nodetable

package
v0.0.0-...-937fe99 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2016 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package nodetable implements high performance GC optimized Node lookup table for Nitro index storage. This table is not thread-safe

Golang map does not need to pay the cost of GC scans if you have native fixed size types for both key and value. We use two tables for the node lookup table implementation. Fast table and slow table. Fast table stores maps crc32(key) to a uint64. Value is a pointer to a skiplist node. Highest bit is used to indicate whether there is any hash collision for the crc32 key used. If the bit is set, that means we need to lookup second table, which is the slow table. Slow table has multiple entries which are mapped by the same crc32 key.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareNodeTable

func CompareNodeTable(a, b unsafe.Pointer) int

CompareNodeTable implements comparator for nodetable instances

func MemoryInUse

func MemoryInUse() (sz int64)

MemoryInUse returns total memory used by nodetables in a process

Types

type EqualKeyFn

type EqualKeyFn func(unsafe.Pointer, []byte) bool

EqualKeyFn implements key equality check

type HashFn

type HashFn func([]byte) uint32

HashFn implements 32bit hash function on a string

type NodeTable

type NodeTable struct {
	// contains filtered or unexported fields
}

NodeTable describes lookup table

func New

func New(hfn HashFn, kfn EqualKeyFn) *NodeTable

New creates a nodetable instance

func (*NodeTable) Close

func (nt *NodeTable) Close()

Close destroys the nodetable

func (*NodeTable) Get

func (nt *NodeTable) Get(key []byte) unsafe.Pointer

Get returns node pointer for the lookup key

func (*NodeTable) MemoryInUse

func (nt *NodeTable) MemoryInUse() int64

MemoryInUse returns memory used by nodetable instance

func (*NodeTable) Remove

func (nt *NodeTable) Remove(key []byte) (success bool, nptr unsafe.Pointer)

Remove an item from the nodetable

func (*NodeTable) Stats

func (nt *NodeTable) Stats() string

Stats returns nodetable statistics

func (*NodeTable) Update

func (nt *NodeTable) Update(key []byte, nptr unsafe.Pointer) (updated bool, oldPtr unsafe.Pointer)

Update inserts or replaces an existing entry

Source Files

  • table.go

Jump to

Keyboard shortcuts

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