decoder

package
v0.0.0-...-7332f57 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const LRU_BITS = 24

RobjOverhead get memory useage of a robj

typedef struct redisobject {
    unsigned type:4;
    unsigned encoding:4;
    unsigned lru:lru_bits; /* lru time (relative to server.lruclock) */
    int refcount;
    void *ptr;
} robj;

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

type Decoder struct {
	Entries chan *Entry

	nopdecoder.NopDecoder
	// contains filtered or unexported fields
}

Decoder decode rdb file

func NewDecoder

func NewDecoder() *Decoder

NewDecoder new a rdb decoder

func (*Decoder) Aux

func (d *Decoder) Aux(key, value []byte)

func (*Decoder) EndHash

func (d *Decoder) EndHash(key []byte)

EndHash is called when there are no more fields in a hash.

func (*Decoder) EndList

func (d *Decoder) EndList(key []byte)

EndList is called when there are no more values in a list.

func (*Decoder) EndRDB

func (d *Decoder) EndRDB()

EndRDB is called when parsing of the RDB file is complete.

func (*Decoder) EndSet

func (d *Decoder) EndSet(key []byte)

EndSet is called when there are no more fields in a set. Same as EndHash

func (*Decoder) EndStream

func (d *Decoder) EndStream(key []byte, items uint64, lastEntryID string, cgroupsData rdb.StreamGroups)

func (*Decoder) EndZSet

func (d *Decoder) EndZSet(key []byte)

EndZSet is called when there are no more members in a sorted set.

func (*Decoder) GetTimestamp

func (d *Decoder) GetTimestamp() int64

func (*Decoder) GetUsedMem

func (d *Decoder) GetUsedMem() int64

func (*Decoder) Hset

func (d *Decoder) Hset(key, field, value []byte)

Hset is called once for each field=value pair in a hash.

func (*Decoder) Rpush

func (d *Decoder) Rpush(key, value []byte)

Rpush is called once for each value in a list.

func (*Decoder) Sadd

func (d *Decoder) Sadd(key, member []byte)

Sadd is called once for each member of a set.

func (*Decoder) Set

func (d *Decoder) Set(key, value []byte, expiry int64, info *rdb.Info)

Set is called once for each string key.

func (*Decoder) StartHash

func (d *Decoder) StartHash(key []byte, length, expiry int64, info *rdb.Info)

StartHash is called at the beginning of a hash. Hset will be called exactly length times before EndHash.

func (*Decoder) StartList

func (d *Decoder) StartList(key []byte, length, expiry int64, info *rdb.Info)

StartList is called at the beginning of a list. Rpush will be called exactly length times before EndList. If length of the list is not known, then length is -1

func (*Decoder) StartRDB

func (d *Decoder) StartRDB(ver int)

func (*Decoder) StartSet

func (d *Decoder) StartSet(key []byte, cardinality, expiry int64, info *rdb.Info)

StartSet is called at the beginning of a set. Sadd will be called exactly cardinality times before EndSet.

func (*Decoder) StartStream

func (d *Decoder) StartStream(key []byte, cardinality, expiry int64, info *rdb.Info)

func (*Decoder) StartZSet

func (d *Decoder) StartZSet(key []byte, cardinality, expiry int64, info *rdb.Info)

StartZSet is called at the beginning of a sorted set. Zadd will be called exactly cardinality times before EndZSet.

func (*Decoder) Xadd

func (d *Decoder) Xadd(key, id, listpack []byte)

func (*Decoder) Zadd

func (d *Decoder) Zadd(key []byte, score float64, member []byte)

Zadd is called once for each member of a sorted set.

type Entry

type Entry struct {
	Key                string
	Bytes              uint64
	Type               string
	NumOfElem          uint64
	LenOfLargestElem   uint64
	FieldOfLargestElem string
}

Entry is info of a redis recored

type MemProfiler

type MemProfiler struct{}

MemProfiler get memory use for all kinds of data stuct

func (*MemProfiler) ElemLen

