amt

package module
v2.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: Apache-2.0, MIT Imports: 9 Imported by: 3

README

go-amt-ipld

Array Mapped Trie (Persistent Vector) implementation using go-ipld

License

Dual MIT and Apache 2

Documentation

Index

Constants

View Source
const MaxIndex = uint64(1<<maxIndexBits) - 1

MaxIndex is the maximum index for elements in the AMT. This is currently 1^63 (max int) because the width is 8. That means every "level" consumes 3 bits from the index, and 63/3 is a nice even 21

Variables

This section is empty.

Functions

func FromArray

func FromArray(ctx context.Context, bs cbor.IpldStore, vals []cbg.CBORMarshaler) (cid.Cid, error)

Types

type ErrNotFound

type ErrNotFound struct {
	Index uint64
}

func (ErrNotFound) Error

func (e ErrNotFound) Error() string

func (ErrNotFound) NotFound

func (e ErrNotFound) NotFound() bool

type Node

type Node struct {
	Bmap   [bitfieldSize]byte
	Links  []cid.Cid
	Values []*cbg.Deferred
	// contains filtered or unexported fields
}

func (*Node) Flush

func (n *Node) Flush(ctx context.Context, bs cbor.IpldStore, depth int) error

func (*Node) MarshalCBOR

func (t *Node) MarshalCBOR(w io.Writer) error

func (*Node) UnmarshalCBOR

func (t *Node) UnmarshalCBOR(r io.Reader) error

type Root

type Root struct {
	Height uint64
	Count  uint64
	Node   Node
	// contains filtered or unexported fields
}

func LoadAMT

func LoadAMT(ctx context.Context, bs cbor.IpldStore, c cid.Cid) (*Root, error)

func NewAMT

func NewAMT(bs cbor.IpldStore) *Root

func (*Root) BatchDelete

func (r *Root) BatchDelete(ctx context.Context, indices []uint64) error

func (*Root) BatchSet

func (r *Root) BatchSet(ctx context.Context, vals []cbg.CBORMarshaler) error

func (*Root) Delete

func (r *Root) Delete(ctx context.Context, i uint64) error

func (*Root) FirstSetIndex

func (r *Root) FirstSetIndex(ctx context.Context) (uint64, error)

func (*Root) Flush

func (r *Root) Flush(ctx context.Context) (cid.Cid, error)

func (*Root) ForEach

func (r *Root) ForEach(ctx context.Context, cb func(uint64, *cbg.Deferred) error) error

func (*Root) ForEachAt

func (r *Root) ForEachAt(ctx context.Context, start uint64, cb func(uint64, *cbg.Deferred) error) error

func (*Root) Get

func (r *Root) Get(ctx context.Context, i uint64, out interface{}) error

func (*Root) MarshalCBOR

func (t *Root) MarshalCBOR(w io.Writer) error

func (*Root) Set

func (r *Root) Set(ctx context.Context, i uint64, val interface{}) error

func (*Root) Subtract

func (r *Root) Subtract(ctx context.Context, or *Root) error

Subtract removes all elements of 'or' from 'r'

func (*Root) UnmarshalCBOR

func (t *Root) UnmarshalCBOR(r io.Reader) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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