Documentation
¶
Overview ¶
Package batchrepr provides interfaces for reading and writing the binary batch representation. This batch representation is used in-memory while constructing a batch and on-disk within the write-ahead log.
Index ¶
Constants ¶
const (
// HeaderLen is the length of the batch header in bytes.
HeaderLen = 12
)
Variables ¶
var ErrInvalidBatch = base.MarkCorruptionError(errors.New("pebble: invalid batch"))
ErrInvalidBatch indicates that a batch is invalid or otherwise corrupted.
Functions ¶
func DecodeStr ¶
DecodeStr decodes a varint encoded string from data, returning the remainder of data and the decoded string. It returns ok=false if the varint is invalid.
TODO(jackson): This should be unexported once pebble package callers have been updated to use appropriate abstractions.
func ReadSeqNum ¶
ReadSeqNum reads the sequence number encoded within the batch. ReadSeqNum does not validate that the repr is valid. It's exported only for very performance sensitive code paths that should not necessarily read the rest of the header as well.
Types ¶
type Header ¶
type Header struct {
// SeqNum is the sequence number at which the batch is committed. A batch
// that has not yet committed will have a zero sequence number.
SeqNum base.SeqNum
// Count is the count of keys written to the batch.
Count uint32
}
Header describes the contents of a batch header.
func ReadHeader ¶
ReadHeader reads the contents of the batch header. If the repr is too small to contain a valid batch header, ReadHeader returns ok=false.
type Reader ¶
type Reader []byte
Reader iterates over the entries contained in a batch.
func Read ¶
Read constructs a Reader from an encoded batch representation, ignoring the contents of the Header.