model

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToU32

func BytesToU32(b []byte) uint32

func BytesToU32Slice

func BytesToU32Slice(b []byte) []uint32

func CompareKeyNoTs

func CompareKeyNoTs(key1, key2 []byte) int

CompareKeyNoTs skipList.key() table.biggestKey() block.baseKey()

func CompareKeyWithTs

func CompareKeyWithTs(key1, key2 []byte) int

func FastRand

func FastRand() uint32

FastRand is a fast thread local random function.

func IsDeletedOrExpired

func IsDeletedOrExpired(meta byte, expiresAt uint64) bool

func IsDiscardEntry

func IsDiscardEntry(vlogEntry, lsmEntry *Entry) bool

func IsValPtr

func IsValPtr(entry Entry) bool

func KeyWithTestTs

func KeyWithTestTs(key []byte, version uint64) []byte

func KeyWithTs

func KeyWithTs(key []byte) []byte

func NewCurVersion

func NewCurVersion() uint64

func ParseKey

func ParseKey(key []byte) []byte

ParseKey 祛除掉版本信息之后的key;

func ParseTsVersion

func ParseTsVersion(key []byte) int64

func RunCallback

func RunCallback(back func())

func SafeCopy

func SafeCopy(des, src []byte) []byte

func SameKeyNoTs

func SameKeyNoTs(src, dst []byte) bool

func U32SliceToBytes

func U32SliceToBytes(u32s []uint32) []byte

func U32ToBytes

func U32ToBytes(v uint32) []byte

func U64ToBytes

func U64ToBytes(v uint64) []byte

Types

type Entry

type Entry struct {
	Key       []byte
	Value     []byte
	ExpiresAt uint64

	Meta    byte
	Version int64

	HeaderLen    int
	Offset       uint32
	ValThreshold int64
}

Entry db写入的结构体;

func BuildEntry

func BuildEntry() Entry

func NewEntry

func NewEntry(key, val []byte) Entry

func (*Entry) EncodeSize

func (e *Entry) EncodeSize() uint32

func (*Entry) EstimateSize

func (e *Entry) EstimateSize(valThreshold int) int

func (*Entry) IsDeleteOrExpired

func (e *Entry) IsDeleteOrExpired() bool

func (*Entry) SafeCopy

func (e *Entry) SafeCopy() Entry

func (*Entry) WithTTL

func (e *Entry) WithTTL(dur time.Duration) *Entry

type EntryHeader

type EntryHeader struct {
	KLen      uint32
	VLen      uint32
	ExpiresAt uint64
	Meta      byte
}

func (*EntryHeader) Decode

func (h *EntryHeader) Decode(buf []byte) int

func (*EntryHeader) DecodeFrom

func (h *EntryHeader) DecodeFrom(reader *HashReader) (int, error)

func (EntryHeader) Encode

func (h EntryHeader) Encode(out []byte) int

type HashReader

type HashReader struct {
	R        io.Reader
	H        hash.Hash32
	ByteRead int
}

func NewHashReader

func NewHashReader(read io.Reader) *HashReader

func (*HashReader) Read

func (r *HashReader) Read(out []byte) (int, error)

func (*HashReader) ReadByte

func (r *HashReader) ReadByte() (byte, error)

func (*HashReader) Sum32

func (r *HashReader) Sum32() uint32

type Item

type Item struct {
	Item Entry
}

type Iterator

type Iterator interface {
	Name() string
	Next()
	Valid() bool
	Rewind()
	Item() Item
	Seek(key []byte)
	Close() error
}

type LogEntry

type LogEntry func(e *Entry, vp *ValuePtr) error

type Options

type Options struct {
	Prefix []byte
	IsAsc  bool // 是否升序遍历, 默认是 true;
}

type ValueExt

type ValueExt struct {
	Meta      byte // delete:1 or normal:0  or BitValuePointer:2
	Value     []byte
	ExpiresAt uint64

	Version int64
}

ValueExt 把有关value的扩展信息,再封装一次; 使其方便一次性编码在 arena空间中, 返回len和offset;

func (*ValueExt) DecodeVal

func (val *ValueExt) DecodeVal(buf []byte)

func (*ValueExt) EncodeVal

func (val *ValueExt) EncodeVal(buf []byte) uint32

func (*ValueExt) EncodeValSize

func (val *ValueExt) EncodeValSize() uint32

type ValuePtr

type ValuePtr struct {
	Len    uint32
	Offset uint32
	Fid    uint32
}

ValuePtr 存储的是 value在vlog组件的信息;

func (*ValuePtr) Decode

func (p *ValuePtr) Decode(b []byte)

func (ValuePtr) Encode

func (p ValuePtr) Encode() []byte

Jump to

Keyboard shortcuts

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