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 by 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.