Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// NumShards controls the number of shards the XidMap is broken into. More
// shards reduces lock contention.
NumShards int
// LRUSize controls the total size of the LRU cache. The LRU is split
// between all shards, so with 4 shards and an LRUSize of 100, each shard
// receives 25 LRU slots.
LRUSize int
}
Options controls the performance characteristics of the XidMap.
type UidProvider ¶
type UidProvider interface {
// ReserveUidRange should give a range of new uids from start to end
// (start and end are both inclusive).
ReserveUidRange() (start, end uint64, err error)
}
UidProvider allows the XidMap to obtain ranges of uids that it can then allocate freely. Implementations should expect to be called concurrently.
type XidMap ¶
type XidMap struct {
// contains filtered or unexported fields
}
XidMap allocates and tracks mappings between Xids and Uids in a threadsafe manner. It's memory friendly because the mapping is stored on disk, but fast because it uses an LRU cache.
func New ¶
func New(kv *badger.DB, up UidProvider, opt Options) *XidMap
New creates an XidMap with given badger and uid provider.
func (*XidMap) AllocateUid ¶
AllocateUid gives a single uid without creating an xid to uid mapping.
Click to show internal directories.
Click to hide internal directories.