Documentation
¶
Overview ¶
Package ctrie provides an implementation of the Ctrie data structure, which is a concurrent, lock-free hash trie. This data structure was originally presented in the paper Concurrent Tries with Efficient Non-Blocking Snapshots:
https://axel22.github.io/resources/docs/ctries-snapshot.pdf
Copyright 2015 Workiva, LLC Modified by stephane martin
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License
Index ¶
- Variables
- type Ctrie
- func (c *Ctrie) Clear()
- func (c *Ctrie) Filter(f func(Entry) bool, ch chan Entry)
- func (c *Ctrie) ForEach(f func(Entry))
- func (c *Ctrie) Insert(key string, value *utils.OFile) (inserted bool)
- func (c *Ctrie) Iterate(ch chan Entry)
- func (c *Ctrie) Lookup(key string) (*utils.OFile, bool)
- func (c *Ctrie) ReadOnlySnapshot() *Ctrie
- func (c *Ctrie) Remove(key string) (*utils.OFile, bool)
- func (c *Ctrie) Set(key string, value *utils.OFile) (replaced bool)
- func (c *Ctrie) Size() int
- func (c *Ctrie) Snapshot() *Ctrie
- type Entry
- type HashFactory
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyList = errors.New("Empty list")
ErrEmptyList is returned when an invalid operation is performed on an empty list.
Functions ¶
This section is empty.
Types ¶
type Ctrie ¶
type Ctrie struct {
// contains filtered or unexported fields
}
Ctrie is a concurrent, lock-free hash trie. By default, keys are hashed using FNV-1a unless a HashFactory is provided to New.
func New ¶
func New(hashFactory HashFactory) *Ctrie
New creates an empty Ctrie which uses the provided HashFactory for key hashing. If nil is passed in, it will default to FNV-1a hashing.
func (*Ctrie) Lookup ¶
Lookup returns the value for the associated key or returns false if the key doesn't exist.
func (*Ctrie) ReadOnlySnapshot ¶
ReadOnlySnapshot returns a stable, point-in-time snapshot of the Ctrie which is read-only. Write operations on a read-only snapshot will panic.
type HashFactory ¶
HashFactory returns a new Hash32 used to hash keys.