DocSink class final

A bump-allocated buffer that holds many consecutive VXS documents.

This is the batch writing path: one large buffer, no per-document allocation, no zeroing between documents. Callers get back the offset of each document and can hand the whole buffer to a block writer or an I/O sink.

A document written through a sink must fit the 16-bit body length; larger blobs should use DocBuilder. The sink is not thread safe and reset invalidates every view previously handed out.

Constructors

DocSink({int capacity = 64 * 1024, bool collectOffsets = false})
Creates a sink with an initial capacity in bytes.

Properties

buffer → Uint8List
The backing buffer. Grows by copying; re-read it after every write.
no setter
collectOffsets → bool
Whether offsets records the start offset of every finished document.
final
docCount → int
Number of documents finished since the last reset.
no setter
hashCode → int
The hash code for this object.
no setterinherited
isOpen → bool
Whether a document is currently being written.
no setter
length → int
Bytes written so far.
no setter
offsets → List<int>
Start offsets of finished documents, in order. Empty unless collectOffsets is true.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

beginDoc({int schemaId = 0, int schemaVersion = 1}) → int
Starts a document and returns its start offset.
endDoc({bool checksum = false}) → int
Patches the header of the open document and returns its start offset.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
putBool(int fieldId, bool value) → void
Writes a boolean field.
putBytes(int fieldId, List<int> value) → void
Writes an opaque bytes field.
putDoc(int fieldId, Bytes doc) → void
Writes an already encoded document (including its header) as a nested doc.
putFloat32(int fieldId, double value) → void
Writes a float32 field.
putFloat64(int fieldId, double value) → void
Writes a float64 field.
putInt(int fieldId, int value) → void
Writes a signed integer field using zigzag varints.
putIntList(int fieldId, List<int> values) → void
Writes a List<int> field.
putRawEntry(int fieldId, int wireType, Uint8List source, int start, int end) → void
Copies an encoded value verbatim, for forward-compatibility round trips.
putString(int fieldId, String value) → void
Writes a UTF-8 string field.
putStringList(int fieldId, List<String> values) → void
Writes a List<String> field.
putUnsigned(int fieldId, int value) → void
Writes an unsigned varint field without zigzag.
reset() → void
Discards the contents and reuses the buffer from the start.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

encodeUtf8(String value, Uint8List out, int offset) → int
Writes the UTF-8 form of value into out starting at offset and returns the number of bytes written.