codec

package
v0.0.0-...-e1f8a17 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPartitionHashFromBytes

func GetPartitionHashFromBytes(b []byte) uint64

GetPartitionHashFromBytes reads the partition hash directly from bytes

func Merge

func Merge(a, b []byte) (mergedBytes []byte, merged bool)

Merge merges two []byte into one []byte based on the Entry format.

Types

type Entry

type Entry struct {
	PartitionHash uint64
	UpdatedAtNs   uint64
	TtlSecond     uint32
	OpAndDataType OpAndDataType
	Value         []byte
}

Entry is the on-disk value bytes in this key-value system.

func FromBytes

func FromBytes(b []byte) *Entry

FromBytes deserialize bytes into one Entry

func MergeEntry

func MergeEntry(a, b []byte) (mergedEntry *Entry, merged bool)

MergeEntry merges two []byte into one Entry object.

func NewMergeEntry

func NewMergeEntry(m *pb.MergeRequest, updatedAtNs uint64) *Entry

NewMergeEntry creates an Entry from pb.MergeRequest

func NewPutEntry

func NewPutEntry(put *pb.PutRequest, updatedAtNs uint64) *Entry

NewPutEntry creates an Entry from pb.PutRequest

func (*Entry) IsExpired

func (e *Entry) IsExpired() bool

IsExpired checks whether the entry updated_at time plus ttl time is less than current time. If ttlSecond is 0, the entry will not expire.

func (*Entry) MergeWith

func (e *Entry) MergeWith(b []byte) (merged bool)

MergeWith merges one Entry object with a matching []byte.

func (*Entry) ToBytes

func (e *Entry) ToBytes() []byte

ToBytes serializes the entry into bytes

type OpAndDataType

type OpAndDataType byte

OpAndDataType maps to pb.OpAndDataType

Jump to

Keyboard shortcuts

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