peapod

package
v0.44.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const Type = "peapod"

Type is peapod storage type used in logs and configuration.

Variables

This section is empty.

Functions

This section is empty.

Types

type Peapod deprecated

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

Peapod provides storage for relatively small NeoFS binary object (peas). Peapod is a single low-level key/value database optimized to work with big number of stored units.

Deprecated: Use fstree.FSTree instead.

func New

func New(path string, perm fs.FileMode, flushInterval time.Duration) *Peapod

New creates new Peapod instance to be located at the given path with specified permissions.

Specified flush interval MUST be positive (see Init).

Note that resulting Peapod is NOT ready-to-go:

  • configure compression first (SetCompressor method)
  • then open the instance (Open method). Opened Peapod must be finally closed
  • initialize internal database structure (Init method). May be skipped for read-only usage

Any other usage is unsafe and may lead to panic.

func (*Peapod) Close

func (x *Peapod) Close() error

Close syncs data and closes the database.

func (*Peapod) Delete

func (x *Peapod) Delete(addr oid.Address) error

Delete removes data associated with the given object address from the underlying database. Delete returns apistatus.ErrObjectNotFound if object is missing.

Put returns common.ErrReadOnly if Peadpod is read-only.

func (*Peapod) Exists

func (x *Peapod) Exists(addr oid.Address) (bool, error)

Exists checks presence of the object in the underlying database by the given address.

func (*Peapod) Get

func (x *Peapod) Get(addr oid.Address) (*objectSDK.Object, error)

Get reads data from the underlying database by the given object address. Returns apistatus.ErrObjectNotFound if object is missing in the Peapod.

func (*Peapod) GetBytes added in v0.41.0

func (x *Peapod) GetBytes(addr oid.Address) ([]byte, error)

GetBytes reads object from the Peapod by address into memory buffer in a canonical NeoFS binary format. Returns apistatus.ObjectNotFound if object is missing.

func (*Peapod) GetRange

func (x *Peapod) GetRange(addr oid.Address, from uint64, length uint64) ([]byte, error)

GetRange works like Get but reads specific payload range.

func (*Peapod) Init

func (x *Peapod) Init() error

Init initializes internal structure of the underlying database and runs flushing routine. The routine writes data batches into disk once per time interval configured in New.

func (*Peapod) Iterate

func (x *Peapod) Iterate(objHandler func(addr oid.Address, data []byte, id []byte) error, errorHandler func(addr oid.Address, err error) error) error

Iterate iterates over all objects stored in the underlying database and passes them into objHandler. Errors are passed into errorHandler if it's specified. If error is returned from handlers iteration stops.

Use IterateAddresses to iterate over keys only.

func (*Peapod) IterateAddresses

func (x *Peapod) IterateAddresses(f func(addr oid.Address) error, ignoreErrors bool) error

IterateAddresses iterates over all objects stored in the underlying database and passes their addresses into f. If f returns an error, IterateAddresses returns it and breaks. ignoreErrors allows to continue if internal errors happen.

func (*Peapod) Open

func (x *Peapod) Open(readOnly bool) error

Open opens underlying database in the specified mode.

func (*Peapod) Path

func (x *Peapod) Path() string

func (*Peapod) Put

func (x *Peapod) Put(addr oid.Address, data []byte) error

Put saves given data in the underlying database by specified object address. The data can be anything, but in practice a binary NeoFS object is expected. Operation is executed within provided context: if the context is done, Put returns its error (in this case data may be saved).

Put returns common.ErrReadOnly if Peadpod is read-only.

func (*Peapod) SetCompressor

func (x *Peapod) SetCompressor(cc *compression.Config)

func (*Peapod) SetLogger added in v0.44.0

func (x *Peapod) SetLogger(l *zap.Logger)

SetLogger sets logger. It is used after the shard ID was generated to use it in logs.

func (*Peapod) Type

func (x *Peapod) Type() string

Jump to

Keyboard shortcuts

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