Package org.apache.druid.frame.field
Class NumericArrayFieldSelector<ElementType extends Number>
- java.lang.Object
-
- org.apache.druid.frame.field.NumericArrayFieldSelector<ElementType>
-
- Type Parameters:
ElementType
- Type of the individual array elements
- All Implemented Interfaces:
HotLoopCallee
,BaseDoubleColumnValueSelector
,BaseFloatColumnValueSelector
,BaseLongColumnValueSelector
,BaseNullableColumnValueSelector
,BaseObjectColumnValueSelector
,ColumnValueSelector
public abstract class NumericArrayFieldSelector<ElementType extends Number> extends Object implements ColumnValueSelector
Base implementation of the column value selector that the concrete numeric field reader implementations inherit from. The selector contains the logic to construct an array written byNumericArrayFieldWriter
, and present it as a column value selector. The inheritors of this class are expected to implement 1.getIndividualValueAtMemory(long)
Which extracts the element from the field where it was written to. Returns null if the value at that location represents a null element 2.getIndividualFieldSize()
Which informs the method about the field size corresponding to each element in the numeric array's serialized representation
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.datasketches.memory.Memory
memory
Memory containing the serialized values of the array-
Fields inherited from interface org.apache.druid.segment.ColumnValueSelector
EMPTY_ARRAY
-
-
Constructor Summary
Constructors Constructor Description NumericArrayFieldSelector(org.apache.datasketches.memory.Memory memory, ReadableFieldPointer fieldPointer)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Class
classOfObject()
Most-specific class of object returned byBaseObjectColumnValueSelector.getObject()
, if known in advance.double
getDouble()
float
getFloat()
abstract int
getIndividualFieldSize()
Returns the field size that each element in the reader array consumes.abstract ElementType
getIndividualValueAtMemory(long position)
Returns the value of the individual element written at the given positionlong
getLong()
Object
getObject()
Returns the currently-selected object.void
inspectRuntimeShape(RuntimeShapeInspector inspector)
Implementations of this method should callinspector.visit()
with all fields of this class, which meet two conditions: 1.boolean
isNull()
Returns true if the primitive long, double, or float value returned by this selector should be treated as null.
-
-
-
Constructor Detail
-
NumericArrayFieldSelector
public NumericArrayFieldSelector(org.apache.datasketches.memory.Memory memory, ReadableFieldPointer fieldPointer)
-
-
Method Detail
-
inspectRuntimeShape
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
Description copied from interface:HotLoopCallee
Implementations of this method should callinspector.visit()
with all fields of this class, which meet two conditions: 1. They are used in methods of this class, annotated withCalledFromHotLoop
2. They are either: a. Nullable objects b. Instances of HotLoopCallee c. Objects, which don't always have a specific class in runtime. For example, a field of typeSet
could beHashSet
orTreeSet
in runtime, depending on how this instance (the instance on which inspectRuntimeShape() is called) is configured. d. ByteBuffer or similar objects, where byte order matters e. boolean flags, affecting branch taking f. Arrays of objects, meeting any of conditions a-e.- Specified by:
inspectRuntimeShape
in interfaceHotLoopCallee
-
getObject
@Nullable public Object getObject()
Description copied from interface:BaseObjectColumnValueSelector
Returns the currently-selected object. The behavior of this method depends on the type of selector, which can be determined by callingColumnSelectorFactory.getColumnCapabilities(String)
on the sameColumnSelectorFactory
that you got this selector from. If the capabilties are nonnull, the selector type is given byTypeSignature.getType()
. String selectors, where type isColumnType.STRING
, may return any type of object from this method, especially in cases where the selector is casting objects to string at selection time. Callers are encouraged to avoid the need to deal with various objects by usingColumnSelectorFactory.makeDimensionSelector(org.apache.druid.query.dimension.DimensionSpec)
instead. Numeric selectors, whereTypeSignature.isNumeric()
, may return any type ofNumber
. Callers that wish to deal with more specific types should treat the originalColumnValueSelector
as aBaseLongColumnValueSelector
,BaseDoubleColumnValueSelector
, orBaseFloatColumnValueSelector
instead. Array selectors, whereTypeSignature.isArray()
, must returnObject[]
. The array may contain null elements, and the array itself may also be null. Selectors of unknown type, whereColumnSelectorFactory.getColumnCapabilities(String)
returns null, may return any type of object. Callers must be prepared for a wide variety of possible input objects. This case is common during ingestion, where selectors are built on top of external data.- Specified by:
getObject
in interfaceBaseObjectColumnValueSelector<ElementType extends Number>
-
classOfObject
public Class classOfObject()
Description copied from interface:BaseObjectColumnValueSelector
Most-specific class of object returned byBaseObjectColumnValueSelector.getObject()
, if known in advance. This method returnsObject
when selectors do not know in advance what class of object they may return.- Specified by:
classOfObject
in interfaceBaseObjectColumnValueSelector<ElementType extends Number>
-
getDouble
public double getDouble()
- Specified by:
getDouble
in interfaceBaseDoubleColumnValueSelector
-
getFloat
public float getFloat()
- Specified by:
getFloat
in interfaceBaseFloatColumnValueSelector
-
getLong
public long getLong()
- Specified by:
getLong
in interfaceBaseLongColumnValueSelector
-
isNull
public boolean isNull()
Description copied from interface:BaseNullableColumnValueSelector
Returns true if the primitive long, double, or float value returned by this selector should be treated as null. Users ofBaseLongColumnValueSelector.getLong()
,BaseDoubleColumnValueSelector.getDouble()
andBaseFloatColumnValueSelector.getFloat()
must check this method first, or else they may improperly use placeholder values returned by the primitive get methods. Users ofBaseObjectColumnValueSelector.getObject()
should not call this method. Instead, call "getObject" and check if it is null.- Specified by:
isNull
in interfaceBaseNullableColumnValueSelector
-
getIndividualValueAtMemory
@Nullable public abstract ElementType getIndividualValueAtMemory(long position)
Returns the value of the individual element written at the given position
-
getIndividualFieldSize
public abstract int getIndividualFieldSize()
Returns the field size that each element in the reader array consumes. It is usually 1 + ElementType.SIZE, to hold the element's nullity, and it's representation.
-
-