Package org.apache.druid.frame.field
Class StringFieldReader
- java.lang.Object
-
- org.apache.druid.frame.field.StringFieldReader
-
- All Implemented Interfaces:
FieldReader
- Direct Known Subclasses:
StringArrayFieldReader
public class StringFieldReader extends Object implements FieldReader
Reads fields written byStringFieldWriter
orStringArrayFieldWriter
. Strings are written in UTF8 and terminated byStringFieldWriter.VALUE_TERMINATOR
. Note that this byte appears in valid UTF8 encodings if and only if the string contains a NUL (char 0). Therefore, this field writer cannot write out strings containing NUL characters. All rows are terminated byStringFieldWriter.ROW_TERMINATOR
. Empty rows are represented in one byte: solely thatStringFieldWriter.ROW_TERMINATOR
. Rows that are null themselves (i.e., a null array) are represented as aStringFieldWriter.NULL_ROW
followed by aStringFieldWriter.ROW_TERMINATOR
. This encoding for null arrays is decoded by older readers as an empty array; null arrays are a feature that did not exist in earlier versions of the code. Null strings are stored asStringFieldWriter.NULL_BYTE
. All other strings are prepended byStringFieldWriter.NOT_NULL_BYTE
byte to differentiate them from nulls. This encoding allows the encoded data to be compared as bytes in a way that matches the behavior ofStringDimensionHandler.DIMENSION_SELECTOR_COMPARATOR
, except null and empty list are not considered equal.
-
-
Constructor Summary
Constructors Modifier Constructor Description StringFieldReader()
protected
StringFieldReader(boolean asArray)
Create a string reader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isComparable()
Whether this field is comparable.boolean
isNull(org.apache.datasketches.memory.Memory memory, long position)
Whether the provided memory position points to a null value.ColumnValueSelector<?>
makeColumnValueSelector(org.apache.datasketches.memory.Memory memory, ReadableFieldPointer fieldPointer)
Create aColumnValueSelector
backed by some memory and a moveable pointer.DimensionSelector
makeDimensionSelector(org.apache.datasketches.memory.Memory memory, ReadableFieldPointer fieldPointer, ExtractionFn extractionFn)
Create aDimensionSelector
backed by some memory and a moveable pointer.
-
-
-
Constructor Detail
-
StringFieldReader
public StringFieldReader()
-
StringFieldReader
protected StringFieldReader(boolean asArray)
Create a string reader.- Parameters:
asArray
- if false, selectors frommakeColumnValueSelector(org.apache.datasketches.memory.Memory, org.apache.druid.frame.field.ReadableFieldPointer)
behave likeValueType.STRING
selectors (potentially multi-value ones). If true, selectors frommakeColumnValueSelector(org.apache.datasketches.memory.Memory, org.apache.druid.frame.field.ReadableFieldPointer)
behave like string array selectors.
-
-
Method Detail
-
makeColumnValueSelector
public ColumnValueSelector<?> makeColumnValueSelector(org.apache.datasketches.memory.Memory memory, ReadableFieldPointer fieldPointer)
Description copied from interface:FieldReader
Create aColumnValueSelector
backed by some memory and a moveable pointer.- Specified by:
makeColumnValueSelector
in interfaceFieldReader
-
makeDimensionSelector
public DimensionSelector makeDimensionSelector(org.apache.datasketches.memory.Memory memory, ReadableFieldPointer fieldPointer, @Nullable ExtractionFn extractionFn)
Description copied from interface:FieldReader
Create aDimensionSelector
backed by some memory and a moveable pointer.- Specified by:
makeDimensionSelector
in interfaceFieldReader
-
isNull
public boolean isNull(org.apache.datasketches.memory.Memory memory, long position)
Description copied from interface:FieldReader
Whether the provided memory position points to a null value.- Specified by:
isNull
in interfaceFieldReader
-
isComparable
public boolean isComparable()
Description copied from interface:FieldReader
Whether this field is comparable. Comparable fields can be compared as unsigned bytes.- Specified by:
isComparable
in interfaceFieldReader
-
-