utils

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMetadataNotFound indicates the metadata doesn't exist
	ErrMetadataNotFound = errors.New("metadata not found")

	// ErrAlreadyCompacted indicates the file has already been compacted to a segment
	ErrAlreadyCompacted = errors.New("already compacted")

	// ErrNotRawFile indicates the value is not a raw file (could be inline or other type)
	ErrNotRawFile = errors.New("not raw file")

	// ErrFilePathMismatch indicates the metadata points to a different file
	ErrFilePathMismatch = errors.New("file path mismatch")

	// ErrMalformedIndexRow indicates the compaction index row is malformed
	ErrMalformedIndexRow = errors.New("malformed index row")

	// ErrFileNotExist indicates the file doesn't exist on disk
	ErrFileNotExist = errors.New("file does not exist")

	// ErrEntryStale indicates a sync entry is stale (metadata changed or missing)
	ErrEntryStale = errors.New("sync entry is stale")

	// ErrFileCorrupted indicates a file is corrupted (size mismatch)
	ErrFileCorrupted = errors.New("file corrupted: size mismatch")
)

Sentinel errors for stale file validation

Functions

func GetMetadata

func GetMetadata(meta *metadata.MetaDB, key string) (*pb.ValueMessage, error)

GetMetadata fetches metadata from the metaDB

func HashString

func HashString(s string) uint32

HashString returns a simple hash of a string for partitioning work

func ValidateFileEntry

func ValidateFileEntry(metadata *pb.ValueMessage, filePath string, context string, key string) error

ValidateFileEntry checks if a file entry is valid by validating against provided metadata. Returns nil if the entry is valid, or a specific error if it's stale: - ErrMetadataNotFound: The metadata is nil (doesn't exist) - ErrAlreadyCompacted: The file has been compacted to a segment - ErrNotRawFile: The value is not a raw file (could be inline or other type) - ErrFilePathMismatch: The metadata points to a different file path

func WrapError

func WrapError(op string, path string, err error) error

WrapError wraps an error with an operation and path.

Types

type FileSizeMismatchError

type FileSizeMismatchError struct {
	Key          string
	FilePath     string
	ActualSize   int64
	ExpectedSize int64
}

FileSizeMismatchError represents a file size mismatch error with details

func (*FileSizeMismatchError) Error

func (e *FileSizeMismatchError) Error() string

func (*FileSizeMismatchError) Is

func (e *FileSizeMismatchError) Is(target error) bool

Jump to

Keyboard shortcuts

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