Documentation
¶
Index ¶
Constants ¶
const ( XMetaValue0 xMetaValue = iota XMetaValue1 XMetaValue2 XMetaValue3 XMetaValue4 XMetaValue5 XMetaValue6 XMetaValue7 XMetaValue8 XMetaValue9 XMetaValueA XMetaValueB XMetaValueC XMetaValueD XMetaValueE XMetaValueF )
Extended metadata values XMetaValue[0, F] can be assigned arbitrary meaning attached to records transmitted and received by Encoder.EncodeX and Decoder.DecodeX.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Inspired by encoding/gob.Decoder from the Go standard library, a Decoder specialises in the receipt of LMDB key-value records transmitted by an Encoder counterpart. It is safe for concurrent use by multiple goroutines.
func NewDecoder ¶
NewDecoder returns a new Decoder that will receive from the io.Reader, and optionally verify the checksum of every record if the hash.Hash32 is not nil.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
An Encoder is modelled after encoding/gob.Encoder from the Go standard library, but specialises in the transmission of LMDB key-value records.
An LMDB record, consisting of a key no more than 511 bytes long, and a value of maximum size 4 GiB, is encoded as follows:
- 2 bytes to represent the key length k in number of bytes,
- 1 <= x <= 4 bytes to represent the value length v in number of bytes,
- k bytes to hold the uninterpreted key,
- v bytes to hold the uninterpreted value, and
- 4 bytes to hold an optional 32-bit checksum of the record.
This incurs an overhead of 3 to 10 bytes per record, and leaves the first seven bits free to carry the following metadata:
- 2 bits to encode the value of x (from the second bullet point above),
- 1 bit to indicate the presence of a trailing 32-bit checksum, and
- 4 bits for extended metadata---see defined constants.
Encoders are safe for concurrent use by multiple goroutines.
func NewEncoder ¶
NewEncoder returns a new encoder that will transmit on the io.Writer, and optionally append a 32-bit checksum to every record if the hash.Hash32 is not nil.