Documentation ¶
Index ¶
- func NewSlabPool(objSize uint8, objsPerSlab uint) *slabPool
- type FragStat
- type MemStat
- type ObjAddr
- type ObjectStore
- func (o *ObjectStore) Add(obj []byte) (ObjAddr, error)
- func (o *ObjectStore) Delete(obj ObjAddr) error
- func (o *ObjectStore) FragStatsByObjSize(size uint8) (float32, error)
- func (o *ObjectStore) FragStatsPerPool() (fragStats []FragStat)
- func (o *ObjectStore) FragStatsTotal() (float32, error)
- func (o *ObjectStore) Get(obj ObjAddr) ([]byte, error)
- func (o *ObjectStore) MemStatsByObjSize(size uint8) (uint64, error)
- func (o *ObjectStore) MemStatsPerPool() (memStats []MemStat)
- func (o *ObjectStore) MemStatsTotal() (uint64, error)
- func (o *ObjectStore) Search(searching []byte) (ObjAddr, bool)
- type SlabAddr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSlabPool ¶
NewSlabPool initializes a new slab pool and returns a pointer to it
Types ¶
type ObjAddr ¶
type ObjAddr = uintptr
ObjAddr is a uintptr used for storing the addresses of objects in slabs
type ObjectStore ¶
type ObjectStore struct {
// contains filtered or unexported fields
}
ObjectStore contains a map of slabPools indexed by the size of the objects stored in each pool It also contains a lookup table which is a slice of SlabAddr lookupTable is kept sorted in descending order and updated whenever a slab is created or deleted
func NewObjectStore ¶
func NewObjectStore(objsPerSlab uint) ObjectStore
NewObjectStore initializes a new object store with the given number of objects per slab, it returns the object store as a value
func (*ObjectStore) Add ¶
func (o *ObjectStore) Add(obj []byte) (ObjAddr, error)
Add takes an object and adds it to the slab pool of the correct size On success it returns the memory address of the added object as an ObjAddr On failure it returns an error as the second value
func (*ObjectStore) Delete ¶
func (o *ObjectStore) Delete(obj ObjAddr) error
Delete deletes an object by object address On success it returns nil, otherwise it returns an error message
func (*ObjectStore) FragStatsByObjSize ¶
func (o *ObjectStore) FragStatsByObjSize(size uint8) (float32, error)
FragStatsByObjSize returns the fragmentation percent of the requested pool as specified by size
func (*ObjectStore) FragStatsPerPool ¶
func (o *ObjectStore) FragStatsPerPool() (fragStats []FragStat)
FragStatsPerPool returns a slice containing a FragStat for each non-empty slab pool
func (*ObjectStore) FragStatsTotal ¶
func (o *ObjectStore) FragStatsTotal() (float32, error)
FragStatsTotal returns the total fragmentation percent across the object store
func (*ObjectStore) Get ¶
func (o *ObjectStore) Get(obj ObjAddr) ([]byte, error)
Get retrieves a value by object address On success it returns a byte slice of appropriate length, containing the requested object data On failure the second returned value is the error
func (*ObjectStore) MemStatsByObjSize ¶
func (o *ObjectStore) MemStatsByObjSize(size uint8) (uint64, error)
MemStatsByObjSize returns the size of a slab pool in bytes. It only looks at MMapped memory
func (*ObjectStore) MemStatsPerPool ¶
func (o *ObjectStore) MemStatsPerPool() (memStats []MemStat)
MemStatsPerPool returns a slice containing a MemStat for each non-empty slab pool
func (*ObjectStore) MemStatsTotal ¶
func (o *ObjectStore) MemStatsTotal() (uint64, error)
MemStatsTotal returns the estimated total MMapped memory used across the object store