Class FirstLastVectorAggregator<RhsType,PairType extends SerializablePair<Long,RhsType>>
- java.lang.Object
-
- org.apache.druid.query.aggregation.firstlast.FirstLastVectorAggregator<RhsType,PairType>
-
- All Implemented Interfaces:
VectorAggregator
- Direct Known Subclasses:
DoubleFirstLastVectorAggregator,FloatFirstLastVectorAggregator,LongFirstLastVectorAggregator,SingleStringFirstLastDimensionVectorAggregator,StringFirstLastVectorAggregator
public abstract class FirstLastVectorAggregator<RhsType,PairType extends SerializablePair<Long,RhsType>> extends Object implements VectorAggregator
Base type for vectorized version of on heap 'last' aggregator for primitive numeric column selectors..
-
-
Field Summary
Fields Modifier and Type Field Description static intNULLITY_OFFSETstatic intVALUE_OFFSET
-
Constructor Summary
Constructors Constructor Description FirstLastVectorAggregator(VectorValueSelector timeSelector, VectorValueSelector valueSelector, VectorObjectSelector objectSelector, SelectionPredicate selectionPredicate)timeSelector can be null, however aggregate functions are no-op then.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaggregate(ByteBuffer buf, int numRows, int[] positions, int[] rows, int positionOffset)Aggregate a list of rows ("rows") into a list of aggregation slots ("positions").voidaggregate(ByteBuffer buf, int position, int startRow, int endRow)Aggregate a range of rows into a single aggregation slot.voidclose()Release any resources used by the aggregator.protected abstract voidputDefaultValue(ByteBuffer buf, int position, long time)Sets the default value for the type in the byte buffer at the given position.protected abstract voidputNull(ByteBuffer buf, int position, long time)protected abstract voidputValue(ByteBuffer buf, int position, long time, VectorValueSelector valueSelector, int index)Sets the value represented by the valueSelector at the given index.protected abstract voidputValue(ByteBuffer buf, int position, long time, RhsType value)Sets the value at the position.protected abstract PairTypereadPairFromVectorSelectors(boolean[] timeNullityVector, long[] timeVector, Object[] maybeFoldedObjects, int index)-
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.query.aggregation.VectorAggregator
get, init, relocate
-
-
-
-
Field Detail
-
NULLITY_OFFSET
public static final int NULLITY_OFFSET
- See Also:
- Constant Field Values
-
VALUE_OFFSET
public static final int VALUE_OFFSET
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FirstLastVectorAggregator
public FirstLastVectorAggregator(@Nullable VectorValueSelector timeSelector, @Nullable VectorValueSelector valueSelector, @Nullable VectorObjectSelector objectSelector, SelectionPredicate selectionPredicate)
timeSelector can be null, however aggregate functions are no-op then.
-
-
Method Detail
-
aggregate
public void aggregate(ByteBuffer buf, int position, int startRow, int endRow)
Description copied from interface:VectorAggregatorAggregate a range of rows into a single aggregation slot. Implementations must not change the position, limit or mark of the given buffer- Specified by:
aggregatein interfaceVectorAggregator- Parameters:
buf- byte buffer storing the byte array representation of the aggregateposition- offset within the byte buffer at which the current aggregate value is storedstartRow- first row of the range within the current batch to aggregate (inclusive)endRow- end row of the range (exclusive)
-
aggregate
public void aggregate(ByteBuffer buf, int numRows, int[] positions, @Nullable int[] rows, int positionOffset)
Description copied from interface:VectorAggregatorAggregate a list of rows ("rows") into a list of aggregation slots ("positions"). Implementations must not change the position, limit or mark of the given buffer- Specified by:
aggregatein interfaceVectorAggregator- Parameters:
buf- byte buffer storing the byte array representation of the aggregatenumRows- number of rows to aggregatepositions- array of aggregate value positions within the buffer; must be at least as long as "numRows"rows- array of row numbers within the current row batch; must be at least as long as "numRows". If null, the aggregator will aggregate rows from 0 (inclusive) to numRows (exclusive).positionOffset- an offset to apply to each value from "positions"
-
putValue
protected abstract void putValue(ByteBuffer buf, int position, long time, RhsType value)
Sets the value at the position. Subclasses can assume that the value isn't null 'position' refers to the location where the value of the pair will get updated (as opposed to the beginning of the serialized pair) It is only used if objectSelector is supplied
-
putValue
protected abstract void putValue(ByteBuffer buf, int position, long time, VectorValueSelector valueSelector, int index)
Sets the value represented by the valueSelector at the given index. A slightly redundant method toputValue(ByteBuffer, int, long, Object)to avoid autoboxing for the numeric types. Subclasses can assume that valueSelector.getNullVector[index] is false (i.e. the value represented at the index isn't null) It is used if valueSelector is supplied
-
putDefaultValue
protected abstract void putDefaultValue(ByteBuffer buf, int position, long time)
Sets the default value for the type in the byte buffer at the given position. It is only used when replaceNullWithDefault = true, therefore the callers don't need to handle any other case. 'position' refers to the location where the value of the pair will get updated (as opposed to the beginning of the serialized pair)
-
putNull
protected abstract void putNull(ByteBuffer buf, int position, long time)
-
readPairFromVectorSelectors
protected abstract PairType readPairFromVectorSelectors(boolean[] timeNullityVector, long[] timeVector, Object[] maybeFoldedObjects, int index)
-
close
public void close()
Description copied from interface:VectorAggregatorRelease any resources used by the aggregator. The aggregator may be reused after this call, by callingVectorAggregator.init(ByteBuffer, int)followed by other methods as normal. This call would be more properly named "reset", but we use the name "close" to improve compatibility with existing aggregator implementations in extensions.- Specified by:
closein interfaceVectorAggregator
-
-