hashmap

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package hashmap implements an on-disk hash map.

Index

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

func (hm *HashMap) AddItem(key []byte, value []byte, returnPresentValue bool) ([]byte, bool)

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

func (hm *HashMap) DeleteItem(key []byte, returnRemovedValue bool) ([]byte, bool)

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

func (hm *HashMap) FetchItem(cursor *Cursor) ([]byte, []byte, bool)

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

func (hm *HashMap) HasItem(key []byte, returnPresentValue bool) ([]byte, bool)

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) Load

func (hm *HashMap) Load(infoAddr int64)

Load loads the hash map from the file storage with the given info address.

func (*HashMap) MaxNumberOfSlotDirs

func (hm *HashMap) MaxNumberOfSlotDirs() int

MaxNumberOfSlotDirs returns the maximum number of the slot directories of the hash map.

func (*HashMap) MinNumberOfSlots

func (hm *HashMap) MinNumberOfSlots() int

MinNumberOfSlots returns the minimum number of the slots of the hash map.

func (*HashMap) NumberOfItems

func (hm *HashMap) NumberOfItems() int

NumberOfItems returns the number of the items of the hash map.

func (*HashMap) NumberOfSlotDirs

func (hm *HashMap) NumberOfSlotDirs() int

NumberOfSlotDirs returns the number of the slot directories of the hash map.

func (*HashMap) NumberOfSlots

func (hm *HashMap) NumberOfSlots() int

NumberOfSlots returns the number of the slots of the hash map.

func (*HashMap) PayloadSize

func (hm *HashMap) PayloadSize() int

PayloadSize returns the payload size of the hash map.

func (*HashMap) Store

func (hm *HashMap) Store() int64

Store stores the hash map to the file storage and then returns the info address.

func (*HashMap) UpdateItem

func (hm *HashMap) UpdateItem(key []byte, value []byte, returnReplacedValue bool) ([]byte, bool)

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.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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