boltdb

package
v0.0.0-...-96f1409 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package boltdb provides a pdk.Translator implementation using boltdb. BoltDB is great, but this package is not particularly well-used or tested, and it is recommended that one use the leveldb translator instead which has better write performance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Translator

type Translator struct {
	Db *bolt.DB
	// contains filtered or unexported fields
}

Translator is a pdk.Translator which stores the two way val/id mapping in boltdb. It only accepts string values to map.

func NewTranslator

func NewTranslator(filename string, fields ...string) (bt *Translator, err error)

NewTranslator gets a new Translator

func (*Translator) BulkAdd

func (bt *Translator) BulkAdd(field string, values [][]byte) error

BulkAdd adds many values to a field at once, allocating ids.

func (*Translator) Close

func (bt *Translator) Close() error

Close syncs and closes the underlying boltdb.

func (*Translator) Get

func (bt *Translator) Get(field string, id uint64) (val interface{})

Get returns the previously mapped value to the monotonic id generated from GetID. For BoltTranslator, val will always be a []byte.

func (*Translator) GetID

func (bt *Translator) GetID(field string, val interface{}) (id uint64, err error)

GetID maps val (which must be a byte slice) to a monotonic id.

Jump to

Keyboard shortcuts

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