Documentation ¶
Index ¶
- func DecodeCompactUint32(reader io.Reader) (uint32, error)
- func DecodeCompactUint64(reader io.Reader) (uint64, error)
- func EncodeCompactUint32(x uint32) []byte
- func EncodeCompactUint64(x uint64) []byte
- type BoolCodec
- func (b BoolCodec) Compare(v1, v2 protoreflect.Value) int
- func (b BoolCodec) ComputeBufferSize(protoreflect.Value) (int, error)
- func (b BoolCodec) Decode(r Reader) (protoreflect.Value, error)
- func (b BoolCodec) Encode(value protoreflect.Value, w io.Writer) error
- func (b BoolCodec) FixedBufferSize() int
- func (b BoolCodec) IsOrdered() bool
- type BytesCodec
- func (b BytesCodec) Compare(v1, v2 protoreflect.Value) int
- func (b BytesCodec) ComputeBufferSize(value protoreflect.Value) (int, error)
- func (b BytesCodec) Decode(r Reader) (protoreflect.Value, error)
- func (b BytesCodec) Encode(value protoreflect.Value, w io.Writer) error
- func (b BytesCodec) FixedBufferSize() int
- func (b BytesCodec) IsOrdered() bool
- type Codec
- type CompactUint32Codec
- func (c CompactUint32Codec) Compare(v1, v2 protoreflect.Value) int
- func (c CompactUint32Codec) ComputeBufferSize(protoreflect.Value) (int, error)
- func (c CompactUint32Codec) Decode(r Reader) (protoreflect.Value, error)
- func (c CompactUint32Codec) Encode(value protoreflect.Value, w io.Writer) error
- func (c CompactUint32Codec) FixedBufferSize() int
- func (c CompactUint32Codec) IsOrdered() bool
- type CompactUint64Codec
- func (c CompactUint64Codec) Compare(v1, v2 protoreflect.Value) int
- func (c CompactUint64Codec) ComputeBufferSize(protoreflect.Value) (int, error)
- func (c CompactUint64Codec) Decode(r Reader) (protoreflect.Value, error)
- func (c CompactUint64Codec) Encode(value protoreflect.Value, w io.Writer) error
- func (c CompactUint64Codec) FixedBufferSize() int
- func (c CompactUint64Codec) IsOrdered() bool
- type DurationCodec
- func (d DurationCodec) Compare(v1, v2 protoreflect.Value) int
- func (d DurationCodec) ComputeBufferSize(protoreflect.Value) (int, error)
- func (d DurationCodec) Decode(r Reader) (protoreflect.Value, error)
- func (d DurationCodec) Encode(value protoreflect.Value, w io.Writer) error
- func (d DurationCodec) FixedBufferSize() int
- func (d DurationCodec) IsOrdered() bool
- type EnumCodec
- func (e EnumCodec) Compare(v1, v2 protoreflect.Value) int
- func (e EnumCodec) ComputeBufferSize(protoreflect.Value) (int, error)
- func (e EnumCodec) Decode(r Reader) (protoreflect.Value, error)
- func (e EnumCodec) Encode(value protoreflect.Value, w io.Writer) error
- func (e EnumCodec) FixedBufferSize() int
- func (e EnumCodec) IsOrdered() bool
- type FixedUint32Codec
- func (u FixedUint32Codec) Compare(v1, v2 protoreflect.Value) int
- func (u FixedUint32Codec) ComputeBufferSize(protoreflect.Value) (int, error)
- func (u FixedUint32Codec) Decode(r Reader) (protoreflect.Value, error)
- func (u FixedUint32Codec) Encode(value protoreflect.Value, w io.Writer) error
- func (u FixedUint32Codec) FixedBufferSize() int
- func (u FixedUint32Codec) IsOrdered() bool
- type FixedUint64Codec
- func (u FixedUint64Codec) Compare(v1, v2 protoreflect.Value) int
- func (u FixedUint64Codec) ComputeBufferSize(protoreflect.Value) (int, error)
- func (u FixedUint64Codec) Decode(r Reader) (protoreflect.Value, error)
- func (u FixedUint64Codec) Encode(value protoreflect.Value, w io.Writer) error
- func (u FixedUint64Codec) FixedBufferSize() int
- func (u FixedUint64Codec) IsOrdered() bool
- type Int32Codec
- func (i Int32Codec) Compare(v1, v2 protoreflect.Value) int
- func (i Int32Codec) ComputeBufferSize(protoreflect.Value) (int, error)
- func (i Int32Codec) Decode(r Reader) (protoreflect.Value, error)
- func (i Int32Codec) Encode(value protoreflect.Value, w io.Writer) error
- func (i Int32Codec) FixedBufferSize() int
- func (i Int32Codec) IsOrdered() bool
- type Int64Codec
- func (i Int64Codec) Compare(v1, v2 protoreflect.Value) int
- func (i Int64Codec) ComputeBufferSize(protoreflect.Value) (int, error)
- func (i Int64Codec) Decode(r Reader) (protoreflect.Value, error)
- func (i Int64Codec) Encode(value protoreflect.Value, w io.Writer) error
- func (i Int64Codec) FixedBufferSize() int
- func (i Int64Codec) IsOrdered() bool
- type NonTerminalBytesCodec
- func (b NonTerminalBytesCodec) Compare(v1, v2 protoreflect.Value) int
- func (b NonTerminalBytesCodec) ComputeBufferSize(value protoreflect.Value) (int, error)
- func (b NonTerminalBytesCodec) Decode(r Reader) (protoreflect.Value, error)
- func (b NonTerminalBytesCodec) Encode(value protoreflect.Value, w io.Writer) error
- func (b NonTerminalBytesCodec) FixedBufferSize() int
- func (b NonTerminalBytesCodec) IsOrdered() bool
- type NonTerminalStringCodec
- func (s NonTerminalStringCodec) Compare(v1, v2 protoreflect.Value) int
- func (s NonTerminalStringCodec) ComputeBufferSize(value protoreflect.Value) (int, error)
- func (s NonTerminalStringCodec) Decode(r Reader) (protoreflect.Value, error)
- func (s NonTerminalStringCodec) Encode(value protoreflect.Value, w io.Writer) error
- func (s NonTerminalStringCodec) FixedBufferSize() int
- func (s NonTerminalStringCodec) IsOrdered() bool
- type Reader
- type StringCodec
- func (s StringCodec) Compare(v1, v2 protoreflect.Value) int
- func (s StringCodec) ComputeBufferSize(value protoreflect.Value) (int, error)
- func (s StringCodec) Decode(r Reader) (protoreflect.Value, error)
- func (s StringCodec) Encode(value protoreflect.Value, w io.Writer) error
- func (s StringCodec) FixedBufferSize() int
- func (s StringCodec) IsOrdered() bool
- type TimestampCodec
- func (t TimestampCodec) Compare(v1, v2 protoreflect.Value) int
- func (t TimestampCodec) ComputeBufferSize(protoreflect.Value) (int, error)
- func (t TimestampCodec) Decode(r Reader) (protoreflect.Value, error)
- func (t TimestampCodec) Encode(value protoreflect.Value, w io.Writer) error
- func (t TimestampCodec) FixedBufferSize() int
- func (t TimestampCodec) IsOrdered() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeCompactUint32 ¶
DecodeCompactUint32 decodes a uint32 encoded with EncodeCompactU32.
func EncodeCompactUint32 ¶
EncodeCompactUint32 encodes uint32 values in 2,3,4 or 5 bytes. Unlike regular varints, this encoding is suitable for ordered prefix scans. The length of the output + 2 is encoded in the first 2 bits of the first byte and the remaining bits encoded with big-endian ordering. Values less than 2^14 fill fit in 2 bytes, values less than 2^22 will fit in 3, and values less than 2^30 will fit in 4.
func EncodeCompactUint64 ¶
EncodeCompactUint64 encodes uint64 values in 2,4,6 or 9 bytes. Unlike regular varints, this encoding is suitable for ordered prefix scans. The first two bits of the first byte indicate the length of the buffer - 00 for 2, 01 for 4, 10 for 6 and 11 for 9. The remaining bits are encoded with big-endian ordering. Values less than 2^14 fill fit in 2 bytes, values less than 2^30 will fit in 4, and values less than 2^46 will fit in 6.
Types ¶
type BoolCodec ¶
type BoolCodec struct{}
BoolCodec encodes a bool value as a single byte 0 or 1.
func (BoolCodec) ComputeBufferSize ¶
func (b BoolCodec) ComputeBufferSize(protoreflect.Value) (int, error)
func (BoolCodec) FixedBufferSize ¶
type BytesCodec ¶
type BytesCodec struct{}
BytesCodec encodes bytes as raw bytes. It errors if the byte array is longer than 255 bytes.
func (BytesCodec) Compare ¶
func (b BytesCodec) Compare(v1, v2 protoreflect.Value) int
func (BytesCodec) ComputeBufferSize ¶
func (b BytesCodec) ComputeBufferSize(value protoreflect.Value) (int, error)
ComputeBufferSize returns the bytes size of the value.
func (BytesCodec) Decode ¶
func (b BytesCodec) Decode(r Reader) (protoreflect.Value, error)
func (BytesCodec) Encode ¶
func (b BytesCodec) Encode(value protoreflect.Value, w io.Writer) error
func (BytesCodec) FixedBufferSize ¶
func (b BytesCodec) FixedBufferSize() int
func (BytesCodec) IsOrdered ¶
func (b BytesCodec) IsOrdered() bool
type Codec ¶
type Codec interface { // Decode decodes a value in a key. Decode(r Reader) (protoreflect.Value, error) // Encode encodes a value in a key. Encode(value protoreflect.Value, w io.Writer) error // Compare compares two values of this type and should primarily be used // for testing. Compare(v1, v2 protoreflect.Value) int // IsOrdered returns true if callers can always assume that this ordering // is suitable for sorted iteration. IsOrdered() bool // FixedBufferSize returns a positive value if encoders should assume a // fixed size buffer for encoding. Encoders will use at most this much size // to encode the value. FixedBufferSize() int // ComputeBufferSize estimates the buffer size needed to encode the field. // Encoders will use at most this much size to encode the value. ComputeBufferSize(value protoreflect.Value) (int, error) }
Codec defines an interface for decoding and encoding values in ORM index keys.
func GetCodec ¶
func GetCodec(field protoreflect.FieldDescriptor, nonTerminal bool) (Codec, error)
GetCodec returns the Codec for the provided field if one is defined. nonTerminal should be set to true if this value is being encoded as a non-terminal segment of a multi-part key.
type CompactUint32Codec ¶
type CompactUint32Codec struct{}
CompactUint32Codec encodes uint32 values using EncodeCompactUint32.
func (CompactUint32Codec) Compare ¶
func (c CompactUint32Codec) Compare(v1, v2 protoreflect.Value) int
func (CompactUint32Codec) ComputeBufferSize ¶
func (c CompactUint32Codec) ComputeBufferSize(protoreflect.Value) (int, error)
func (CompactUint32Codec) Decode ¶
func (c CompactUint32Codec) Decode(r Reader) (protoreflect.Value, error)
func (CompactUint32Codec) Encode ¶
func (c CompactUint32Codec) Encode(value protoreflect.Value, w io.Writer) error
func (CompactUint32Codec) FixedBufferSize ¶
func (c CompactUint32Codec) FixedBufferSize() int
func (CompactUint32Codec) IsOrdered ¶
func (c CompactUint32Codec) IsOrdered() bool
type CompactUint64Codec ¶
type CompactUint64Codec struct{}
CompactUint64Codec encodes uint64 values using EncodeCompactUint64.
func (CompactUint64Codec) Compare ¶
func (c CompactUint64Codec) Compare(v1, v2 protoreflect.Value) int
func (CompactUint64Codec) ComputeBufferSize ¶
func (c CompactUint64Codec) ComputeBufferSize(protoreflect.Value) (int, error)
func (CompactUint64Codec) Decode ¶
func (c CompactUint64Codec) Decode(r Reader) (protoreflect.Value, error)
func (CompactUint64Codec) Encode ¶
func (c CompactUint64Codec) Encode(value protoreflect.Value, w io.Writer) error
func (CompactUint64Codec) FixedBufferSize ¶
func (c CompactUint64Codec) FixedBufferSize() int
func (CompactUint64Codec) IsOrdered ¶
func (c CompactUint64Codec) IsOrdered() bool
type DurationCodec ¶
type DurationCodec struct{}
DurationCodec encodes a google.protobuf.Duration value as 12 bytes using Int64Codec for seconds followed by Int32Codec for nanos. This allows for sorted iteration.
func (DurationCodec) Compare ¶
func (d DurationCodec) Compare(v1, v2 protoreflect.Value) int
func (DurationCodec) ComputeBufferSize ¶
func (d DurationCodec) ComputeBufferSize(protoreflect.Value) (int, error)
func (DurationCodec) Decode ¶
func (d DurationCodec) Decode(r Reader) (protoreflect.Value, error)
func (DurationCodec) Encode ¶
func (d DurationCodec) Encode(value protoreflect.Value, w io.Writer) error
func (DurationCodec) FixedBufferSize ¶
func (d DurationCodec) FixedBufferSize() int
func (DurationCodec) IsOrdered ¶
func (d DurationCodec) IsOrdered() bool
type EnumCodec ¶
type EnumCodec struct{}
EnumCodec encodes enum values as varints.
func (EnumCodec) ComputeBufferSize ¶
func (e EnumCodec) ComputeBufferSize(protoreflect.Value) (int, error)
func (EnumCodec) FixedBufferSize ¶
type FixedUint32Codec ¶
type FixedUint32Codec struct{}
FixedUint32Codec encodes uint32 values as 4-byte big-endian integers.
func (FixedUint32Codec) Compare ¶
func (u FixedUint32Codec) Compare(v1, v2 protoreflect.Value) int
func (FixedUint32Codec) ComputeBufferSize ¶
func (u FixedUint32Codec) ComputeBufferSize(protoreflect.Value) (int, error)
func (FixedUint32Codec) Decode ¶
func (u FixedUint32Codec) Decode(r Reader) (protoreflect.Value, error)
func (FixedUint32Codec) Encode ¶
func (u FixedUint32Codec) Encode(value protoreflect.Value, w io.Writer) error
func (FixedUint32Codec) FixedBufferSize ¶
func (u FixedUint32Codec) FixedBufferSize() int
func (FixedUint32Codec) IsOrdered ¶
func (u FixedUint32Codec) IsOrdered() bool
type FixedUint64Codec ¶
type FixedUint64Codec struct{}
FixedUint64Codec encodes uint64 values as 8-byte big-endian integers.
func (FixedUint64Codec) Compare ¶
func (u FixedUint64Codec) Compare(v1, v2 protoreflect.Value) int
func (FixedUint64Codec) ComputeBufferSize ¶
func (u FixedUint64Codec) ComputeBufferSize(protoreflect.Value) (int, error)
func (FixedUint64Codec) Decode ¶
func (u FixedUint64Codec) Decode(r Reader) (protoreflect.Value, error)
func (FixedUint64Codec) Encode ¶
func (u FixedUint64Codec) Encode(value protoreflect.Value, w io.Writer) error
func (FixedUint64Codec) FixedBufferSize ¶
func (u FixedUint64Codec) FixedBufferSize() int
func (FixedUint64Codec) IsOrdered ¶
func (u FixedUint64Codec) IsOrdered() bool
type Int32Codec ¶
type Int32Codec struct{}
Int32Codec encodes 32-bit integers as big-endian unsigned 32-bit integers by adding the maximum value of int32 (2147583647) + 1 before encoding so that these values can be used for ordered iteration.
func (Int32Codec) Compare ¶
func (i Int32Codec) Compare(v1, v2 protoreflect.Value) int
func (Int32Codec) ComputeBufferSize ¶
func (i Int32Codec) ComputeBufferSize(protoreflect.Value) (int, error)
func (Int32Codec) Decode ¶
func (i Int32Codec) Decode(r Reader) (protoreflect.Value, error)
func (Int32Codec) Encode ¶
func (i Int32Codec) Encode(value protoreflect.Value, w io.Writer) error
func (Int32Codec) FixedBufferSize ¶
func (i Int32Codec) FixedBufferSize() int
func (Int32Codec) IsOrdered ¶
func (i Int32Codec) IsOrdered() bool
type Int64Codec ¶
type Int64Codec struct{}
Int64Codec encodes 64-bit integers as big-endian unsigned 64-bit integers by adding the maximum value of int32 (9223372036854775807) + 1 before encoding so that these values can be used for ordered iteration.
func (Int64Codec) Compare ¶
func (i Int64Codec) Compare(v1, v2 protoreflect.Value) int
func (Int64Codec) ComputeBufferSize ¶
func (i Int64Codec) ComputeBufferSize(protoreflect.Value) (int, error)
func (Int64Codec) Decode ¶
func (i Int64Codec) Decode(r Reader) (protoreflect.Value, error)
func (Int64Codec) Encode ¶
func (i Int64Codec) Encode(value protoreflect.Value, w io.Writer) error
func (Int64Codec) FixedBufferSize ¶
func (i Int64Codec) FixedBufferSize() int
func (Int64Codec) IsOrdered ¶
func (i Int64Codec) IsOrdered() bool
type NonTerminalBytesCodec ¶
type NonTerminalBytesCodec struct{}
NonTerminalBytesCodec encodes bytes as raw bytes length prefixed by a single byte. It errors if the byte array is longer than 255 bytes.
func (NonTerminalBytesCodec) Compare ¶
func (b NonTerminalBytesCodec) Compare(v1, v2 protoreflect.Value) int
func (NonTerminalBytesCodec) ComputeBufferSize ¶
func (b NonTerminalBytesCodec) ComputeBufferSize(value protoreflect.Value) (int, error)
ComputeBufferSize returns the bytes size of the value plus the length of the varint length-prefix.
func (NonTerminalBytesCodec) Decode ¶
func (b NonTerminalBytesCodec) Decode(r Reader) (protoreflect.Value, error)
func (NonTerminalBytesCodec) Encode ¶
func (b NonTerminalBytesCodec) Encode(value protoreflect.Value, w io.Writer) error
func (NonTerminalBytesCodec) FixedBufferSize ¶
func (b NonTerminalBytesCodec) FixedBufferSize() int
func (NonTerminalBytesCodec) IsOrdered ¶
func (b NonTerminalBytesCodec) IsOrdered() bool
type NonTerminalStringCodec ¶
type NonTerminalStringCodec struct{}
NonTerminalStringCodec encodes strings as null-terminated raw bytes. Null values within strings will produce an error.
func (NonTerminalStringCodec) Compare ¶
func (s NonTerminalStringCodec) Compare(v1, v2 protoreflect.Value) int
func (NonTerminalStringCodec) ComputeBufferSize ¶
func (s NonTerminalStringCodec) ComputeBufferSize(value protoreflect.Value) (int, error)
func (NonTerminalStringCodec) Decode ¶
func (s NonTerminalStringCodec) Decode(r Reader) (protoreflect.Value, error)
func (NonTerminalStringCodec) Encode ¶
func (s NonTerminalStringCodec) Encode(value protoreflect.Value, w io.Writer) error
func (NonTerminalStringCodec) FixedBufferSize ¶
func (s NonTerminalStringCodec) FixedBufferSize() int
func (NonTerminalStringCodec) IsOrdered ¶
func (s NonTerminalStringCodec) IsOrdered() bool
type StringCodec ¶
type StringCodec struct{}
StringCodec encodes strings as raw bytes.
func (StringCodec) Compare ¶
func (s StringCodec) Compare(v1, v2 protoreflect.Value) int
func (StringCodec) ComputeBufferSize ¶
func (s StringCodec) ComputeBufferSize(value protoreflect.Value) (int, error)
func (StringCodec) Decode ¶
func (s StringCodec) Decode(r Reader) (protoreflect.Value, error)
func (StringCodec) Encode ¶
func (s StringCodec) Encode(value protoreflect.Value, w io.Writer) error
func (StringCodec) FixedBufferSize ¶
func (s StringCodec) FixedBufferSize() int
func (StringCodec) IsOrdered ¶
func (s StringCodec) IsOrdered() bool
type TimestampCodec ¶
type TimestampCodec struct{}
TimestampCodec DurationCodec encodes a google.protobuf.Timestamp value as 12 bytes using Int64Codec for seconds followed by Int32Codec for nanos. This allows for sorted iteration.
func (TimestampCodec) Compare ¶
func (t TimestampCodec) Compare(v1, v2 protoreflect.Value) int
func (TimestampCodec) ComputeBufferSize ¶
func (t TimestampCodec) ComputeBufferSize(protoreflect.Value) (int, error)
func (TimestampCodec) Decode ¶
func (t TimestampCodec) Decode(r Reader) (protoreflect.Value, error)
func (TimestampCodec) Encode ¶
func (t TimestampCodec) Encode(value protoreflect.Value, w io.Writer) error
func (TimestampCodec) FixedBufferSize ¶
func (t TimestampCodec) FixedBufferSize() int
func (TimestampCodec) IsOrdered ¶
func (t TimestampCodec) IsOrdered() bool