Package org.apache.druid.segment
Interface VirtualColumn
-
- All Superinterfaces:
Cacheable
- All Known Implementing Classes:
ExpressionVirtualColumn,FallbackVirtualColumn,ListFilteredVirtualColumn,NestedFieldVirtualColumn,SettableLongVirtualColumn
public interface VirtualColumn extends Cacheable
Virtual columns are "views" created over aColumnSelectorFactoryorColumnSelector. They can potentially draw from multiple underlying columns, although they always present themselves as if they were a single column. A virtual column object will be shared amongst threads and must be thread safe. The selectors returned from the various makeXXXSelector methods need not be thread safe.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default booleancanVectorize(ColumnInspector inspector)ColumnCapabilitiescapabilities(String columnName)Deprecated.default ColumnCapabilitiescapabilities(ColumnInspector inspector, String columnName)Return theColumnCapabilitieswhich best describe the optimal selector to read from this virtual column.default ColumnIndexSuppliergetIndexSupplier(String columnName, ColumnIndexSelector columnIndexSelector)Get theColumnIndexSupplierfor the specified virtual column, with the assistance of aColumnIndexSelectorto allow reading things from segments.StringgetOutputName()Output name of this column.ColumnValueSelector<?>makeColumnValueSelector(String columnName, ColumnSelectorFactory factory)Build aColumnValueSelectorcorresponding to this virtual column.default ColumnValueSelector<?>makeColumnValueSelector(String columnName, ColumnSelector columnSelector, ReadableOffset offset)Returns similarColumnValueSelectorobject as returned bymakeColumnValueSelector(String, ColumnSelectorFactory)except this method has full access to the underlying column and can potentially provide a more efficient implementation.DimensionSelectormakeDimensionSelector(DimensionSpec dimensionSpec, ColumnSelectorFactory factory)Build a selector corresponding to this virtual column.default DimensionSelectormakeDimensionSelector(DimensionSpec dimensionSpec, ColumnSelector columnSelector, ReadableOffset offset)Returns similarDimensionSelectorobject as returned bymakeDimensionSelector(DimensionSpec, ColumnSelectorFactory)except this method has full access to the underlying column and can potentially provide a more efficient implementation.default MultiValueDimensionVectorSelectormakeMultiValueVectorDimensionSelector(DimensionSpec dimensionSpec, ColumnSelector columnSelector, ReadableVectorOffset offset)Returns similarSingleValueDimensionVectorSelectorobject as returned bymakeSingleValueVectorDimensionSelector(DimensionSpec, ColumnSelector, ReadableVectorOffset)except this method has full access to the underlying column and can potentially provide a more efficient implementation.default MultiValueDimensionVectorSelectormakeMultiValueVectorDimensionSelector(DimensionSpec dimensionSpec, VectorColumnSelectorFactory factory)Build aMultiValueDimensionVectorSelectorcorresponding to this virtual column.default SingleValueDimensionVectorSelectormakeSingleValueVectorDimensionSelector(DimensionSpec dimensionSpec, ColumnSelector columnSelector, ReadableVectorOffset offset)Returns similarSingleValueDimensionVectorSelectorobject as returned bymakeSingleValueVectorDimensionSelector(DimensionSpec, ColumnSelector, ReadableVectorOffset)except this method has full access to the underlying column and can potentially provide a more efficient implementation.default SingleValueDimensionVectorSelectormakeSingleValueVectorDimensionSelector(DimensionSpec dimensionSpec, VectorColumnSelectorFactory factory)Build aSingleValueDimensionVectorSelectorcorresponding to this virtual column.default VectorObjectSelectormakeVectorObjectSelector(String columnName, ColumnSelector columnSelector, ReadableVectorOffset offset)Returns similarVectorObjectSelectorobject as returned bymakeVectorObjectSelector(String, VectorColumnSelectorFactory)except this method has full access to the underlying column and can potentially provide a more efficient implementation.default VectorObjectSelectormakeVectorObjectSelector(String columnName, VectorColumnSelectorFactory factory)Build aVectorObjectSelectorcorresponding to this virtual column.default VectorValueSelectormakeVectorValueSelector(String columnName, ColumnSelector columnSelector, ReadableVectorOffset offset)Returns similarVectorValueSelectorobject as returned bymakeVectorValueSelector(String, VectorColumnSelectorFactory)except this method has full access to the underlying column and can potentially provide a more efficient implementation.default VectorValueSelectormakeVectorValueSelector(String columnName, VectorColumnSelectorFactory factory)Build aVectorValueSelectorcorresponding to this virtual column.List<String>requiredColumns()Returns a list of columns that this virtual column will access.booleanusesDotNotation()Indicates that this virtual column can be referenced with dot notation.-
Methods inherited from interface org.apache.druid.java.util.common.Cacheable
getCacheKey
-
-
-
-
Method Detail
-
getOutputName
String getOutputName()
Output name of this column.- Returns:
- name
-
makeDimensionSelector
DimensionSelector makeDimensionSelector(DimensionSpec dimensionSpec, ColumnSelectorFactory factory)
Build a selector corresponding to this virtual column. Also provides the name that the virtual column was referenced with (throughDimensionSpec.getDimension(), which is useful if this column uses dot notation. The virtual column is expected to apply any necessary decoration from the dimensionSpec.
-
makeDimensionSelector
@Nullable default DimensionSelector makeDimensionSelector(DimensionSpec dimensionSpec, ColumnSelector columnSelector, ReadableOffset offset)
Returns similarDimensionSelectorobject as returned bymakeDimensionSelector(DimensionSpec, ColumnSelectorFactory)except this method has full access to the underlying column and can potentially provide a more efficient implementation. Users of this interface must ensure to first call this method whenever possible. Typically this can not be called in query paths on top of IncrementalIndex which doesn't have columns as in persisted segments.
-
makeColumnValueSelector
ColumnValueSelector<?> makeColumnValueSelector(String columnName, ColumnSelectorFactory factory)
Build aColumnValueSelectorcorresponding to this virtual column. Also provides the name that the virtual column was referenced with, which is useful if this column uses dot notation.
-
makeColumnValueSelector
@Nullable default ColumnValueSelector<?> makeColumnValueSelector(String columnName, ColumnSelector columnSelector, ReadableOffset offset)
Returns similarColumnValueSelectorobject as returned bymakeColumnValueSelector(String, ColumnSelectorFactory)except this method has full access to the underlying column and can potentially provide a more efficient implementation. Users of this interface must ensure to first call this method whenever possible. Typically this can not be called in query paths on top of IncrementalIndex which doesn't have columns as in persisted segments.
-
canVectorize
default boolean canVectorize(ColumnInspector inspector)
-
makeSingleValueVectorDimensionSelector
default SingleValueDimensionVectorSelector makeSingleValueVectorDimensionSelector(DimensionSpec dimensionSpec, VectorColumnSelectorFactory factory)
Build aSingleValueDimensionVectorSelectorcorresponding to this virtual column. Also provides the name that the virtual column was referenced with (throughDimensionSpec.getDimension(), which is useful if this column uses dot notation. The virtual column is expected to apply any necessary decoration from theDimensionSpec.
-
makeSingleValueVectorDimensionSelector
@Nullable default SingleValueDimensionVectorSelector makeSingleValueVectorDimensionSelector(DimensionSpec dimensionSpec, ColumnSelector columnSelector, ReadableVectorOffset offset)
Returns similarSingleValueDimensionVectorSelectorobject as returned bymakeSingleValueVectorDimensionSelector(DimensionSpec, ColumnSelector, ReadableVectorOffset)except this method has full access to the underlying column and can potentially provide a more efficient implementation. Users of this interface must ensure to first call this method whenever possible.
-
makeMultiValueVectorDimensionSelector
default MultiValueDimensionVectorSelector makeMultiValueVectorDimensionSelector(DimensionSpec dimensionSpec, VectorColumnSelectorFactory factory)
Build aMultiValueDimensionVectorSelectorcorresponding to this virtual column. Also provides the name that the virtual column was referenced with (throughDimensionSpec.getDimension(), which is useful if this column uses dot notation. The virtual column is expected to apply any necessary decoration from theDimensionSpec.
-
makeMultiValueVectorDimensionSelector
@Nullable default MultiValueDimensionVectorSelector makeMultiValueVectorDimensionSelector(DimensionSpec dimensionSpec, ColumnSelector columnSelector, ReadableVectorOffset offset)
Returns similarSingleValueDimensionVectorSelectorobject as returned bymakeSingleValueVectorDimensionSelector(DimensionSpec, ColumnSelector, ReadableVectorOffset)except this method has full access to the underlying column and can potentially provide a more efficient implementation. Users of this interface must ensure to first call this method whenever possible.
-
makeVectorValueSelector
default VectorValueSelector makeVectorValueSelector(String columnName, VectorColumnSelectorFactory factory)
Build aVectorValueSelectorcorresponding to this virtual column. Also provides the name that the virtual column was referenced with, which is useful if this column uses dot notation.
-
makeVectorValueSelector
@Nullable default VectorValueSelector makeVectorValueSelector(String columnName, ColumnSelector columnSelector, ReadableVectorOffset offset)
Returns similarVectorValueSelectorobject as returned bymakeVectorValueSelector(String, VectorColumnSelectorFactory)except this method has full access to the underlying column and can potentially provide a more efficient implementation. Users of this interface must ensure to first call this method whenever possible.
-
makeVectorObjectSelector
default VectorObjectSelector makeVectorObjectSelector(String columnName, VectorColumnSelectorFactory factory)
Build aVectorObjectSelectorcorresponding to this virtual column. Also provides the name that the virtual column was referenced with, which is useful if this column uses dot notation.
-
makeVectorObjectSelector
@Nullable default VectorObjectSelector makeVectorObjectSelector(String columnName, ColumnSelector columnSelector, ReadableVectorOffset offset)
Returns similarVectorObjectSelectorobject as returned bymakeVectorObjectSelector(String, VectorColumnSelectorFactory)except this method has full access to the underlying column and can potentially provide a more efficient implementation. Users of this interface must ensure to first call this method whenever possible.
-
capabilities
@Deprecated ColumnCapabilities capabilities(String columnName)
Deprecated.This method is deprecated in favor ofcapabilities(ColumnInspector, String), which should be used whenever possible and can support virtual column implementations that need to inspect other columns as inputs. This is a fallback implementation to return the capabilities of this virtual column, which includes a type that corresponds to the best performing base selector supertype (e. g.BaseLongColumnValueSelector) of the object, returned frommakeColumnValueSelector(String, ColumnSelectorFactory). May vary based on columnName if this column uses dot notation.- Parameters:
columnName- the name this virtual column was referenced with- Returns:
- capabilities, must not be null
-
capabilities
@Nullable default ColumnCapabilities capabilities(ColumnInspector inspector, String columnName)
Return theColumnCapabilitieswhich best describe the optimal selector to read from this virtual column.The
ColumnInspector(most likely corresponding to an underlyingColumnSelectorFactoryof a query) allows the virtual column to consider this information if necessary to compute its output type details.Examples of this include the
ExpressionVirtualColumn, which takes input from other columns and uses theColumnInspectorto infer the output type of expressions based on the types of the inputs.- Parameters:
inspector- column inspector to provide additional information of other available columnscolumnName- the name this virtual column was referenced with- Returns:
- capabilities, must not be null
-
requiredColumns
List<String> requiredColumns()
Returns a list of columns that this virtual column will access. This may include the names of other virtual columns. May be empty if a virtual column doesn't access any underlying columns. Does not pass columnName because there is an assumption that the list of columns needed by a dot-notation supporting virtual column will not vary based on the columnName.- Returns:
- column names
-
usesDotNotation
boolean usesDotNotation()
Indicates that this virtual column can be referenced with dot notation. For example, a virtual column named "foo" could be referred to as "foo.bar" with the Cursor it is registered with. In that case, init will be called with columnName "foo.bar" rather than "foo".- Returns:
- whether to use dot notation
-
getIndexSupplier
@Nullable default ColumnIndexSupplier getIndexSupplier(String columnName, ColumnIndexSelector columnIndexSelector)
Get theColumnIndexSupplierfor the specified virtual column, with the assistance of aColumnIndexSelectorto allow reading things from segments. If the virtual column has no indexes, this method will return null, or may also return a non-null supplier whose methods may return null values - having a supplier is no guarantee that the column has indexes.
-
-