art

package module
v0.0.0-...-82ae432 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2020 License: MIT Imports: 3 Imported by: 0

README

ART

Designed for main memory index:

  1. Read optimization
  2. Write exclusion
  3. CPU Cache & Pipeline friendly
  4. Saving memory space

Introduction

Why Adaptive Radix Tree

Main memory capacities have grown up to a point where most databases fit into RAM. For main-memory database systems, index structure performance is a critical bottleneck. Traditional in-memory data structures like balanced binary search trees are not efficient on modern hardware, because they do not optimally utilize on-CPU caches. Hash tables, also often used for main-memory indexes, are fast but only support point queries.

Adaptive Radix Tree overcomes these shortcomings.

You could find more details in <The Adaptive Radix Tree: ARTful Indexing for Main-Memory Databases>.

What's more, one important invariant of ART is that every insertion/deletion order results in the same tree because there are no re-balancing operations. Which means it's easier to implement thread-safe structure.

It was proposed for the first time in 2010, it's too new for a memory index structure.

There is no mature implementation in present.

Limitation

Platform

Only supports X86-64 which has CMPXCHG16B feature (only early processors laked it):

16bytes value could be accessed atomically.

Cannot mix pointer and value in inner node

Go's invalid pointer checking will find the invalid pointer(value). Although we can disable it, it may cause unpredictable collapse.

Acknowledge

  1. ART index, UncP/aili

  2. ART based on <The ART of Practical Synchronization> flode/ARTSynchronized

Thanks for their contribution!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ART

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

ART implements The Adaptive Radix Tree.

func New

func New() *ART

func (*ART) Delete

func (t *ART) Delete() (key []byte, value unsafe.Pointer, err error)

Delete deletes entry, returns nil error if succeed, and deleted key & it's value will be returned too.

func (*ART) Insert

func (t *ART) Insert(key []byte, value unsafe.Pointer, insertOnly bool) (err error)

Insert inserts new entry, returns nil if succeed.

set insertOnly true, if you don't want update old entry.

func (*ART) Search

func (t *ART) Search(key []byte) unsafe.Pointer

Search searches key, returns value's pointer if found.

Returns nil if not found.

Directories

Path Synopsis
internal
mem

Jump to

Keyboard shortcuts

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