Class StringFieldReader
- All Implemented Interfaces:
FieldReader
- Direct Known Subclasses:
StringArrayFieldReader
StringFieldWriter or StringArrayFieldWriter.
Strings are written in UTF8 and terminated by StringFieldWriter.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 by StringFieldWriter.ROW_TERMINATOR.
Empty rows are represented in one byte: solely that StringFieldWriter.ROW_TERMINATOR. Rows that are null
themselves (i.e., a null array) are represented as a StringFieldWriter.NULL_ROW followed by a
StringFieldWriter.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 as StringFieldWriter.NULL_BYTE. All other strings are prepended by
StringFieldWriter.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 of
StringDimensionHandler.DIMENSION_SELECTOR_COMPARATOR, except null and
empty list are not considered equal.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedStringFieldReader(boolean asArray) Create a string reader. -
Method Summary
Modifier and TypeMethodDescriptionbooleanisNull(org.apache.datasketches.memory.Memory memory, long position) Whether the provided memory position points to a null value.makeColumnValueSelector(org.apache.datasketches.memory.Memory memory, ReadableFieldPointer fieldPointer) Create aColumnValueSelectorbacked by some memory and a moveable pointer.makeDimensionSelector(org.apache.datasketches.memory.Memory memory, ReadableFieldPointer fieldPointer, ExtractionFn extractionFn) Create aDimensionSelectorbacked by some memory and a moveable pointer.makeRACColumn(Frame frame, RowSignature signature, String columnName) Create aColumnwhich provides accses to the rows in the frame, via theColumn.toAccessor().
-
Field Details
-
EXPECTED_BYTES_FOR_NULL
public static final byte[] EXPECTED_BYTES_FOR_NULL
-
-
Constructor Details
-
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.STRINGselectors (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 Details
-
makeColumnValueSelector
public ColumnValueSelector<?> makeColumnValueSelector(org.apache.datasketches.memory.Memory memory, ReadableFieldPointer fieldPointer) Description copied from interface:FieldReaderCreate aColumnValueSelectorbacked by some memory and a moveable pointer.- Specified by:
makeColumnValueSelectorin interfaceFieldReader
-
makeDimensionSelector
public DimensionSelector makeDimensionSelector(org.apache.datasketches.memory.Memory memory, ReadableFieldPointer fieldPointer, @Nullable ExtractionFn extractionFn) Description copied from interface:FieldReaderCreate aDimensionSelectorbacked by some memory and a moveable pointer.- Specified by:
makeDimensionSelectorin interfaceFieldReader
-
isNull
public boolean isNull(org.apache.datasketches.memory.Memory memory, long position) Description copied from interface:FieldReaderWhether the provided memory position points to a null value.- Specified by:
isNullin interfaceFieldReader
-
makeRACColumn
Description copied from interface:FieldReaderCreate aColumnwhich provides accses to the rows in the frame, via theColumn.toAccessor().- Specified by:
makeRACColumnin interfaceFieldReader
-