nativeadapter

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2026 License: Apache-2.0 Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package nativeadapter bridges the public index API to native owner queries.

Index

Constants

View Source
const DefaultMaxTerms uint64 = ^uint64(0)

DefaultMaxTerms preserves the existing product contract for fields whose dictionaries exceed a caller-selected budget. Callers that need a bounded expansion must set SearcherOptions.MaxTerms explicitly; the production default does not silently reject valid high-cardinality fields.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	Owner *native.Owner
}

Adapter translates public index documents to native owner batches.

func (*Adapter) Acquire

func (a *Adapter) Acquire(ctx context.Context) (*native.ReadView, error)

Acquire pins one native read view for query operations.

func (*Adapter) Batch

func (a *Adapter) Batch(ctx context.Context, batch index.Batch) error

Batch admits documents through the native owner.

func (*Adapter) MatchField

func (a *Adapter) MatchField(ctx context.Context, view *native.ReadView, request native.FieldRequest) ([]native.QueryHit, error)

MatchField executes bounded indexed-field presence matching.

func (*Adapter) MatchRange

func (a *Adapter) MatchRange(ctx context.Context, view *native.ReadView, request native.RangeRequest) ([]native.QueryHit, error)

MatchRange executes bounded encoded range matching.

func (*Adapter) MatchTerms

func (a *Adapter) MatchTerms(ctx context.Context, view *native.ReadView, request native.TermSetRequest) ([]native.QueryHit, error)

MatchTerms executes exact term membership on one pinned view.

func (*Adapter) NewSearcher

func (a *Adapter) NewSearcher(ctx context.Context, options SearcherOptions) (*Searcher, error)

NewSearcher acquires one immutable native view for the request. Callers must close the returned searcher after consuming all iterators.

type RootLease

type RootLease interface {
	Validate() error
	ValidatePath(string) error
}

RootLease is the database-owned capability required for native publication.

type Searcher

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

Searcher binds one request context and one immutable native ReadView. The view remains pinned until Close; no method opens a legacy search reader.

func (*Searcher) Close

func (s *Searcher) Close() error

Close releases the request's immutable view.

func (*Searcher) Iterator

func (s *Searcher) Iterator(
	ctx context.Context, fieldKey index.FieldKey, termRange index.RangeOpts,
	order modelv1.Sort, pageSize int,
) (index.FieldIterator[*index.DocumentResult], error)

Iterator creates a page-backed cursor for one series and optional encoded field range. It does not materialize all matching documents.

func (*Searcher) Match

func (s *Searcher) Match(fieldKey index.FieldKey, matches []string, options *modelv1.Condition_MatchOption) (posting.List, posting.List, error)

Match performs analyzed any/all term matching under the field's series and time constraints. Analysis is done before entering the native package.

func (*Searcher) MatchField

func (s *Searcher) MatchField(fieldKey index.FieldKey) (posting.List, posting.List, error)

MatchField returns every document in the field's series/time scope, matching the legacy engine's Range-with-empty-options contract: it is a scope scan, not a field-presence check. A document that never set the field is still returned (its sort position is the cursor's "missing" sentinel); the stream NOT filter relies on this to treat "field absent" as satisfying a negated HAVING/EQ condition, the same way the legacy index always did.

func (*Searcher) MatchTerms

func (s *Searcher) MatchTerms(field index.Field) (posting.List, posting.List, error)

MatchTerms returns exact term membership for one field value.

func (*Searcher) Range

func (s *Searcher) Range(fieldKey index.FieldKey, options index.RangeOpts) (posting.List, posting.List, error)

Range performs bounded encoded range membership. An empty range means indexed-field presence, matching the public index contract.

func (*Searcher) Sort

func (s *Searcher) Sort(
	ctx context.Context, seriesIDs []common.SeriesID, fieldKey index.FieldKey,
	order modelv1.Sort, timeRange *timestamp.TimeRange, pageSize int,
) (index.FieldIterator[*index.DocumentResult], error)

Sort returns a page-backed native sort cursor. Series IDs are represented as one bounded OR selection and the timestamp range is evaluated inside the pinned native view.

type SearcherOptions

type SearcherOptions struct {
	MaxTerms      uint64
	MaxCandidates uint64
	// AsyncPersistence permits Batch to return after native publication but
	// before the immutable root has been durably persisted. The default is
	// synchronous, matching the historical writer's safe default.
	AsyncPersistence bool
	// PersistInterval spaces background persists when AsyncPersistence is
	// set; see native.OwnerOptions.PersistInterval.
	PersistInterval time.Duration
	// TimeMetrics receives time-range pruning counts from every query the
	// owner NewStore creates serves; see native.OwnerOptions.TimeMetrics. It
	// is read only by NewStore, not by NewSearcher.
	TimeMetrics native.TimeMetrics
}

SearcherOptions supplies the mandatory native budgets for dictionary expansion and candidate materialization. A zero MaxTerms is rejected by NewSearcher rather than silently turning MatchField into an unbounded walk.

type Store

type Store struct {
	Owner *native.Owner
	// contains filtered or unexported fields
}

Store is the narrow production owner seam. It intentionally does not implement index.Store: query ownership is explicit through NewSearcher and iterators retain their pinned view until Close.

func NewStore

func NewStore(path string, lease RootLease, options SearcherOptions) (*Store, error)

NewStore creates a native owner under a database-owned lease.

func (*Store) Activity

func (s *Store) Activity() (uint64, uint64)

Activity returns the owner's admitted-document and acquired-view counters.

func (*Store) Batch

func (s *Store) Batch(ctx context.Context, batch index.Batch) error

Batch writes one native batch while preserving product document semantics.

func (*Store) Close

func (s *Store) Close() error

Close drains native persistence and releases the owner lease reference.

func (*Store) EnableExternalSegments

func (s *Store) EnableExternalSegments() (index.ExternalSegmentStreamer, error)

EnableExternalSegments forwards the native staged-segment capability.

func (*Store) NewSearcher

func (s *Store) NewSearcher(ctx context.Context) (*Searcher, error)

NewSearcher pins one immutable view for the request.

func (*Store) Sort

func (s *Store) Sort(ctx context.Context, seriesIDs []common.SeriesID, fieldKey index.FieldKey,
	order modelv1.Sort, timeRange *timestamp.TimeRange, pageSize int,
) (index.FieldIterator[*index.DocumentResult], error)

Sort creates an iterator which owns the request searcher until Close.

func (*Store) Stats

func (s *Store) Stats() (int64, int64)

Stats returns current live document count and native bytes.

func (*Store) TakeFileSnapshot

func (s *Store) TakeFileSnapshot(destination string) error

TakeFileSnapshot copies the current immutable native root.

Jump to

Keyboard shortcuts

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