Package org.apache.druid.segment.virtual
Class ExpressionDeferredGroupByVectorColumnSelector
- java.lang.Object
-
- org.apache.druid.segment.virtual.ExpressionDeferredGroupByVectorColumnSelector
-
- All Implemented Interfaces:
GroupingSelector,GroupByVectorColumnSelector
public class ExpressionDeferredGroupByVectorColumnSelector extends Object implements GroupByVectorColumnSelector
Implementation ofGroupByVectorColumnSelectorthat uses a wide key representing all expression inputs to enable deferring expression evaluation towriteKeyToResultRow(MemoryPointer, int, ResultRow, int). For example, the expression "coalesce(x, y)" would write a key composed of (x, y) inwriteKeys(org.apache.datasketches.memory.WritableMemory, int, int, int, int), then compute "coalesce(x, y)" inwriteKeyToResultRow(org.apache.druid.query.groupby.epinephelinae.collection.MemoryPointer, int, org.apache.druid.query.groupby.ResultRow, int).
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetGroupingKeySize()Get the size in bytes of the key parts generated by this column.intgetValueCardinality()Returns the value cardinality if it is known (such as when backed by aDimensionDictionarySelector).voidreset()Reset any internal state held by this selector.intwriteKeys(org.apache.datasketches.memory.WritableMemory keySpace, int keySize, int keyOffset, int startRow, int endRow)Write key parts for this column, from startRow (inclusive) to endRow (exclusive), into keySpace starting at keyOffset.voidwriteKeyToResultRow(MemoryPointer keyMemory, int keyOffset, ResultRow resultRow, int resultRowPosition)Write key parts for this column into a particular result row.
-
-
-
Method Detail
-
getGroupingKeySize
public int getGroupingKeySize()
Description copied from interface:GroupByVectorColumnSelectorGet the size in bytes of the key parts generated by this column.- Specified by:
getGroupingKeySizein interfaceGroupByVectorColumnSelector
-
getValueCardinality
public int getValueCardinality()
Description copied from interface:GroupingSelectorReturns the value cardinality if it is known (such as when backed by aDimensionDictionarySelector). If there are only null values, this method should return 1. If the cardinality is not known, returnsDimensionDictionarySelector.CARDINALITY_UNKNOWN.- Specified by:
getValueCardinalityin interfaceGroupingSelector
-
writeKeys
public int writeKeys(org.apache.datasketches.memory.WritableMemory keySpace, int keySize, int keyOffset, int startRow, int endRow)Description copied from interface:GroupByVectorColumnSelectorWrite key parts for this column, from startRow (inclusive) to endRow (exclusive), into keySpace starting at keyOffset.- Specified by:
writeKeysin interfaceGroupByVectorColumnSelector- Parameters:
keySpace- key memorykeySize- size of the overall key (not just the part for this column)keyOffset- starting position for the first key part within keySpacestartRow- starting row (inclusive) within the current vectorendRow- ending row (exclusive) within the current vector- Returns:
- estimated increase in internal state footprint, in bytes, as a result of this operation. May be zero if memory did not increase as a result of this operation. Will not be negative.
-
writeKeyToResultRow
public void writeKeyToResultRow(MemoryPointer keyMemory, int keyOffset, ResultRow resultRow, int resultRowPosition)
Description copied from interface:GroupByVectorColumnSelectorWrite key parts for this column into a particular result row.- Specified by:
writeKeyToResultRowin interfaceGroupByVectorColumnSelector- Parameters:
keyMemory- key memorykeyOffset- starting position for this key part within keyMemory (starting fromMemoryPointer.position)resultRow- result row to receive key partsresultRowPosition- position within the result row for this key part
-
reset
public void reset()
Description copied from interface:GroupByVectorColumnSelectorReset any internal state held by this selector. After this method is called, any memory previously written byGroupByVectorColumnSelector.writeKeys(org.apache.datasketches.memory.WritableMemory, int, int, int, int)must be considered unreadable. CallingGroupByVectorColumnSelector.writeKeyToResultRow(org.apache.druid.query.groupby.epinephelinae.collection.MemoryPointer, int, org.apache.druid.query.groupby.ResultRow, int)on that memory has undefined behavior.- Specified by:
resetin interfaceGroupByVectorColumnSelector
-
-