Variant
A view over one encoded Variant value.
Nothing is decoded on construction and nothing is copied: a Variant is a metadata reference, a MemorySegment and an offset into it. Navigating into a field or an element produces another view over the same bytes, which is what makes reading a single path out of a large document cost the path, not the document.
The segment may be a heap array during ingest or a mapped file region once segments are on disk; the reader does not care which, and that is the point — the same code reads a memtable entry and a page of an SSTable.
A view is immutable and cheap to create. It is safe to share between threads as long as the underlying segment is not being written, which for an immutable segment is always.
Every accessor validates before it reads. Bytes that do not decode raise VariantFormatException — the engine never fabricates a default for data it cannot read.
Properties
The two-bit basic type opening this value.
Number of top-level children: fields for an object, elements for an array, 0 for a scalar.
Number of elements. @throws VariantTypeException unless this value is an array.
Number of fields. @throws VariantTypeException unless this value is an object.
What this value means, independent of the width it was stored in.
Dictionary resolving this value's field ids. Usually shared by a whole segment.
The exact on-disk primitive type, or null when this value is not a primitive — a short string, an object or an array.
Functions
Appends toJsonSummaryString to out, avoiding an intermediate String.
Appends Variant.toJsonString to out, avoiding an intermediate String.
The value of a float or double, widened to Double.
Value of the field at index.
Follows path from this value, or returns null if any step does not exist.
Follows a path expression such as $.items[0].name. See VariantPath.parse.
The text of a short string or a long string.
The raw counter behind a time or timestamp: microseconds for VariantPrimitiveType.TIME_NTZ, VariantPrimitiveType.TIMESTAMP_TZ and VariantPrimitiveType.TIMESTAMP_NTZ, nanoseconds for the two NANOS types.
Copies this value's bytes out of the segment. Pair with VariantMetadata.toByteArray.
Renders this value as JSON text.
The first limit top-level children, with everything below them elided.
One line describing this value's shape and size, whatever it holds and however large it is.