Documentation
¶
Overview ¶
Package row2 reads and writes the Fast2 and Compact2 KVO row formats. A Field or View borrows at most one byte span. The external schema supplies signedness and field meanings. Select the codec at the table boundary: these bytes cannot be decoded as Fast1 word-map data.
Index ¶
- Constants
- Variables
- func PayloadSize(v values.Value) uint64
- type Editor
- type Encoding
- type Field
- type Iterator
- type KeyAccessOptions
- type Kind
- type Layout
- type Step
- type View
- func (v View) At(index int, enc Encoding) values.Value
- func (v View) Child(s Step) View
- func (v View) Get(key uint64, enc Encoding) values.Value
- func (v View) GetFast(key uint64) values.Value
- func (v View) GetString(key string, enc Encoding) values.Value
- func (v View) Has(key uint64) bool
- func (v View) HasString(key string) bool
- func (v View) Iter() Iterator
- func (v View) Kind() Kind
- func (v View) Layout() Layout
- func (v View) Len() int
- func (v View) Missing() bool
- func (v View) Raw() []byte
- func (v View) RawAt(i int) Field
- func (v View) RawField(key uint64) Field
- func (v View) RawString(key string) Field
- type Writer
- func (w *Writer) Begin(key uint64, text string, kind Kind, layout Layout)
- func (w *Writer) BytesWritten() []byte
- func (w *Writer) Count() int
- func (w *Writer) End()
- func (w *Writer) Finish(keepEmpty bool)
- func (w *Writer) Put(key uint64, text string, v values.Value, enc Encoding)
- func (w *Writer) PutPresent(key uint64, text string, v values.Value, enc Encoding)
- func (w *Writer) PutRaw(key uint64, text string, v Field)
- func (w *Writer) Release()
- func (w *Writer) ReserveEntries(n int)
- func (w *Writer) Reset(dst []byte)
Constants ¶
const MaxBytes = 64 << 20
const MaxEntries = 1 << 20
Variables ¶
var ( ErrFormat = errors.New("row2: invalid row") ErrLayout = errors.New("row2: invalid layout") ErrKind = errors.New("row2: wrong container kind") ErrType = errors.New("row2: incompatible value") ErrOrder = errors.New("row2: keys must be ordered and unique") ErrLimit = errors.New("row2: container exceeds limit") ErrValue = errors.New("row2: invalid input") ErrIndex = errors.New("row2: index out of bounds") )
Functions ¶
func PayloadSize ¶
PayloadSize bounds a scalar or immutable byte-span payload before encoding.
Types ¶
type Editor ¶
type Editor struct {
// contains filtered or unexported fields
}
Editor holds a borrowed row until the first write. Snapshot freezes the current bytes, including for backends which retain a Put until commit. Use one editor by pointer. Do not copy an editor after its first write.
func (*Editor) Get ¶
Get borrows from the current edit until the next Set. Snapshot the row before taking a view that must survive another write.
func (*Editor) Set ¶
Set replaces a leaf. A scalar with an existing Fast cell changes eight bytes in owned storage. Changes in shape or Compact width stream through the writer; siblings, including unknown fields, retain their raw payloads.
func (*Editor) SetWithWriter ¶
SetWithWriter reuses metadata scratch across edits. The caller can share w across editors used sequentially. Each rebuilt row owns its output bytes.
type Encoding ¶
type Encoding uint8
Encoding specifies how a typed runtime value maps to row2 payload bytes. Strings and immutable byte spans share Data; Float32 uses the historical float64 wire encoding, while runtime values retain float32 bits.
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
Field is raw codec metadata, not a runtime value. Payloads borrow the source container; inline words retain their full width when copied without a model. Decode requires the schema's encoding. Copying unknown fields uses PutRaw.
type KeyAccessOptions ¶
type KeyAccessOptions uint8
KeyAccessOptions controls property access independently of the field ID.
const ( // Compact selects compact storage when creating a child. Compact KeyAccessOptions = 1 << iota // Present preserves explicit zero values and present, empty children. Present )
type Layout ¶
type Layout uint8
Layout selects the physical row2 container layout. The values match the low trailer bit: Compact2 is zero and Fast2 is one. They are not EDB's StorageFormat IDs, which also include other codecs.
type Step ¶
type Step struct {
Key uint64
Options KeyAccessOptions
}
Step names a schema property and its access options.
type View ¶
type View struct {
// contains filtered or unexported fields
}
View borrows one encoded container. Raw and child spans are read-only.
func Trusted ¶
Trusted borrows bytes produced by the codec or validated at ingestion. The bytes and any borrowed children must outlive the view.
func TryOpen ¶
TryOpen validates a single bounded container. Spans are opaque; for untrusted input, open a modeled child separately before trusting its contents.
func (View) Child ¶
Child returns a missing view for an absent field. A presence-significant field can represent a present, empty object using an explicit zero.
func (View) GetFast ¶
GetFast borrows a field from Fast2, whose words and spans already have the runtime layout. The caller must ensure Indexed() and handle Float32 fields through Get(key, Float32), since those retain float64 bits on disk.
func (View) HasString ¶
HasString distinguishes a missing dictionary entry from a present zero value.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer streams nested containers into one destination. Keys within an object or dictionary must arrive in strictly increasing order.
func AcquireWriter ¶
AcquireWriter returns a writer with reusable directory scratch. dst and the encoded bytes belong to the caller, including after Release.
func (*Writer) BytesWritten ¶
func (*Writer) PutPresent ¶
func (*Writer) PutRaw ¶
PutRaw preserves an unknown field's representation, including explicit zero.
func (*Writer) Release ¶
func (w *Writer) Release()
Release an acquired writer exactly once. It returns directory scratch to the pool. Discard unusually large workspaces so one wide or deeply nested row cannot pin them between writes.
func (*Writer) ReserveEntries ¶
ReserveEntries is optional capacity advice, not a count or framing promise. A source slice/model can supply it without sizing or encoding any child.