Documentation
¶
Overview ¶
binary_codec.go provides a custom binary encoding/decoding for Row data (map[string]any) optimized for memory efficiency and performance.
Binary Format:
Map: [uint32: num_pairs] + pairs Pair: [uint32: key_len][key_bytes][type_byte][value_data]
Type bytes:
0 = nil 1 = bool (1 byte: 0=false, 1=true) 2 = int64 (8 bytes, little endian) 3 = float64 (8 bytes, little endian) 4 = string ([uint32: len][bytes]) 5 = []byte ([uint32: len][bytes]) 6 = int32 (4 bytes, little endian) - promoted to int64 7 = float32 (4 bytes, little endian) - promoted to float64
This format avoids reflection entirely for maximum memory efficiency.
cbor_codec.go provides CBOR encoding/decoding for Row data.
Package rowcodec provides encoding/decoding interfaces for Row data (map[string]any) with multiple implementation options.
gob_codec.go provides GOB encoding/decoding for Row data.
Index ¶
- type BinaryCodec
- func (c *BinaryCodec) Decode(data []byte, into map[string]any) error
- func (c *BinaryCodec) DecodeRow(data []byte, into pipeline.Row) error
- func (c *BinaryCodec) Encode(row map[string]any) ([]byte, error)
- func (c *BinaryCodec) EncodeRow(row pipeline.Row) ([]byte, error)
- func (c *BinaryCodec) NewDecoder(r io.Reader) Decoder
- func (c *BinaryCodec) NewEncoder(w io.Writer) Encoder
- type BinaryDecoder
- type BinaryEncoder
- type CBORCodec
- func (c *CBORCodec) Decode(data []byte, into map[string]any) error
- func (c *CBORCodec) DecodeRow(data []byte, into pipeline.Row) error
- func (c *CBORCodec) Encode(row map[string]any) ([]byte, error)
- func (c *CBORCodec) EncodeRow(row pipeline.Row) ([]byte, error)
- func (c *CBORCodec) NewDecoder(r io.Reader) Decoder
- func (c *CBORCodec) NewEncoder(w io.Writer) Encoder
- type CBORDecoder
- type CBOREncoder
- type Codec
- type Decoder
- type Encoder
- type GOBCodec
- func (c *GOBCodec) Decode(data []byte, into map[string]any) error
- func (c *GOBCodec) DecodeRow(data []byte, into pipeline.Row) error
- func (c *GOBCodec) Encode(row map[string]any) ([]byte, error)
- func (c *GOBCodec) EncodeRow(row pipeline.Row) ([]byte, error)
- func (c *GOBCodec) NewDecoder(r io.Reader) Decoder
- func (c *GOBCodec) NewEncoder(w io.Writer) Encoder
- type GOBDecoder
- type GOBEncoder
- type RowDecoder
- type RowEncoder
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinaryCodec ¶
type BinaryCodec struct{}
BinaryCodec holds the binary encoder/decoder.
func NewBinaryCodec ¶
func NewBinaryCodec() (*BinaryCodec, error)
NewBinaryCodec creates a new binary codec.
func (*BinaryCodec) Decode ¶
func (c *BinaryCodec) Decode(data []byte, into map[string]any) error
Decode decodes binary bytes into the supplied map[string]any. The supplied map is cleared before decoding.
func (*BinaryCodec) DecodeRow ¶
func (c *BinaryCodec) DecodeRow(data []byte, into pipeline.Row) error
DecodeRow decodes binary bytes into the supplied Row (map[wkk.RowKey]any). The supplied Row is cleared before decoding.
func (*BinaryCodec) Encode ¶
func (c *BinaryCodec) Encode(row map[string]any) ([]byte, error)
Encode encodes a map[string]any to binary bytes.
func (*BinaryCodec) EncodeRow ¶
func (c *BinaryCodec) EncodeRow(row pipeline.Row) ([]byte, error)
EncodeRow encodes a Row (map[wkk.RowKey]any) to binary bytes.
func (*BinaryCodec) NewDecoder ¶
func (c *BinaryCodec) NewDecoder(r io.Reader) Decoder
NewDecoder creates a new binary decoder.
func (*BinaryCodec) NewEncoder ¶
func (c *BinaryCodec) NewEncoder(w io.Writer) Encoder
NewEncoder creates a new binary encoder.
type BinaryDecoder ¶
type BinaryDecoder struct {
// contains filtered or unexported fields
}
BinaryDecoder reads binary-encoded map data from an io.Reader.
func (*BinaryDecoder) Decode ¶
func (d *BinaryDecoder) Decode(into map[string]any) error
Decode reads a map[string]any from binary format.
func (*BinaryDecoder) DecodeInto ¶
func (d *BinaryDecoder) DecodeInto(target map[string]any) error
DecodeInto reads binary data into the provided map, which should be empty or will be cleared.
type BinaryEncoder ¶
type BinaryEncoder struct {
// contains filtered or unexported fields
}
BinaryEncoder writes binary-encoded map data to an io.Writer.
type CBORCodec ¶
type CBORCodec struct {
// contains filtered or unexported fields
}
CBORCodec holds the CBOR encoder/decoder configuration.
func (*CBORCodec) Decode ¶
Decode decodes CBOR bytes into the supplied map[string]any. The supplied map is cleared before decoding.
func (*CBORCodec) DecodeRow ¶
DecodeRow decodes CBOR bytes into the supplied Row (map[wkk.RowKey]any). The supplied Row is cleared before decoding.
func (*CBORCodec) NewDecoder ¶
NewDecoder creates a new CBOR decoder.
type CBORDecoder ¶
type CBORDecoder struct {
// contains filtered or unexported fields
}
CBORDecoder reads CBOR-encoded map data from an io.Reader.
type CBOREncoder ¶
type CBOREncoder struct {
// contains filtered or unexported fields
}
CBOREncoder writes CBOR-encoded map data to an io.Writer.
type Codec ¶
type Codec interface { // Encode encodes a map[string]any to bytes. Encode(row map[string]any) ([]byte, error) // Decode decodes bytes into the supplied map[string]any. // The supplied map is cleared before decoding. Decode(data []byte, into map[string]any) error // EncodeRow encodes a Row (map[wkk.RowKey]any) to bytes. EncodeRow(row pipeline.Row) ([]byte, error) // DecodeRow decodes bytes into the supplied Row (map[wkk.RowKey]any). // The supplied Row is cleared before decoding. DecodeRow(data []byte, into pipeline.Row) error // NewEncoder creates a new encoder that writes to the given writer. NewEncoder(w io.Writer) Encoder // NewDecoder creates a new decoder that reads from the given reader. NewDecoder(r io.Reader) Decoder }
Codec defines the interface for encoding/decoding row data.
type Decoder ¶
type Decoder interface { // Decode reads into the supplied map[string]any from the codec's format. // The supplied map is cleared before decoding. // Returns io.EOF when no more data is available. Decode(into map[string]any) error }
Decoder defines the interface for streaming decoding.
type Encoder ¶
type Encoder interface { // Encode writes a map[string]any in the codec's format. Encode(row map[string]any) error }
Encoder defines the interface for streaming encoding.
type GOBCodec ¶
type GOBCodec struct{}
GOBCodec holds the GOB encoder/decoder.
func (*GOBCodec) Decode ¶
Decode decodes GOB bytes into the supplied map[string]any. The supplied map is cleared before decoding.
func (*GOBCodec) DecodeRow ¶
DecodeRow decodes GOB bytes into the supplied Row (map[wkk.RowKey]any). The supplied Row is cleared before decoding.
func (*GOBCodec) NewDecoder ¶
NewDecoder creates a new GOB decoder.
type GOBDecoder ¶
type GOBDecoder struct {
// contains filtered or unexported fields
}
GOBDecoder reads GOB-encoded map data from an io.Reader.
type GOBEncoder ¶
type GOBEncoder struct {
// contains filtered or unexported fields
}
GOBEncoder writes GOB-encoded map data to an io.Writer.
type RowDecoder ¶
type RowDecoder struct {
// contains filtered or unexported fields
}
RowDecoder reads binary-encoded Row data from an io.Reader, preserving RowKey handles.
func NewRowDecoder ¶
func NewRowDecoder(r io.Reader) *RowDecoder
NewRowDecoder creates a new Row decoder that preserves RowKey handles.
type RowEncoder ¶
type RowEncoder struct {
// contains filtered or unexported fields
}
RowEncoder writes binary-encoded Row data to an io.Writer, preserving RowKey handles.
func NewRowEncoder ¶
func NewRowEncoder(w io.Writer) *RowEncoder
NewRowEncoder creates a new Row encoder that preserves RowKey handles.