chunk

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 6, 2025 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Path is the path to the chunk file.
	// If the file does not exist, it will be created.
	// If the file exists, it will be reloaded.
	Path string
	// ReadonlyAtFirst indicates whether the file should be readonly at first.
	// If file of path does not exist, it cannot be true.
	ReadonlyAtFirst bool
}

Config for a chunk file.

func (*Config) Validate

func (c *Config) Validate() (fileExists bool, err error)

type Dependencies

type Dependencies struct{}

type Factory

--- Factory code block ---

func NewFactory

func NewFactory(mockOn ...component.MockOption) Factory

type Feed

type Feed struct {
	*model.Feed
	Vectors [][]float32
}

Feed is the feed model in the chunk file.

type File

type File interface {
	component.Component

	// EnsureReadonly ensures the file is readonly (can not Append).
	// It should be fast when the file already is readonly.
	// It will ensure the writeonly related resources are closed,
	// and open the readonly related resources, such as mmap to save memory.
	EnsureReadonly(ctx context.Context) (err error)
	Count(ctx context.Context) (count uint32)

	// Append appends feeds to the file.
	// onSuccess is called when the feed is appended successfully (synchronously).
	// The offset is the offset of the feed in the file.
	// !!! It doesn't buffer the data between requests, so the caller should buffer the feeds to avoid high I/O.
	Append(ctx context.Context, feeds []*Feed, onSuccess func(feed *Feed, offset uint64) error) (err error)

	// Read reads a feed from the file.
	Read(ctx context.Context, offset uint64) (feed *Feed, err error)

	// Range ranges over all feeds in the file.
	Range(ctx context.Context, iter func(feed *Feed, offset uint64) (err error)) (err error)
}

File is the interface for a chunk file. Concurrent safe.

Jump to

Keyboard shortcuts

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