hamt

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: Apache-2.0, MIT Imports: 10 Imported by: 10

Documentation

Index

Constants

View Source
const (
	// ErrNotProtobuf indicates an error attempting to load a HAMT from a non-protobuf node
	ErrNotProtobuf errorType = "node was not a protobuf node"
	// ErrNotUnixFSNode indicates an error attempting to load a HAMT from a generic protobuf node
	ErrNotUnixFSNode errorType = "node was not a UnixFS node"
	// ErrInvalidChildIndex indicates there is no link to load for the given child index
	ErrInvalidChildIndex errorType = "invalid index passed to operate children (likely corrupt bitfield)"
	// ErrHAMTTooDeep indicates we attempted to load from a HAMT node that went past the depth of the tree
	ErrHAMTTooDeep errorType = "sharded directory too deep"
	// ErrInvalidHashType indicates the HAMT node's hash function is unsupported (must be Murmur3)
	ErrInvalidHashType errorType = "only murmur3 supported as hash function"
	// ErrNoDataField indicates the HAMT node's UnixFS structure lacked a data field, which is
	// where a bit mask is stored
	ErrNoDataField errorType = "'Data' field not present"
	// ErrNoFanoutField indicates the HAMT node's UnixFS structure lacked a fanout field, which is required
	ErrNoFanoutField errorType = "'Fanout' field not present"
	// ErrHAMTSizeInvalid indicates the HAMT's size property was not an exact power of 2
	ErrHAMTSizeInvalid errorType = "hamt size should be a power of two"
	// ErrMissingLinkName indicates a link in a HAMT had no Name property (required for all HAMTs)
	ErrMissingLinkName errorType = "missing link name"
)
View Source
const (
	// HashMurmur3 is the multiformats identifier for Murmur3
	HashMurmur3 uint64 = 0x22
)

Variables

This section is empty.

Functions

func MatchKey

func MatchKey(pbLink dagpb.PBLink, key string, maxPadLen int) bool

func NewUnixFSHAMTShard

func NewUnixFSHAMTShard(ctx context.Context, substrate dagpb.PBNode, data data.UnixFSData, lsys *ipld.LinkSystem) (ipld.Node, error)

NewUnixFSHAMTShard attempts to construct a UnixFSHAMTShard node from the base protobuf node plus a decoded UnixFSData structure

func NewUnixFSHAMTShardWithPreload added in v1.5.1

func NewUnixFSHAMTShardWithPreload(ctx context.Context, substrate dagpb.PBNode, data data.UnixFSData, lsys *ipld.LinkSystem) (ipld.Node, error)

NewUnixFSHAMTShardWithPreload attempts to construct a UnixFSHAMTShard node from the base protobuf node plus a decoded UnixFSData structure, and then iterate through and load the full set of hamt shards.

Types

type ErrInvalidLinkName

type ErrInvalidLinkName struct {
	Name string
}

ErrInvalidLinkName indicates a link's name was too short for a HAMT

func (ErrInvalidLinkName) Error

func (e ErrInvalidLinkName) Error() string

type UnixFSHAMTShard

type UnixFSHAMTShard = *_UnixFSHAMTShard

UnixFSHAMTShared is an IPLD Prime Node that provides a read interface to a UnixFS HAMT

func AttemptHAMTShardFromNode

func AttemptHAMTShardFromNode(ctx context.Context, nd ipld.Node, lsys *ipld.LinkSystem) (UnixFSHAMTShard, error)

AttemptHAMTShardFromNode attempts to read a HAMT shard from a general protobuf node

func (UnixFSHAMTShard) AsBool

func (n UnixFSHAMTShard) AsBool() (bool, error)

func (UnixFSHAMTShard) AsBytes

func (n UnixFSHAMTShard) AsBytes() ([]byte, error)

func (UnixFSHAMTShard) AsFloat

func (n UnixFSHAMTShard) AsFloat() (float64, error)

func (UnixFSHAMTShard) AsInt

func (n UnixFSHAMTShard) AsInt() (int64, error)
func (n UnixFSHAMTShard) AsLink() (ipld.Link, error)

func (UnixFSHAMTShard) AsString

func (n UnixFSHAMTShard) AsString() (string, error)

func (UnixFSHAMTShard) FieldData

func (n UnixFSHAMTShard) FieldData() dagpb.MaybeBytes
func (n UnixFSHAMTShard) FieldLinks() dagpb.PBLinks

func (UnixFSHAMTShard) IsAbsent

func (n UnixFSHAMTShard) IsAbsent() bool

func (UnixFSHAMTShard) IsNull

func (n UnixFSHAMTShard) IsNull() bool

func (UnixFSHAMTShard) Iterator

func (n UnixFSHAMTShard) Iterator() *iter.UnixFSDir__Itr

func (UnixFSHAMTShard) Kind

func (n UnixFSHAMTShard) Kind() ipld.Kind

func (UnixFSHAMTShard) Length

func (n UnixFSHAMTShard) Length() int64

Length returns the length of a list, or the number of entries in a map, or -1 if the node is not of list nor map kind.

func (UnixFSHAMTShard) ListIterator

func (n UnixFSHAMTShard) ListIterator() ipld.ListIterator

ListIterator returns an iterator which yields key-value pairs traversing the node. If the node kind is anything other than a list, nil will be returned.

The iterator will yield every entry in the list; that is, it can be expected that itr.Next will be called node.Length times before itr.Done becomes true.

func (UnixFSHAMTShard) Lookup

func (n UnixFSHAMTShard) Lookup(key dagpb.String) dagpb.Link

func (UnixFSHAMTShard) LookupByIndex

func (n UnixFSHAMTShard) LookupByIndex(idx int64) (ipld.Node, error)

func (UnixFSHAMTShard) LookupByNode

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

func (UnixFSHAMTShard) LookupBySegment

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

func (UnixFSHAMTShard) MapIterator

func (n UnixFSHAMTShard) MapIterator() ipld.MapIterator

func (UnixFSHAMTShard) Prototype

func (n UnixFSHAMTShard) Prototype() ipld.NodePrototype

func (UnixFSHAMTShard) Representation

func (n UnixFSHAMTShard) Representation() ipld.Node

func (UnixFSHAMTShard) Substrate

func (n UnixFSHAMTShard) Substrate() ipld.Node

func (UnixFSHAMTShard) Type

func (UnixFSHAMTShard) Type() schema.Type

satisfy schema.TypedNode

Jump to

Keyboard shortcuts

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