blobstor

package
v0.58.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: GPL-3.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const IDSize = 16

IDSize is the binary shard ID size in bytes.

Variables

View Source
var ErrNoSpace = logicerr.New("no free space")

ErrNoSpace MUST be returned when there is no space to put an object on the device.

View Source
var ErrReadOnly = logicerr.New("opened as read-only")

ErrReadOnly MUST be returned for modifying operations when the storage was opened in readonly mode.

Functions

func Copy added in v0.57.0

func Copy(dst, src Storage) error

Copy copies all objects from source Storage into the destination one. If any object cannot be stored, Copy immediately fails.

func CopyBatched added in v0.57.0

func CopyBatched(dst, src Storage, batchSize int) error

CopyBatched copies all objects from source Storage into the destination one using batched API. If any batch cannot be stored, Copy immediately fails. batchSize less than or equal to 1 makes it the same as Copy.

Types

type ID added in v0.57.0

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

ID represents a shard identifier. Implements the built-in comparable interface.

func DecodeIDString added in v0.57.0

func DecodeIDString(s string) (ID, error)

DecodeIDString decodes base58 string into ID.

func NewID added in v0.57.0

func NewID() (ID, error)

NewID generates a new shard identifier.

func NewIDFromBytes added in v0.57.0

func NewIDFromBytes(v []byte) (ID, error)

NewIDFromBytes constructs ID from fixed-size raw bytes.

func (ID) Bytes added in v0.57.0

func (id ID) Bytes() []byte

Bytes returns a copy of the raw ID bytes.

func (ID) Hash added in v0.57.0

func (id ID) Hash() uint64

Hash returns the cached HRW hash.

func (ID) IsZero added in v0.57.0

func (id ID) IsZero() bool

IsZero reports whether ID is empty.

func (ID) String added in v0.57.0

func (id ID) String() string

String encodes ID into base58 form.

type PayloadRange added in v0.57.0

type PayloadRange struct {
	First  uint64
	Second uint64
	Mode   PayloadRangeMode
}

PayloadRange describes a payload range independently of its full length.

func NewPayloadRange added in v0.57.0

func NewPayloadRange(off, ln uint64) PayloadRange

NewPayloadRange returns an offset-length payload range.

func NewPayloadRangeBounds added in v0.57.0

func NewPayloadRangeBounds(first, last uint64) PayloadRange

NewPayloadRangeBounds returns a payload range with inclusive bounds.

func NewPayloadRangeFrom added in v0.57.0

func NewPayloadRangeFrom(first uint64) PayloadRange

NewPayloadRangeFrom returns a payload range from first to the payload end.

func NewPayloadRangeSuffix added in v0.57.0

func NewPayloadRangeSuffix(ln uint64) PayloadRange

NewPayloadRangeSuffix returns a payload suffix range of the given length.

func (PayloadRange) IsFull added in v0.57.0

func (r PayloadRange) IsFull() bool

IsFull checks whether payload range is set and corresponds to full payload.

func (PayloadRange) IsSet added in v0.57.0

func (r PayloadRange) IsSet() bool

IsSet reports whether the range is configured.

func (PayloadRange) Resolve added in v0.57.0

func (r PayloadRange) Resolve(payloadLen uint64) (uint64, uint64, error)

Resolve converts the range into offset-length form using the full payload length and validates the result.

func (PayloadRange) Resolved added in v0.57.0

func (r PayloadRange) Resolved(payloadLen uint64) (PayloadRange, error)

Resolved converts the range into validated offset-length form.

type PayloadRangeMode added in v0.57.0

type PayloadRangeMode uint8

PayloadRangeMode identifies the meaning of values stored in PayloadRange.

const (
	// PayloadRangeModeNone means that no payload range is set.
	PayloadRangeModeNone PayloadRangeMode = iota
	// PayloadRangeModeOffsetLength interprets values as offset and length.
	PayloadRangeModeOffsetLength
	// PayloadRangeModeBounds interprets values as inclusive first and last positions.
	PayloadRangeModeBounds
	// PayloadRangeModeFrom interprets the first value as a position to read from.
	PayloadRangeModeFrom
	// PayloadRangeModeSuffix interprets the first value as a suffix length.
	PayloadRangeModeSuffix
)

type PutStream added in v0.58.0

type PutStream interface {
	io.WriteCloser

	// WriteBuffers sequentially writes all L bytes from bs to the underlying data
	// stream. It returns the number of bytes written from p (0 <= n <= L) and any
	// error encountered that caused the write to stop early. WriteBuffers must
	// return a non-nil error if it returns n < L. WriteBuffers must not bs and its
	// elements, even temporarily.
	//
	// Implementations must not retain bs and its elements.
	WriteBuffers(bs [][]byte) (int, error)
}

PutStream streams object into Storage.

type Storage added in v0.57.0

type Storage interface {
	Open(readOnly bool) error
	Init(ID) error
	Close() error

	Type() string
	Path() string
	ShardID() ID

	// GetBytes reads object by address into memory buffer in a canonical NeoFS
	// binary format. Returns [apistatus.ObjectNotFound] if object is missing.
	GetBytes(oid.Address) ([]byte, error)
	Get(oid.Address) (*object.Object, error)
	GetRangeStream(addr oid.Address, rng PayloadRange, readHeader bool) (*object.Object, uint64, io.ReadCloser, error)
	GetStream(oid.Address) (*object.Object, io.ReadSeekCloser, error)
	Head(oid.Address) (*object.Object, error)
	ReadHeader(oid.Address, []byte) (int, error)
	ReadObject(oid.Address, []byte) (int, io.ReadCloser, error)
	ReadPayloadRange(oid.Address, uint64, uint64, []byte, func([]byte) error) (io.ReadCloser, error)
	ReadObjectParts(buf []byte, addr oid.Address, rng PayloadRange, interceptHeaderBinaryFn func([]byte) error) (int, io.ReadCloser, error)
	Exists(oid.Address) (bool, error)
	Put(oid.Address, []byte) error
	InitPut(oid.Address, uint64, uint64, io.WriterTo) (PutStream, func(), error)
	PutBatch(map[oid.Address][]byte) error
	Delete(oid.Address) error
	Iterate(func(oid.Address, []byte) error, func(oid.Address, error) error) error
	IterateAddresses(func(oid.Address) error, bool) error
}

Storage represents key-value object storage. It is used as a building block for a blobstor of a shard.

Directories

Path Synopsis
Package fstree implements a storage subsystem that saves objects as files in FS tree.
Package fstree implements a storage subsystem that saves objects as files in FS tree.
internal

Jump to

Keyboard shortcuts

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