VariantBuilder
Encodes Variant values.
The builder is a streaming encoder: values are appended to one growable buffer in the order they arrive, and a container's header — which cannot be written first, because it depends on how many elements there turn out to be, how wide their offsets are and how large the biggest field id is — is inserted in front of the children once they are complete. That keeps encoding to a single pass with no intermediate tree.
val builder = VariantBuilder()
builder.startObject()
builder.field("id"); builder.appendLong(7)
builder.field("tags"); builder.startArray(); builder.appendString("a"); builder.endArray()
builder.endObject()
val variant = builder.buildVariant()The dictionary is deliberately a constructor parameter rather than private state: an SSTable shares one dictionary across every document it holds, so the usual ingest loop creates the dictionary once, then resets the builder per document.
Not thread-safe; the engine has a single writer.
Constructors
Properties
Functions
Appends value, re-expressed against this builder's dictionary.
Appends a date as days since 1970-01-01.
Appends value as the narrowest exact decimal type.
Appends value as a double, non-finite values included; JSON cannot read those back.
Appends value as the narrowest integer type that holds it.
Appends the Variant null primitive.
Appends a JSON number literal, choosing its physical type by the rule exact if possible, narrowest if exact:
Appends value, using the short-string form when its UTF-8 form is under 64 bytes.
Appends a time without time zone as microseconds since midnight.
Appends a timestamp in microseconds since the epoch.
Appends a timestamp in nanoseconds since the epoch. See appendTimestampMicros.
The encoded value together with a snapshot of the dictionary.
Closes the array opened by the matching startArray.
Closes the object opened by the matching startObject.
Discards the value under construction, keeping the dictionary for the next document.
Opens an array.
Opens an object. Every field must be followed by exactly one value.