func (m *MemProfiler) ElemLen(element []byte) uint64

ElemLen get length of a element

func (*MemProfiler) HashtableEntryOverhead

func (m *MemProfiler) HashtableEntryOverhead() uint64

HashtableEntryOverhead get memory use of hashtable entry See https://github.com/antirez/redis/blob/unstable/src/dict.h Each dictEntry has 3 pointers

typedef struct dictEntry {
    void *key;
    union {
        void *val;
        uint64_t u64;
        int64_t s64;
        double d;
    } v;
    struct dictEntry *next;
} dictEntry;

func (*MemProfiler) HashtableOverhead

func (m *MemProfiler) HashtableOverhead(size uint64) uint64

HashtableOverhead get memory use of a hashtable See https://github.com/antirez/redis/blob/unstable/src/dict.h See the structures dict and dictht 2 * (3 unsigned longs + 1 pointer) + int + long + 2 pointers

Additionally, see **table in dictht The length of the table is the next power of 2 When the hashtable is rehashing, another instance of **table is created Due to the possibility of rehashing during loading, we calculate the worse case in which both tables are allocated, and so multiply the size of **table by 1.5

func (*MemProfiler) KeyExpiryOverhead

func (m *MemProfiler) KeyExpiryOverhead(expiry int64) uint64

KeyExpiryOverhead get memory useage of a key expiry Key expiry is stored in a hashtable, so we have to pay for the cost of a hashtable entry The timestamp itself is stored as an int64, which is a 8 bytes

func (*MemProfiler) LinkedListEntryOverhead

func (m *MemProfiler) LinkedListEntryOverhead() uint64

LinkedListEntryOverhead get memory use of a linked list entry See https://github.com/antirez/redis/blob/unstable/src/adlist.h A node has 3 pointers

func (*MemProfiler) LinkedlistOverhead

func (m *MemProfiler) LinkedlistOverhead() uint64

LinkedlistOverhead get memory use of a linked list See https://github.com/antirez/redis/blob/unstable/src/adlist.h A list has 5 pointers + an unsigned long

func (*MemProfiler) QuicklistOverhead

func (m *MemProfiler) QuicklistOverhead(size uint64) uint64

func (*MemProfiler) RobjOverhead

func (m *MemProfiler) RobjOverhead() uint64

func (*MemProfiler) SizeofStreamRadixTree

func (m *MemProfiler) SizeofStreamRadixTree(numElements uint64) uint64

func (*MemProfiler) SizeofString

func (m *MemProfiler) SizeofString(bytes []byte) uint64

SizeofString get memory use of a string https://github.com/antirez/redis/blob/unstable/src/sds.h

func (*MemProfiler) SkiplistEntryOverhead

func (m *MemProfiler) SkiplistEntryOverhead() uint64

SkiplistEntryOverhead get memory use of a skiplist entry

func (*MemProfiler) SkiplistOverhead

func (m *MemProfiler) SkiplistOverhead(size uint64) uint64

SkiplistOverhead get memory use of a skiplist

func (*MemProfiler) StreamCG

func (m *MemProfiler) StreamCG() uint64

func (*MemProfiler) StreamConsumer

func (m *MemProfiler) StreamConsumer(name []byte) uint64

func (*MemProfiler) StreamNACK

func (m *MemProfiler) StreamNACK(length uint64) uint64

func (*MemProfiler) StreamOverhead

func (m *MemProfiler) StreamOverhead() uint64

func (*MemProfiler) TopLevelObjOverhead

func (m *MemProfiler) TopLevelObjOverhead(key []byte, expiry int64) uint64

TopLevelObjOverhead get memory use of a top level object Each top level object is an entry in a dictionary, and so we have to include the overhead of a dictionary entry

func (*MemProfiler) ZiplistEntryOverhead

func (m *MemProfiler) ZiplistEntryOverhead(value []byte) uint64

func (*MemProfiler) ZiplistHeaderOverhead

func (m *MemProfiler) ZiplistHeaderOverhead() uint64

Jump to

Keyboard shortcuts

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