Class QueryableProjection<T>

java.lang.Object
org.apache.druid.segment.projections.QueryableProjection<T>

public class QueryableProjection<T> extends Object
Represents a projection of some base table available to use to build a CursorHolder by a CursorFactory.

Projections are a type of invisible materialized view stored inside of a Segment which can be automatically used if they match the CursorBuildSpec argument passed to CursorFactory.makeCursorHolder(CursorBuildSpec).

In the most basic sense, a projection consists of: - the actual underlying projection rows (rowSelector) - a mapping of CursorBuildSpec columns to underlying projection columns (remapColumns) - and a modified CursorBuildSpec (cursorBuildSpec)

The getRowSelector() and getCursorBuildSpec() methods can be used by a CursorFactory to build a CursorHolder for the projection instead of the base table, and wrapColumnSelectorFactory(ColumnSelectorFactory) and wrapVectorColumnSelectorFactory(VectorColumnSelectorFactory) can be used to decorate the selector factories constructed by that CursorHolder whenever it builds a Cursor or VectorCursor to ensure that all the selectors needed to satisfy the original CursorBuildSpec are available at the correct names.

See Also:
  • Constructor Details

  • Method Details

    • getCursorBuildSpec

      public CursorBuildSpec getCursorBuildSpec()
      The original CursorBuildSpec of a query can be modified if a projection matches the query, such as removing virtual columns which have already been pre-computed.
    • wrapColumnSelectorFactory

      public ColumnSelectorFactory wrapColumnSelectorFactory(ColumnSelectorFactory selectorFactory)
      The projection can contain pre-computed virtual columns or pre-aggregated aggregation columns. At query time, these are remapped to match the desired names for all equivalent components of the CursorBuildSpec.

      For example, if the original CursorBuildSpec has a sum aggregator named 'sum_x' which takes a field 'x' as input, and an equivalent sum aggregation exists on the projection with the name 'xsum' built from the base table column 'x', the wrapped column selector factory will make 'xsum' available as 'sum_x', allowing the query to use the combining aggregator instead of processing the base table for column 'x'.

    • wrapVectorColumnSelectorFactory

      public VectorColumnSelectorFactory wrapVectorColumnSelectorFactory(VectorColumnSelectorFactory selectorFactory)
      The projection can contain pre-computed virtual columns or pre-aggregated aggregation columns. At query time, these are remapped to match the desired names for all equivalent components of the CursorBuildSpec

      For example, if the original CursorBuildSpec has a sum aggregator named 'sum_x' which takes a field 'x' as input, and an equivalent sum aggregation exists on the projection with the name 'xsum' built from the base table column 'x', the wrapped column selector factory will make 'xsum' available as 'sum_x', allowing the query to use the combining aggregator instead of processing the base table for column 'x'.

    • getRowSelector

      public T getRowSelector()
      Backing storage for the rows of the projection as is appropriate for the type of CursorFactory