Class Projections
java.lang.Object
org.apache.druid.segment.projections.Projections
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceReturns true if column is defined inAggregateProjectionSpec.getGroupingColumns()OR if the column does not exist in the base table. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> QueryableProjection<T>findMatchingProjection(CursorBuildSpec cursorBuildSpec, SortedSet<AggregateProjectionMetadata> projections, org.joda.time.Interval dataInterval, Projections.PhysicalColumnChecker physicalChecker, Function<String, T> getRowSelector) static StringgetProjectionSmooshFileName(ProjectionSchema schema, String columnName) static StringgetProjectionSmooshPrefix(ProjectionSchema projectionSchema) static StringgetProjectionSmooshV9FileName(AggregateProjectionMetadata projectionSpec, String columnName) static StringgetProjectionSmooshV9Prefix(AggregateProjectionMetadata projectionSpec) static ProjectionMatchmatchAggregateProjection(AggregateProjectionSchema projection, CursorBuildSpec queryCursorBuildSpec, org.joda.time.Interval dataInterval, Projections.PhysicalColumnChecker physicalColumnChecker) Check if this projection "matches" aCursorBuildSpecfor a query to see if we can use a projection instead.static ProjectionMatchBuildermatchAggregators(AggregateProjectionSchema projection, CursorBuildSpec queryCursorBuildSpec, Projections.PhysicalColumnChecker physicalColumnChecker, ProjectionMatchBuilder matchBuilder) static ProjectionMatchBuildermatchFilter(AggregateProjectionSchema projection, CursorBuildSpec queryCursorBuildSpec, Projections.PhysicalColumnChecker physicalColumnChecker, ProjectionMatchBuilder matchBuilder) static ProjectionMatchBuildermatchGrouping(AggregateProjectionSchema projection, CursorBuildSpec queryCursorBuildSpec, Projections.PhysicalColumnChecker physicalColumnChecker, ProjectionMatchBuilder matchBuilder) static ProjectionMatchBuildermatchQueryPhysicalColumn(String column, AggregateProjectionSchema projection, Projections.PhysicalColumnChecker physicalColumnChecker, ProjectionMatchBuilder matchBuilder) static ProjectionMatchBuildermatchQueryVirtualColumn(VirtualColumn queryVirtualColumn, AggregateProjectionSchema projection, CursorBuildSpec queryCursorBuildSpec, Projections.PhysicalColumnChecker physicalColumnChecker, ProjectionMatchBuilder matchBuilder) static ProjectionMatchBuildermatchQueryVirtualColumns(AggregateProjectionSchema projection, CursorBuildSpec queryCursorBuildSpec, Projections.PhysicalColumnChecker physicalColumnChecker, ProjectionMatchBuilder matchBuilder) static ProjectionMatchBuildermatchRequiredColumn(String column, AggregateProjectionSchema projection, CursorBuildSpec queryCursorBuildSpec, Projections.PhysicalColumnChecker physicalColumnChecker, ProjectionMatchBuilder matchBuilder) Ensure that the projection has the specified column required by aCursorBuildSpecin one form or another.
-
Field Details
-
BASE_TABLE_PROJECTION_NAME
- See Also:
-
-
Method Details
-
findMatchingProjection
@Nullable public static <T> QueryableProjection<T> findMatchingProjection(CursorBuildSpec cursorBuildSpec, SortedSet<AggregateProjectionMetadata> projections, org.joda.time.Interval dataInterval, Projections.PhysicalColumnChecker physicalChecker, Function<String, T> getRowSelector) -
matchAggregateProjection
@Nullable public static ProjectionMatch matchAggregateProjection(AggregateProjectionSchema projection, CursorBuildSpec queryCursorBuildSpec, org.joda.time.Interval dataInterval, Projections.PhysicalColumnChecker physicalColumnChecker) Check if this projection "matches" aCursorBuildSpecfor a query to see if we can use a projection instead. For a projection to match, all grouping columns of the build spec must match, virtual columns of the build spec must either be available as a physical column on the projection, or the inputs to the virtual column must be available on the projection, and all aggregators must be compatible with pre-aggregated columns of the projection perAggregatorFactory.substituteCombiningFactory(AggregatorFactory). If the projection matches, this method returns aProjectionMatchwhich contains an updatedCursorBuildSpecwhich has the remaining virtual columns from the original build spec which must still be computed and the 'combining' aggregator factories to process the pre-aggregated data from the projection, as well as a mapping of query column names to projection column names.- Parameters:
projection- theAggregateProjectionSchemato check for matchqueryCursorBuildSpec- theCursorBuildSpecthat contains the required inputs to build aCursorHolderfor a queryphysicalColumnChecker- Helper utility which can determine if a physical column required by queryCursorBuildSpec is available on the projection OR does not exist on the base table either- Returns:
- a
ProjectionMatchif theCursorBuildSpecmatches the projection, else null
-
matchQueryVirtualColumns
@Nullable public static ProjectionMatchBuilder matchQueryVirtualColumns(AggregateProjectionSchema projection, CursorBuildSpec queryCursorBuildSpec, Projections.PhysicalColumnChecker physicalColumnChecker, ProjectionMatchBuilder matchBuilder) -
matchFilter
@Nullable public static ProjectionMatchBuilder matchFilter(AggregateProjectionSchema projection, CursorBuildSpec queryCursorBuildSpec, Projections.PhysicalColumnChecker physicalColumnChecker, ProjectionMatchBuilder matchBuilder) -
matchGrouping
@Nullable public static ProjectionMatchBuilder matchGrouping(AggregateProjectionSchema projection, CursorBuildSpec queryCursorBuildSpec, Projections.PhysicalColumnChecker physicalColumnChecker, ProjectionMatchBuilder matchBuilder) -
matchAggregators
@Nullable public static ProjectionMatchBuilder matchAggregators(AggregateProjectionSchema projection, CursorBuildSpec queryCursorBuildSpec, Projections.PhysicalColumnChecker physicalColumnChecker, ProjectionMatchBuilder matchBuilder) -
matchRequiredColumn
@Nullable public static ProjectionMatchBuilder matchRequiredColumn(String column, AggregateProjectionSchema projection, CursorBuildSpec queryCursorBuildSpec, Projections.PhysicalColumnChecker physicalColumnChecker, ProjectionMatchBuilder matchBuilder) Ensure that the projection has the specified column required by aCursorBuildSpecin one form or another. If the column is aVirtualColumnon the build spec, ensure that the projection has an equivalent virtual column, or has the required inputs to compute the virtual column. If an equivalent virtual column exists, its name will be added toProjectionMatchBuilder.remapColumn(String, String)so the query virtual column name\ can be mapped to the projection physical column name. If no equivalent virtual column exists, but the inputs are available on the projection to compute it, it will be added toProjectionMatchBuilder.addReferenceedVirtualColumn(VirtualColumn).Finally, if the column is not a virtual column in the query, it is checked with
Projections.PhysicalColumnCheckerwhich true if the column is present on the projection OR if the column is NOT present on the base table (meaning missing columns that do not exist anywhere do not disqualify a projection from being used).- Parameters:
column- Column name to checkprojection-AggregateProjectionSchemato match againstqueryCursorBuildSpec- theCursorBuildSpecrequired by the queryphysicalColumnChecker- Helper to check if the physical column exists on a projection, or does not exist on the base tablematchBuilder- match state to add mappings of query virtual columns to projection physical columns and query virtual columns which still must be computed from projection physical columns- Returns:
ProjectionMatchBuilderwith updated state per the rules described above, or null if the column cannot be matched
-
matchQueryVirtualColumn
@Nullable public static ProjectionMatchBuilder matchQueryVirtualColumn(VirtualColumn queryVirtualColumn, AggregateProjectionSchema projection, CursorBuildSpec queryCursorBuildSpec, Projections.PhysicalColumnChecker physicalColumnChecker, ProjectionMatchBuilder matchBuilder) -
matchQueryPhysicalColumn
@Nullable public static ProjectionMatchBuilder matchQueryPhysicalColumn(String column, AggregateProjectionSchema projection, Projections.PhysicalColumnChecker physicalColumnChecker, ProjectionMatchBuilder matchBuilder) -
getProjectionSmooshV9FileName
public static String getProjectionSmooshV9FileName(AggregateProjectionMetadata projectionSpec, String columnName) -
getProjectionSmooshV9Prefix
-
getProjectionSmooshFileName
-
getProjectionSmooshPrefix
-