shard

package
v0.0.0-...-a4f5bd3 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const KeyCharsASCII = "ascii"
View Source
const MaxKeySize = 4096
View Source
const Version = 2

Variables

This section is empty.

Functions

func IsPrintableASCII

func IsPrintableASCII(s string) bool

func Marshal

func Marshal(s Shard) ([]byte, error)

Marshal serializes a Shard or a RootShard to CBOR encoded bytes.

func MarshalBlock

func MarshalBlock[S Shard](s S) (block.BlockView[S], error)

MarshalBlock serializes the Shard to CBOR encoded bytes, takes the sha2-256 hash of the data, constructs a CID and returns a block.Block.

Types

type BlockView

type BlockView interface {
	block.BlockView[Shard]
}

func AsBlock

func AsBlock[S Shard](b block.BlockView[S]) BlockView

type Diff

type Diff struct {
	Additions []BlockView
	Removals  []BlockView
}

type Entry

type Entry interface {
	Key() string
	Value() Value
}

Entry is a single key/value entry within a shard.

func NewEntry

func NewEntry(k string, v Value) Entry

func PutEntry

func PutEntry(target []Entry, newEntry Entry) []Entry

type Fetcher

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

func NewFetcher

func NewFetcher(blocks block.Fetcher) *Fetcher

func (*Fetcher) Get

func (f *Fetcher) Get(ctx context.Context, link ipld.Link) (BlockView, error)

func (*Fetcher) GetRoot

func (f *Fetcher) GetRoot(ctx context.Context, link ipld.Link) (RootBlockView, error)

type RootBlockView

type RootBlockView interface {
	block.BlockView[RootShard]
}

type RootShard

type RootShard interface {
	Shard
	// Version is the shard compatibility version.
	Version() int64
	// KeyChars are the characters allowed in keys, referring to a known character
	// set. e.g. "ascii" refers to the printable ASCII characters in the code
	// range 32-126.
	KeyChars() string
	// MaxKeySize is the maximum key size in bytes - default 4096 bytes.
	MaxKeySize() int64
}

func NewRoot

func NewRoot(entries []Entry) RootShard

func UnmarshalRoot

func UnmarshalRoot(b []byte) (RootShard, error)

UnmarshalRoot deserializes CBOR encoded bytes to a RootShard.

type Shard

type Shard interface {
	// Prefix is the key prefix from the root to this shard.
	Prefix() string
	Entries() []Entry
}

func New

func New(prefix string, entries []Entry) Shard

func Unmarshal

func Unmarshal(b []byte) (Shard, error)

Unmarshal deserializes CBOR encoded bytes to a Shard.

type Value

type Value interface {
	// Shard is a link to a shard, which may be nil if this value is a link to
	// user data.
	Shard() ipld.Link
	// Value is a link to user data, which may be nil if this value is a link to
	// a shard.
	Value() ipld.Link
}

func NewValue

func NewValue(val ipld.Link, shard ipld.Link) Value

Jump to

Keyboard shortcuts

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