block

package
v0.2.1 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: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LabelFilterEqual    = "="
	LabelFilterNotEqual = "!="

	NewLabelFilter = func(key, value string, eq bool) string {
		if eq {
			return fmt.Sprintf("%s%s%s", key, LabelFilterEqual, value)
		}

		return fmt.Sprintf("%s%s%s", key, LabelFilterNotEqual, value)
	}

	ParseLabelFilter = func(filter string) (LabelFilter, error) {
		eq := false
		parts := strings.Split(filter, LabelFilterNotEqual)
		if len(parts) != 2 {
			parts = strings.Split(filter, LabelFilterEqual)
			eq = true
		}
		if len(parts) != 2 {
			return LabelFilter{}, errors.New("invalid label filter")
		}

		return LabelFilter{Label: parts[0], Value: parts[1], Equal: eq}, nil
	}
)

Functions

func NewFeedVOHeap

func NewFeedVOHeap(feeds []*FeedVO) *heap.Heap[*FeedVO]

Types

type Block

type Block interface {
	component.Component
	Reload(c *Config) error

	Start() time.Time
	End() time.Time
	State() State
	TransformToCold() error
	ClearOnDisk() error

	Append(ctx context.Context, feeds ...*model.Feed) error
	Query(ctx context.Context, query QueryOptions) ([]*FeedVO, error)
	Exists(ctx context.Context, id uint64) (bool, error)
}

--- Interface code block ---

type Config

type Config struct {
	Dir           string
	FlushInterval time.Duration
	ForCreate     *ForCreateConfig
	// contains filtered or unexported fields
}

func (*Config) Validate

func (c *Config) Validate() error

type Dependencies

type Dependencies struct {
	ChunkFactory    chunk.Factory
	PrimaryFactory  primary.Factory
	InvertedFactory inverted.Factory
	VectorFactory   vector.Factory
	LLMFactory      llm.Factory
}

type Factory

--- Factory code block ---

func NewFactory

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

type FeedVO

type FeedVO struct {
	*model.Feed `json:",inline"`
	Vectors     [][]float32 `json:"-"`
	Score       float32     `json:"score,omitempty"` // Only exists when SemanticFilter is set.
}

FeedVO is the feed view for query result.

type FeedVOs

type FeedVOs []*FeedVO

type ForCreateConfig

type ForCreateConfig struct {
	Start        time.Time
	Duration     time.Duration
	EmbeddingLLM string
}

type LabelFilter

type LabelFilter struct {
	Label string
	Equal bool
	Value string
}

LabelFilter defines the matcher for an item.

type QueryOptions

type QueryOptions struct {
	Query        string
	Threshold    float32
	LabelFilters []string

	Limit      int
	Start, End time.Time
	// contains filtered or unexported fields
}

func (*QueryOptions) HitTimeRangeCondition

func (q *QueryOptions) HitTimeRangeCondition(b Block) bool

func (*QueryOptions) Validate

func (q *QueryOptions) Validate() error

type State

type State string

State is the state of the block.

const (
	// StateHot means the block is writable.
	// ALL data is in memory.
	// It is the head of the block chain.
	StateHot State = "hot"
	// StateCold for read only.
	// It has indexs on disk.
	StateCold State = "cold"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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