object

package
v0.48.3 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: GPL-3.0 Imports: 27 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnreachableQuery is returned when no object ever matches a particular
	// search query.
	ErrUnreachableQuery = errors.New("unreachable query")

	// MetaAttributeDelimiter is attribute key and value separator used in metadata DB.
	MetaAttributeDelimiter = []byte{0x00}
)
View Source
var ErrInvalidSearchQuery = errors.New("invalid search query")

ErrInvalidSearchQuery is returned when some object search query is invalid.

View Source
var ErrNoExpiration = errors.New("missing expiration epoch attribute")

ErrNoExpiration means no expiration was set.

Functions

func AddressOf added in v0.28.0

func AddressOf(obj *object.Object) oid.Address

AddressOf returns the address of the object.

func BigIntBytes added in v0.46.0

func BigIntBytes(n *big.Int) []byte

BigIntBytes returns integer's raw representation. Int must belong to [-maxUint256; maxUint256] interval. Result's length is fixed: 33 bytes, first describes sign.

func CalculateCursor added in v0.46.0

func CalculateCursor(filt *object.SearchFilter, lastItem client.SearchResultItem) ([]byte, error)

CalculateCursor calculates cursor for the given last search result item.

func EncodeReplicationMetaInfo added in v0.44.0

func EncodeReplicationMetaInfo(cID cid.ID, oID, firstPart, previousPart oid.ID, pSize uint64, typ objectsdk.Type,
	deleted, locked []oid.ID, vub uint64, magicNumber uint32) []byte

EncodeReplicationMetaInfo uses NEO's map (strict order) serialized format as a raw representation of object's meta information.

This (ordered) format is used (keys are strings):

"cid": _raw_ container ID (32 bytes)
"oid": _raw_ object ID (32 bytes)
"size": payload size
"validUntil": last valid block number for meta information
"network": network magic
"firstPart": [OPTIONAL] _raw_ object ID (32 bytes)
"previousPart": [OPTIONAL] _raw_ object ID (32 bytes)
"deleted": [OPTIONAL] array of _raw_ object IDs
"locked": [OPTIONAL] array of _raw_ object IDs
"type": [OPTIONAL] object type enumeration

func Expiration added in v0.42.1

func Expiration(obj object.Object) (uint64, error)

Expiration searches for expiration attribute in the object. Returns ErrNoExpiration if not found.

func IsIntegerSearchOp added in v0.45.0

func IsIntegerSearchOp(op object.SearchMatchType) bool

IsIntegerSearchOp reports whether given op matches integer attributes.

func MergeSearchResults added in v0.45.0

func MergeSearchResults(lim uint16, firstAttr string, cmpInt bool, sets [][]client.SearchResultItem, mores []bool) ([]client.SearchResultItem, bool, error)

MergeSearchResults merges up to lim elements from sorted search result sets into the one sorted set. Items are compared by the 1st attribute (if withAttr), and then by IDs when equal. If cmpInt is set, attributes are compared numerically. Otherwise, lexicographically. Additional booleans show whether corresponding sets can be continued. If the merged set can be continued itself, true is returned.

func MetaDataKVHandler added in v0.46.0

func MetaDataKVHandler(resHolder *SearchResult, attrGetter AttributeGetter, additionalCheck AdditionalObjectChecker, fs []SearchFilter, attrs []string, cursor *SearchCursor, count uint16) func(k, v []byte) bool

MetaDataKVHandler returns a handler that filters out and writes search results for Search NeoFS operation (see client.Client.SearchObjects for details) based on the provided arguments. resHolder must not be nil. additionalCheck may or may not be nil, it will be called once on every object that matches all the previous (filters-based) checks. fInt must have preparsed (from string attribute form) integer values from the fs. Returned handler must be called on a sorted list of key-value pairs without any pair omission and/or duplication. Pairs must be common NeoFS indexes for object header's fields. See [meta] (storage engine's package) for details.

func PreprocessSearchQuery added in v0.46.0

func PreprocessSearchQuery(fs object.SearchFilters, attrs []string, cursor string) ([]SearchFilter, *SearchCursor, error)

PreprocessSearchQuery accepts verified search filters, requested attributes along and continuation cursor, verifies the cursor and returns additional arguments to pass into [DB.Search]. If the query is valid but unreachable, ErrUnreachableQuery is returned.

func RestoreIntAttribute added in v0.46.0

func RestoreIntAttribute(b []byte) (string, error)

RestoreIntAttribute restores from raw signed uint256 format its string representation.

func VerifyHeaderForMetadata added in v0.45.2

func VerifyHeaderForMetadata(hdr object.Object) error

VerifyHeaderForMetadata checks whether given header corresponds to metadata bucket requirements and limits.

Types

type AdditionalObjectChecker added in v0.46.0

type AdditionalObjectChecker func(oid.ID) (match bool)

AdditionalObjectChecker is an additional check that may be provided to MetaDataKVHandler. `false` return value stops object from being recorded to SearchResult, `true` keeps searching without additional filtering.

type AddressWithType added in v0.36.0

type AddressWithType struct {
	Address oid.Address
	Type    object.Type
}

AddressWithType groups object address with its NeoFS object type.

type AttributeGetter added in v0.46.0

type AttributeGetter interface {
	// Get must return attribute value for a pair of object ID and attribute
	// value. (nil, nil) must be returned if value is missing. err should mean
	// only data base errors.
	Get(oID []byte, attributeKey string) (attributeValue []byte, err error)
}

AttributeGetter provides access to attributes based on database's indexes.

type ContentMeta added in v0.36.0

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

