peapod

package
v0.41.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: GPL-3.0 Imports: 18 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

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.

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(prm common.DeletePrm) (common.DeleteRes, 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(prm common.ExistsPrm) (common.ExistsRes, error)

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

func (*Peapod) Get

func (x *Peapod) Get(prm common.GetPrm) (common.GetRes, 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(prm common.GetRangePrm) (common.GetRangeRes, 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(prm common.IteratePrm) (common.IterateRes, error)

Iterate iterates over all objects stored in the underlying database and passes them into LazyHandler or Handler. Break on f's false return.

Use IterateAddresses to iterate over keys only.

func (*Peapod) IterateAddresses

func (x *Peapod) IterateAddresses(f func(addr oid.Address) error) 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.

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(prm common.PutPrm) (common.PutRes, 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) SetReportErrorFunc

func (x *Peapod) SetReportErrorFunc(func(string, error))

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