hamt

package module
v0.0.0-...-376decb Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 18 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HashMapNodePrototype schema.TypedPrototype
	HashMapRootPrototype schema.TypedPrototype
)
View Source
var ErrMalformedHamt = errors.New("malformed HAMT node")

ErrMalformedHamt is returned whenever a block intended as a HAMT node does not conform to the expected form that a block may take. This can occur during block-load where initial validation takes place or during traversal where certain conditions are expected to be met.

Functions

func Reify

func Reify(root ipld.Node) (ipld.Node, error)

Reify looks at an ipld Node and tries to interpret it as a HAMT; if successful, it returns the synthetic Node which can be used to access the entire HAMT as if it was a single simple map.

Presumably the node given as a parameter is "raw" data model. (Nothing enforces this, however.)

Reify is one of the ways you can create a HAMT node, but it's not the only one. Reify is most suitable if you've got a bunch of data you already parsed into a tree raw. Other approaches include using the synthetic builder (if you just want to engage at the "build a map" level), or using Schemas to denote where the HAMT should appear (in which case loading data while using the schema should automatically reify the HAMT without further action required).

Types

type Bucket

type Bucket []BucketEntry

type BucketEntry

type BucketEntry struct {
	Key   []byte
	Value ipld.Node
}

type Builder

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

func NewBuilder

func NewBuilder(proto Prototype) *Builder

func (*Builder) AssignBool

func (b *Builder) AssignBool(bool) error

func (*Builder) AssignBytes

func (b *Builder) AssignBytes([]byte) error

func (*Builder) AssignFloat

func (b *Builder) AssignFloat(float64) error

func (*Builder) AssignInt

func (b *Builder) AssignInt(int64) error
func (b *Builder) AssignLink(ipld.Link) error

func (*Builder) AssignNode

func (b *Builder) AssignNode(ipld.Node) error

func (*Builder) AssignNull

func (b *Builder) AssignNull() error

func (*Builder) AssignString

func (b *Builder) AssignString(string) error

func (*Builder) BeginList

func (b *Builder) BeginList(sizeHint int64) (ipld.ListAssembler, error)

func (*Builder) BeginMap

func (b *Builder) BeginMap(sizeHint int64) (ipld.MapAssembler, error)

func (*Builder) Build

func (b *Builder) Build() ipld.Node

func (*Builder) Prototype

func (b *Builder) Prototype() ipld.NodePrototype

func (*Builder) Reset

func (b *Builder) Reset()

func (Builder) WithLinking

func (b Builder) WithLinking(system ipld.LinkSystem, proto ipld.LinkPrototype) *Builder

type Element

type Element struct {
	HashMapNode *ipld.Link
	Bucket      *Bucket
}

type FilecoinV3Prototype

type FilecoinV3Prototype struct{}

func (FilecoinV3Prototype) NewBuilder

func (p FilecoinV3Prototype) NewBuilder() ipld.NodeBuilder

type HashMapNode

type HashMapNode struct {
	Map  []byte
	Data []Element
}

type HashMapRoot

type HashMapRoot struct {
	HashAlg    multicodec.Code
	BucketSize int
	Hamt       HashMapNode
}

type Node

type Node struct {
	HashMapRoot
	// contains filtered or unexported fields
}

func Build

func Build(builder *Builder) *Node

func (*Node) AsBool

func (*Node) AsBool() (bool, error)

func (*Node) AsBytes

func (*Node) AsBytes() ([]byte, error)

func (*Node) AsFloat

func (*Node) AsFloat() (float64, error)

func (*Node) AsInt

func (*Node) AsInt() (int64, error)
func (*Node) AsLink() (ipld.Link, error)

func (*Node) AsString

func (*Node) AsString() (string, error)

func (*Node) IsAbsent

func (*Node) IsAbsent() bool

func (*Node) IsNull

func (*Node) IsNull() bool

func (*Node) Kind

func (*Node) Kind() ipld.Kind

func (*Node) Length

func (n *Node) Length() int64

func (*Node) ListIterator

func (*Node) ListIterator() ipld.ListIterator

func (*Node) LookupByIndex

func (*Node) LookupByIndex(idx int64) (ipld.Node, error)

func (*Node) LookupByNode

func (n *Node) LookupByNode(key ipld.Node) (ipld.Node, error)

func (*Node) LookupBySegment

func (n *Node) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error)

func (*Node) LookupByString

func (n *Node) LookupByString(s string) (ipld.Node, error)

func (*Node) MapIterator

func (n *Node) MapIterator() ipld.MapIterator

func (Node) Prototype

func (n Node) Prototype() datamodel.NodePrototype

func (*Node) Substrate

func (n *Node) Substrate() ipld.Node

func (Node) WithLinking

func (n Node) WithLinking(system ipld.LinkSystem, proto ipld.LinkPrototype) *Node

type Prototype

type Prototype struct {
	BitWidth   int
	BucketSize int
	// contains filtered or unexported fields
}

func (Prototype) NewBuilder

func (p Prototype) NewBuilder() ipld.NodeBuilder

func (Prototype) WithHashAlg

func (p Prototype) WithHashAlg(code multicodec.Code) Prototype

Jump to

Keyboard shortcuts

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