gcswiss

package module
v0.0.0-...-a47652f Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: MIT Imports: 5 Imported by: 0

README

gcswiss

GoDoc

gcswiss is an off-heap hashmap following the swiss-tables design. Keys must always be strings, but the values are generic. Keys & values are copied and kept off heap, so if the values contain pointers to heap objects they must be kept alive separately.

Documentation

Overview

Package gcswiss is a GC friendly hash map that uses an Extensible hashing plus Swiss table design. It is very based on the newer Go standard library map and the cockroachdb implementation.

- It does not support deletes. - It uses a 32bit hash - It allocates memory outside of the Go heap.

At the bottom we have groups of 8 (maybe 16 later?) entries.

Above this we have tables, which are fixed-size hash tables containing groups.

Above that we have a directory, which is indexed by the top bits of the hash and points to tables. This is the extensible hashing part.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GroupLocation

type GroupLocation[V any] struct {
	// contains filtered or unexported fields
}

GroupLocation represents a location in the table for a specific key. The caller retrieves the location, then can use it to get or set the value. If the key did not exist, the caller must use Set to set the key and value.

func (GroupLocation[V]) Get

func (gl GroupLocation[V]) Get() V

func (GroupLocation[V]) Set

func (gl GroupLocation[V]) Set(key string, value V)

Set is used when the key was not previously present in the map.

func (GroupLocation[V]) SetValue

func (gl GroupLocation[V]) SetValue(value V)

type Map

type Map[V any] struct {
	// contains filtered or unexported fields
}

func New

func New[V any]() *Map[V]

func (*Map[V]) Close

func (m *Map[V]) Close()

func (*Map[V]) Find

func (m *Map[V]) Find(key string) (GroupLocation[V], bool)

Jump to

Keyboard shortcuts

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