Package org.apache.druid.segment
Class RowBasedStorageAdapter<RowType>
- java.lang.Object
-
- org.apache.druid.segment.RowBasedStorageAdapter<RowType>
-
- All Implemented Interfaces:
Expr.InputBindingInspector,ColumnInspector,CursorFactory,StorageAdapter
public class RowBasedStorageAdapter<RowType> extends Object implements StorageAdapter
AStorageAdapterthat is based on a stream of objects. Generally created by aRowBasedSegment.- See Also:
for implementation notes
-
-
Constructor Summary
Constructors Constructor Description RowBasedStorageAdapter(Sequence<RowType> rowSequence, RowAdapter<RowType> rowAdapter, RowSignature rowSignature)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Indexed<String>getAvailableDimensions()Iterable<String>getAvailableMetrics()ColumnCapabilitiesgetColumnCapabilities(String column)Returns capabilities of a particular column, if known.intgetDimensionCardinality(String column)Returns the number of distinct values for a column, orDimensionDictionarySelector.CARDINALITY_UNKNOWNif unknown.org.joda.time.IntervalgetInterval()org.joda.time.DateTimegetMaxIngestedEventTime()org.joda.time.DateTimegetMaxTime()Metadata-only operation that returns an upper bound onColumnHolder.TIME_COLUMN_NAMEvalues for this adapter.ComparablegetMaxValue(String column)Returns the minimum value of the provided column, if known through an index, dictionary, or cache.MetadatagetMetadata()org.joda.time.DateTimegetMinTime()Metadata-only operation that returns a lower bound onColumnHolder.TIME_COLUMN_NAMEvalues for this adapter.ComparablegetMinValue(String column)Returns the minimum value of the provided column, if known through an index, dictionary, or cache.intgetNumRows()RowSignaturegetRowSignature()Returns the row signature of the data available from this adapter.static booleanisQueryGranularityAllowed(org.joda.time.Interval interval, Granularity granularity)Whether the provided time interval and granularity combination is allowed.Sequence<Cursor>makeCursors(Filter filter, org.joda.time.Interval queryInterval, VirtualColumns virtualColumns, Granularity gran, boolean descending, QueryMetrics<?> queryMetrics)Creates a sequence of Cursors, one for each time-granular bucket (based on the provided Granularity).-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.druid.segment.ColumnInspector
getType
-
Methods inherited from interface org.apache.druid.segment.CursorFactory
canVectorize, makeVectorCursor
-
Methods inherited from interface org.apache.druid.math.expr.Expr.InputBindingInspector
areNumeric, areNumeric, areSameTypes, areSameTypes, areScalar, areScalar, canVectorize, canVectorize
-
Methods inherited from interface org.apache.druid.segment.StorageAdapter
hasBuiltInFilters, isFromTombstone
-
-
-
-
Constructor Detail
-
RowBasedStorageAdapter
public RowBasedStorageAdapter(Sequence<RowType> rowSequence, RowAdapter<RowType> rowAdapter, RowSignature rowSignature)
-
-
Method Detail
-
isQueryGranularityAllowed
public static boolean isQueryGranularityAllowed(org.joda.time.Interval interval, Granularity granularity)Whether the provided time interval and granularity combination is allowed. We restrict ETERNITY with non-ALL granularity, because allowing it would involve creating a very high number of time grains. This would cause queries to take an excessive amount of time or run out of memory.
-
getInterval
public org.joda.time.Interval getInterval()
- Specified by:
getIntervalin interfaceStorageAdapter
-
getAvailableDimensions
public Indexed<String> getAvailableDimensions()
- Specified by:
getAvailableDimensionsin interfaceStorageAdapter
-
getAvailableMetrics
public Iterable<String> getAvailableMetrics()
- Specified by:
getAvailableMetricsin interfaceStorageAdapter
-
getRowSignature
public RowSignature getRowSignature()
Description copied from interface:StorageAdapterReturns the row signature of the data available from this adapter. For mutable adapters, even though the signature may evolve over time, any particular object returned by this method is an immutable snapshot.- Specified by:
getRowSignaturein interfaceStorageAdapter
-
getDimensionCardinality
public int getDimensionCardinality(String column)
Description copied from interface:StorageAdapterReturns the number of distinct values for a column, orDimensionDictionarySelector.CARDINALITY_UNKNOWNif unknown. If the column doesn't exist, returns 1, because a column that doesn't exist is treated as a column of default (or null) values.- Specified by:
getDimensionCardinalityin interfaceStorageAdapter
-
getMinTime
public org.joda.time.DateTime getMinTime()
Description copied from interface:StorageAdapterMetadata-only operation that returns a lower bound onColumnHolder.TIME_COLUMN_NAMEvalues for this adapter. May be earlier than the actual minimum data timestamp. ForQueryableIndexStorageAdapterandIncrementalIndexStorageAdapterspecifically, which back regular tables (i.e.TableDataSource), this method contract is tighter: it does return the actual minimum data timestamp. This fact is leveraged byTimeBoundaryQueryto return results using metadata only.- Specified by:
getMinTimein interfaceStorageAdapter
-
getMaxTime
public org.joda.time.DateTime getMaxTime()
Description copied from interface:StorageAdapterMetadata-only operation that returns an upper bound onColumnHolder.TIME_COLUMN_NAMEvalues for this adapter. May be later than the actual maximum data timestamp. ForQueryableIndexStorageAdapterandIncrementalIndexStorageAdapterspecifically, which back regular tables (i.e.TableDataSource), this method contract is tighter: it does return the actual maximum data timestamp. This fact is leveraged byTimeBoundaryQueryto return results using metadata only.- Specified by:
getMaxTimein interfaceStorageAdapter
-
getMinValue
@Nullable public Comparable getMinValue(String column)
Description copied from interface:StorageAdapterReturns the minimum value of the provided column, if known through an index, dictionary, or cache. Returns null if not known. Does not scan the column to find the minimum value.- Specified by:
getMinValuein interfaceStorageAdapter
-
getMaxValue
@Nullable public Comparable getMaxValue(String column)
Description copied from interface:StorageAdapterReturns the minimum value of the provided column, if known through an index, dictionary, or cache. Returns null if not known. Does not scan the column to find the maximum value.- Specified by:
getMaxValuein interfaceStorageAdapter
-
getColumnCapabilities
@Nullable public ColumnCapabilities getColumnCapabilities(String column)
Description copied from interface:StorageAdapterReturns capabilities of a particular column, if known. May be null if the column doesn't exist, or if the column does exist but the capabilities are unknown. The latter is possible with dynamically discovered columns. Note that StorageAdapters are representations of "real" segments, so they are not aware of any virtual columns that may be involved in a query. In general, query engines should instead use the methodColumnSelectorFactory.getColumnCapabilities(String), which returns capabilities for virtual columns as well.- Specified by:
getColumnCapabilitiesin interfaceColumnInspector- Specified by:
getColumnCapabilitiesin interfaceStorageAdapter- Parameters:
column- column name- Returns:
- capabilities, or null
-
getNumRows
public int getNumRows()
- Specified by:
getNumRowsin interfaceStorageAdapter
-
getMaxIngestedEventTime
public org.joda.time.DateTime getMaxIngestedEventTime()
- Specified by:
getMaxIngestedEventTimein interfaceStorageAdapter
-
getMetadata
public Metadata getMetadata()
- Specified by:
getMetadatain interfaceStorageAdapter
-
makeCursors
public Sequence<Cursor> makeCursors(@Nullable Filter filter, org.joda.time.Interval queryInterval, VirtualColumns virtualColumns, Granularity gran, boolean descending, @Nullable QueryMetrics<?> queryMetrics)
Description copied from interface:CursorFactoryCreates a sequence of Cursors, one for each time-granular bucket (based on the provided Granularity).- Specified by:
makeCursorsin interfaceCursorFactory
-
-