dashtable

package
v0.0.0-...-e9e3673 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToInt64

func BytesToInt64(b []byte) int64

func BytesToString

func BytesToString(b []byte) string

BytesToString converts a string to a byte slice.

Note: This link the returned b slice as the underlying value of the s string, so any changes on b will also be reflected to s. Make sure you won't change b or only changed it AFTER the returning s string has been used and it won't be accessed anymore. Careful while using this function.

func Int64ToBytes

func Int64ToBytes(i int64) []byte

func StringToBytes

func StringToBytes(s string) (b []byte)

StringToBytes converts a string to a byte slice.

Note: This link the returned b slice to the s string, so any changes on b will also be reflected to s. Careful while using this function.

Types

type Dashtable

type Dashtable[K comparable, V any] struct {
	// contains filtered or unexported fields
}

Dashtable is a toy implementation of dragonfly's dashtable. https://github.com/dragonflydb/dragonfly/blob/main/docs/dashtable.md A dashtable is expected to be run in a single thread/goroutine only, and currently it's NOT thread-safe to call Set and Get in parallel. To better scale out, build the application top of the Dashtable which pin each CPU thread to a dashtable instance.

func New

func New[K comparable, V any](noMaxItem uint64) *Dashtable[K, V]

New returns a ready to use Dashtable.

noMaxItem provides a hint on how many segments we need to create first hand to be able to hold up to that maximum number of items, as we haven't implemented dashtable growth via segment splitting yet.

func (*Dashtable[K, V]) Get

func (dtb *Dashtable[K, V]) Get(key K) (ok bool, value V)

func (*Dashtable[K, V]) Set

func (dtb *Dashtable[K, V]) Set(key K, value V)

func (*Dashtable[K, V]) Sum

func (dtb *Dashtable[K, V]) Sum(key K) uint64

Jump to

Keyboard shortcuts

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