ContentMeta describes NeoFS meta information that brings object's payload if the object is one of:

  • object.TypeTombstone;
  • object.TypeLink;
  • object.TypeLock.

func (ContentMeta) Objects added in v0.36.0

func (i ContentMeta) Objects() []oid.ID

Objects returns objects that the original object's payload affects:

  • inhumed objects, if the original object is a Tombstone;
  • locked objects, if the original object is a Lock;
  • nil, if the original object is a Regular object.

type DeleteHandler added in v0.12.0

type DeleteHandler interface {
	// DeleteObjects places objects to a removal queue.
	//
	// Returns apistatus.LockNonRegularObject if at least one object
	// is locked.
	DeleteObjects(oid.Address, ...oid.Address) error
}

DeleteHandler is an interface of delete queue processor.

type FSChain added in v0.46.0

type FSChain interface {
	InvokeContainedScript(tx *transaction.Transaction, header *block.Header, _ *trigger.Type, _ *bool) (*result.Invoke, error)
}

FSChain provides base non-contract functionality of the FS chain required for FormatValidator to work.

type FormatValidator added in v0.12.0

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

FormatValidator represents an object format validator.

func NewFormatValidator added in v0.12.0

func NewFormatValidator(fsChain FSChain, netmapContract NetmapContract, opts ...FormatValidatorOption) *FormatValidator

NewFormatValidator creates, initializes and returns FormatValidator instance.

func (*FormatValidator) Validate added in v0.12.0

func (v *FormatValidator) Validate(obj *object.Object, unprepared bool) error

Validate validates object format.

Does not validate payload checksum and content. If unprepared is true, only fields set by user are validated.

Returns nil error if the object has valid structure.

func (*FormatValidator) ValidateContent added in v0.12.0

func (v *FormatValidator) ValidateContent(o *object.Object) (ContentMeta, error)

ValidateContent validates payload content according to the object type.

type FormatValidatorOption added in v0.12.0

type FormatValidatorOption func(*cfg)

FormatValidatorOption represents a FormatValidator constructor option.

func WithLockSource added in v0.38.0

func WithLockSource(e LockSource) FormatValidatorOption

WithLockSource return option to set a Locked objects source.

func WithNetState added in v0.16.0

func WithNetState(netState netmap.State) FormatValidatorOption

WithNetState returns options to set the network state interface.

func WithSplitVerifier added in v0.41.0

func WithSplitVerifier(sv SplitVerifier) FormatValidatorOption

WithSplitVerifier returns option to set a SplitVerifier.

func WithTombVerifier added in v0.41.0

func WithTombVerifier(tv TombVerifier) FormatValidatorOption

WithTombVerifier returns option to set a TombVerifier.

type LockSource added in v0.38.0

type LockSource interface {
	// IsLocked must clarify object's lock status.
	IsLocked(address oid.Address) (bool, error)
}

LockSource is a source of lock relations between the objects.

type Locker added in v0.28.0

type Locker interface {
	// Lock list of objects as locked by locker in the specified container.
	//
	// Returns apistatus.LockNonRegularObject if at least object in locked
	// list is irregular (not type of REGULAR).
	Lock(idCnr cid.ID, locker oid.ID, locked []oid.ID) error
}

Locker is an object lock storage interface.

type NetmapContract added in v0.46.0

type NetmapContract interface {
	// GetEpochBlock returns FS chain height when given NeoFS epoch was ticked.
	GetEpochBlock(epoch uint64) (uint32, error)
}

NetmapContract represents Netmap contract deployed in the FS chain required for FormatValidator to work.

type SearchCursor added in v0.46.0

type SearchCursor struct {
	// PrimarySeekKey defines the last key that was already handled.
	PrimarySeekKey []byte
	// PrimaryKeysPrefix defines what part of primary key is prefix.
	PrimaryKeysPrefix []byte
}

SearchCursor is a cursor used for continuous search in the meta indexes database.

type SearchFilter added in v0.46.0

type SearchFilter struct {
	object.SearchFilter
	// AutoMatch means every existing value is acceptable for filters.
	AutoMatch bool
	// Parsed is parsed integer value from filter.
	Parsed *big.Int
	// RawValue is raw attribute value in the original form.
	Raw []byte
}

SearchFilter wraps regular object.SearchFilter with additional metadata for numeric matches.

type SearchResult added in v0.46.0

type SearchResult struct {
	Objects             []client.SearchResultItem
	UpdatedSearchCursor []byte
	Err                 error
}

SearchResult is a MetaDataKVHandler operation's results holder.

type SplitVerifier added in v0.41.0

type SplitVerifier interface {
	// VerifySplit must verify split hierarchy and return any error that did
	// not allow processing the chain. Must break (if possible) any internal
	// computations if context is done. The second and the third args are the
	// first part's address used as a chain unique identifier that also must
	// be checked. The fourth arg is guaranteed to be the full list from the
	// link's payload without item order change.
	VerifySplit(context.Context, cid.ID, oid.ID, []object.MeasuredObject) error
}

SplitVerifier represent split validation unit. It verifies V2 split chains based on the link object's payload (list of ID+ObjectSize pairs).

type TombVerifier added in v0.41.0

type TombVerifier interface {
	// VerifyTomb must verify tombstone payload. Must break (if possible) any internal
	// computations if context is done.
	VerifyTomb(ctx context.Context, cnr cid.ID, t object.Tombstone) error

	// VerifyTombStoneWithoutPayload must verify API 2.18+ tombstones without
	// payload.
	VerifyTombStoneWithoutPayload(ctx context.Context, t object.Object) error
}

TombVerifier represents tombstone validation unit. It verifies tombstone object received by the node.

Jump to

Keyboard shortcuts

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