Documentation
¶
Overview ¶
Package hashmap implements an on-disk hash map.
Index ¶
- type Cursor
- type HashMap
- func (hm *HashMap) AddItem(key []byte, value []byte, returnPresentValue bool) ([]byte, bool)
- func (hm *HashMap) AddOrUpdateItem(key []byte, value []byte, returnReplacedValue bool) ([]byte, bool)
- func (hm *HashMap) Create()
- func (hm *HashMap) DeleteItem(key []byte, returnRemovedValue bool) ([]byte, bool)
- func (hm *HashMap) Destroy()
- func (hm *HashMap) FetchItem(cursor *Cursor) ([]byte, []byte, bool)
- func (hm *HashMap) HasItem(key []byte, returnPresentValue bool) ([]byte, bool)
- func (hm *HashMap) Init(fileStorage *fsm.FileStorage) *HashMap
- func (hm *HashMap) Load(infoAddr int64)
- func (hm *HashMap) MaxNumberOfSlotDirs() int
- func (hm *HashMap) MinNumberOfSlots() int
- func (hm *HashMap) NumberOfItems() int
- func (hm *HashMap) NumberOfSlotDirs() int
- func (hm *HashMap) NumberOfSlots() int
- func (hm *HashMap) PayloadSize() int
- func (hm *HashMap) Store() int64
- func (hm *HashMap) UpdateItem(key []byte, value []byte, returnReplacedValue bool) ([]byte, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
Cursor represents a cursor at a position in a hash map.
type HashMap ¶
type HashMap struct {
// contains filtered or unexported fields
}
HashMap represents a hash map on disk.
func (*HashMap) AddItem ¶
AddItem adds the given item to the hash map. If no item matched exists in the hash map, it adds the item and then returns true, otherwise it returns false and the present value (optional) of the item.
func (*HashMap) AddOrUpdateItem ¶
func (hm *HashMap) AddOrUpdateItem(key []byte, value []byte, returnReplacedValue bool) ([]byte, bool)
AddOrUpdateItem adds the given item to the hash map or replaces the value of an item with the given key to the given value. If no item matched exists in the hash map, it adds the item and then returns true, otherwise it updates the item and then returns false and the replaced value (optional) of the item.
func (*HashMap) Create ¶
func (hm *HashMap) Create()
Create creates the hash map on the file storage.
func (*HashMap) DeleteItem ¶
DeleteItem deletes an item with the given key in the hash map. If an item matched exists in the hash map, it deletes the item and then returns true and the removed value (optional) of the item, otherwise it returns false.
func (*HashMap) Destroy ¶
func (hm *HashMap) Destroy()
Destroy destroys the hash map on the file storage.
func (*HashMap) FetchItem ¶
FetchItem fetches an item from the given cursor in the hash map, and meanwhile advances the given cursor to the next position. It returns false if there are no more items. The initial cursor is of the zero value.
func (*HashMap) HasItem ¶
HasItem checks whether an item with the given key in the hash map. If an item matched exists in the hash map, it returns true and the present value (optional) of the item, otherwise it returns false.
func (*HashMap) Init ¶
func (hm *HashMap) Init(fileStorage *fsm.FileStorage) *HashMap
Init initializes the hash map with the given file storage and returns it.
func (*HashMap) MaxNumberOfSlotDirs ¶
MaxNumberOfSlotDirs returns the maximum number of the slot directories of the hash map.
func (*HashMap) MinNumberOfSlots ¶
MinNumberOfSlots returns the minimum number of the slots of the hash map.
func (*HashMap) NumberOfItems ¶
NumberOfItems returns the number of the items of the hash map.
func (*HashMap) NumberOfSlotDirs ¶
NumberOfSlotDirs returns the number of the slot directories of the hash map.
func (*HashMap) NumberOfSlots ¶
NumberOfSlots returns the number of the slots of the hash map.
func (*HashMap) PayloadSize ¶
PayloadSize returns the payload size of the hash map.
func (*HashMap) Store ¶
Store stores the hash map to the file storage and then returns the info address.
func (*HashMap) UpdateItem ¶
UpdateItem replaces the value of an item with the given key in the hash map to the given value. If an item matched exists in the hash map, it updates the item and then returns true and the replaced value (optional) of the item, otherwise it returns false.