msgpack

package
v0.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2018 License: Apache-2.0 Imports: 7 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DecodeLogEntryRemainingToken

type DecodeLogEntryRemainingToken struct {
	// contains filtered or unexported fields
}

DecodeLogEntryRemainingToken contains all the information that DecodeLogEntryRemaining requires to continue decoding a log entry after a call to DecodeLogEntryUniqueIndex.

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder decodes persisted msgpack-encoded data

func NewDecoder

func NewDecoder(opts DecodingOptions) *Decoder

NewDecoder creates a new decoder

func (*Decoder) DecodeIndexEntry

func (dec *Decoder) DecodeIndexEntry() (schema.IndexEntry, error)

DecodeIndexEntry decodes index entry

func (*Decoder) DecodeIndexInfo

func (dec *Decoder) DecodeIndexInfo() (schema.IndexInfo, error)

DecodeIndexInfo decodes the index info

func (*Decoder) DecodeIndexSummary

func (dec *Decoder) DecodeIndexSummary() (
	schema.IndexSummary, IndexSummaryToken, error)

DecodeIndexSummary decodes index summary

func (*Decoder) DecodeLogEntry

func (dec *Decoder) DecodeLogEntry() (schema.LogEntry, error)

DecodeLogEntry decodes commit log entry

func (*Decoder) DecodeLogEntryRemaining

func (dec *Decoder) DecodeLogEntryRemaining(token DecodeLogEntryRemainingToken, index uint64) (schema.LogEntry, error)

DecodeLogEntryRemaining can only be called after DecodeLogEntryUniqueIndex, and it returns a complete schema.LogEntry.

func (*Decoder) DecodeLogEntryUniqueIndex

func (dec *Decoder) DecodeLogEntryUniqueIndex() (DecodeLogEntryRemainingToken, uint64, error)

DecodeLogEntryUniqueIndex decodes a log entry as much as is required to return the series unique index. Call DecodeLogEntryRemaining afterwards to decode the remaining fields.

func (*Decoder) DecodeLogInfo

func (dec *Decoder) DecodeLogInfo() (schema.LogInfo, error)

DecodeLogInfo decodes commit log info

func (*Decoder) DecodeLogMetadata

func (dec *Decoder) DecodeLogMetadata() (schema.LogMetadata, error)

DecodeLogMetadata decodes commit log metadata

func (*Decoder) Reset

func (dec *Decoder) Reset(stream DecoderStream)

Reset resets the data stream to decode from

type DecoderStream

type DecoderStream interface {
	io.Reader

	// Reset resets the decoder stream for decoding a new byte slice.
	Reset(b []byte)

	// ReadByte reads the next byte.
	ReadByte() (byte, error)

	// UnreadByte unreads the last read byte or returns error if none read
	// yet. Only a single byte can be unread at a time, a consecutive call
	// to UnreadByte will result in an error.
	UnreadByte() error

	// Bytes returns the ref to the bytes provided when Reset(...) is
	// called. To get the current position into the byte slice use:
	// len(s.Bytes()) - s.Remaining()
	Bytes() []byte

	// Skip progresses the reader by a certain amount of bytes, useful
	// when taking a ref to some of the bytes and progressing the reader
	// itself.
	Skip(length int64) error

	// Remaining returns the remaining bytes in the stream.
	Remaining() int64

	// Offset returns the current offset in the byte stream
	Offset() int
}

DecoderStream is a data stream that is read by the decoder, it takes both a reader and the underlying backing bytes. This is constructed this way since the decoder needs access to the backing bytes when taking refs directly for decoding byte slices without allocating bytes itself but also needs to progress the reader (for instance when a reader is a ReaderWithDigest that is calculating a digest as its being read).

func NewDecoderStream

func NewDecoderStream(b []byte) DecoderStream

NewDecoderStream creates a new decoder stream from a bytes ref.

type DecodingOptions

type DecodingOptions interface {
	// SetAllocDecodedBytes sets whether we allocate new space when decoding
	// a byte slice
	SetAllocDecodedBytes(value bool) DecodingOptions

	// AllocDecodedBytes determines whether we allocate new space when decoding
	// a byte slice
	AllocDecodedBytes() bool
}

DecodingOptions provide a set of options for decoding data

func NewDecodingOptions

func NewDecodingOptions() DecodingOptions

NewDecodingOptions creates a new set of decoding options

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder encodes data in msgpack format for persistence

func NewEncoder

func NewEncoder() *Encoder

NewEncoder creates a new encoder

func (*Encoder) Bytes

func (enc *Encoder) Bytes() []byte

Bytes returns the encoded bytes

func (*Encoder) EncodeIndexEntry

func (enc *Encoder) EncodeIndexEntry(entry schema.IndexEntry) error

EncodeIndexEntry encodes index entry

func (*Encoder) EncodeIndexInfo

func (enc *Encoder) EncodeIndexInfo(info schema.IndexInfo) error

EncodeIndexInfo encodes index info

func (*Encoder) EncodeIndexSummary

func (enc *Encoder) EncodeIndexSummary(summary schema.IndexSummary) error

EncodeIndexSummary encodes index summary

func (*Encoder) EncodeLogEntry

func (enc *Encoder) EncodeLogEntry(entry schema.LogEntry) error

EncodeLogEntry encodes commit log entry

func (*Encoder) EncodeLogInfo

func (enc *Encoder) EncodeLogInfo(info schema.LogInfo) error

EncodeLogInfo encodes commit log info

func (*Encoder) EncodeLogMetadata

func (enc *Encoder) EncodeLogMetadata(entry schema.LogMetadata) error

EncodeLogMetadata encodes commit log metadata

func (*Encoder) Reset

func (enc *Encoder) Reset()

Reset resets the buffer

type IndexSummaryToken

type IndexSummaryToken struct {
	// contains filtered or unexported fields
}

IndexSummaryToken can be used, along with the summaries file buffer, to quickly retrieve the ID or index file offset of an index summary entry. It's structured such that the ID and Index file offset can be retrieved quickly, while only requiring 64-bits of memory per entry.

func NewIndexSummaryToken

func NewIndexSummaryToken(idStartOffset, idLength uint32) IndexSummaryToken

NewIndexSummaryToken returns a new IndexSummaryToken

func (IndexSummaryToken) ID

func (m IndexSummaryToken) ID(buf []byte) []byte

ID returns the ID that the metadata corresponds to

func (IndexSummaryToken) IndexOffset

func (m IndexSummaryToken) IndexOffset(
	buf []byte, stream DecoderStream, msgpackDecoder *msgpack.Decoder) (int64, error)

IndexOffset returns the offset in the index file for the series that the metadata corresponds to. The buf, stream, and decoder arguments are passed in so that the IndexSummaryToken struct can be kept small, as well as so that the caller can have control over re-use and allocations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL