index

package
v0.0.0-...-b4886c5 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package index implements gSuneido database indexes.

Indexes store pairs of string keys and uint64 offsets. Keys must be unique within a particular index.

Suneido style iterators (i.e. Next/Prev/Rewind) have a current key value and behave as if Next/Prev get the first value greater than or less than the current value, regardless of modifications to the data. e.g. the current or next value could be deleted, or a new next value inserted. However, their implementations use a current position to be more efficient. Although the iterators expose a Cur method, this is for internal purposes. The current value is only really valid immediately after Next or Prev. At the Suneido level Next and Prev return the new current value.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MergeResult

type MergeResult = *ixbuf.T

type OverIter

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

OverIter is a Suneido style iterator that merges several other Suneido style iterators.

OverIter also tracks read ranges for transaction conflict checking.

func NewOverIter

func NewOverIter(table string, iIndex int) *OverIter

func (*OverIter) Cur

func (oi *OverIter) Cur() (string, uint64)

func (*OverIter) Eof

func (oi *OverIter) Eof() bool

func (*OverIter) Next

func (oi *OverIter) Next(t oiTran)

func (*OverIter) Prev

func (oi *OverIter) Prev(t oiTran)

func (*OverIter) Print

func (oi *OverIter) Print()

func (*OverIter) Range

func (oi *OverIter) Range(rng Range)

func (*OverIter) Rewind

func (oi *OverIter) Rewind()

type Overlay

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

Overlay is the composite in-memory representation of an index

func NewOverlay

func NewOverlay(store *stor.Stor, is *ixkey.Spec) *Overlay

func OverlayFor

func OverlayFor(bt *btree.T) *Overlay

func OverlayForN

func OverlayForN(bt *btree.T, nlayers int) *Overlay

func OverlayStub

func OverlayStub() *Overlay

OverlayStub is for tests

func ReadOverlay

func ReadOverlay(st *stor.Stor, r *stor.Reader) *Overlay

ReadOverlay reads an Overlay from storage BUT without ixspec

func (*Overlay) BtreeLevels

func (ov *Overlay) BtreeLevels() int

func (*Overlay) Check

func (ov *Overlay) Check(fn func(uint64)) int

func (*Overlay) CheckMerged

func (ov *Overlay) CheckMerged()

func (*Overlay) Cksum

func (ov *Overlay) Cksum() uint32

func (*Overlay) Copy

func (ov *Overlay) Copy() *Overlay

Copy is for debugging

func (*Overlay) Delete

func (ov *Overlay) Delete(key string, off uint64)

Delete either deletes the key/offset from the mutable ixbuf.T or inserts a tombstone into the mutable ixbuf.T.

func (*Overlay) GetIxspec

func (ov *Overlay) GetIxspec() *ixkey.Spec

func (*Overlay) Insert

func (ov *Overlay) Insert(key string, off uint64)

Insert inserts into the mutable top ixbuf.T

func (*Overlay) Lookup

func (ov *Overlay) Lookup(key string) uint64

Lookup returns the offset of the record specified by the key or 0 if it's not found. It handles the Delete bit and removes the Update bit.

func (*Overlay) Merge

func (ov *Overlay) Merge(nmerge int) MergeResult

Merge merges the base ixbuf with one or more of the transaction ixbuf's to produce a new base ixbuf. It does not modify the original ixbuf's.

func (*Overlay) Modified

func (ov *Overlay) Modified() bool

Modified is used by info.Persist. It only looks at the base ixbuf (layer[0]) which accumulates changes between persists via merging other per transaction ixbuf's.

func (*Overlay) Mutable

func (ov *Overlay) Mutable() *Overlay

Mutable returns a modifiable copy of an Overlay

func (*Overlay) Nlayers

func (ov *Overlay) Nlayers() int

func (*Overlay) Print

func (ov *Overlay) Print()

func (*Overlay) QuickCheck

func (ov *Overlay) QuickCheck()

func (*Overlay) RangeFrac

func (ov *Overlay) RangeFrac(org, end string) float32

func (*Overlay) Save

func (ov *Overlay) Save() SaveResult

Save updates the stored btree with the base ixbuf and returns the new btree to later pass to WithSaved

func (*Overlay) SetIxspec

func (ov *Overlay) SetIxspec(is *ixkey.Spec)

func (*Overlay) Stats

func (ov *Overlay) Stats() btree.Stats

func (*Overlay) StorSize

func (ov *Overlay) StorSize() int

func (*Overlay) Update

func (ov *Overlay) Update(key string, off uint64)

func (*Overlay) UpdateWith

func (ov *Overlay) UpdateWith(latest *Overlay)

UpdateWith combines the overlay result of a transaction with the latest overlay. It is called by Meta.LayeredOnto. The immutable part of ov was taken at the start of the transaction so it will be out of date. The checker ensures that the updates are independent.

func (*Overlay) WithMerged

func (ov *Overlay) WithMerged(mr MergeResult, nmerged int) *Overlay

WithMerged is called by Meta.ApplyMerge

func (*Overlay) WithSaved

func (ov *Overlay) WithSaved(bt SaveResult) *Overlay

WithSaved returns a new Overlay, combining the current state (ov) with the updated btree (in ov2)

func (*Overlay) Write

func (ov *Overlay) Write(w *stor.Writer)

type Range

type Range = iterator.Range

type SaveResult

type SaveResult = *btree.T

Directories

Path Synopsis
Package ixbuf defines an ordered list ixbuf.T with a mutating Insert and a immutable persistent Merge.
Package ixbuf defines an ordered list ixbuf.T with a mutating Insert and a immutable persistent Merge.
Package ixkey handles specifying and encoding index key strings that are directly comparable.
Package ixkey handles specifying and encoding index key strings that are directly comparable.

Jump to

Keyboard shortcuts

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