model

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package model defines the structures and interfaces for query options and results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Name   string
	Values []*modelv1.FieldValue
}

Field is a field name and its values.

type MeasureAgg added in v0.11.0

type MeasureAgg struct {
	FieldName string
	Func      modelv1.AggregationFunction
}

MeasureAgg describes a single aggregation for a measure query. v1 supports one aggregation per query — matches the singular QueryRequest.agg proto field. FieldName must reference a field in MeasureQueryOptions.FieldProjection.

type MeasureBatch added in v0.11.0

type MeasureBatch struct {
	// Schema describes the column layout. Tags[i] / Fields[i] entries are
	// indexed via Schema.TagIndex / Schema.FieldIndex.
	Schema *vectorized.BatchSchema

	// Per-row metadata columns. Length equals the row count.
	Timestamps []int64
	Versions   []int64
	ShardIDs   []common.ShardID
	SeriesIDs  []common.SeriesID

	// Typed tag and field columns. Tags[i] corresponds to the i-th
	// RoleTag entry in Schema.Columns (in declaration order); same for
	// Fields. Each column reports the same Len() as len(Timestamps).
	Tags   []vectorized.Column
	Fields []vectorized.Column

	// SeriesBoundaries records exclusive end-of-series row indices for
	// multi-series batches. nil or empty when the batch contains a single
	// series.
	SeriesBoundaries []int
}

MeasureBatch is a single columnar batch flowing out of the storage layer.

Row count is the length of Timestamps. Versions, ShardIDs and SeriesIDs have the same length. Tags and Fields are parallel column slices whose indices correspond to Schema.Columns entries with RoleTag / RoleField respectively (the column at Tags[i] aligns with the i-th tag slot in Schema, in declaration order; same for Fields[i]).

SeriesBoundaries records the exclusive end-of-series row indices within the batch. For example, a batch holding 100 rows of series A followed by 200 rows of series B reports SeriesBoundaries = [100, 300]. Empty (nil or zero-length) means "single series" — every row in the batch belongs to the same series.

func AcquireMeasureBatch added in v0.11.0

func AcquireMeasureBatch(schema *vectorized.BatchSchema, capacity int) *MeasureBatch

AcquireMeasureBatch returns a recycled *MeasureBatch wired to schema with Tag / Field column slots pre-acquired from the per-type column pool. The parallel metadata slices are truncated to length 0 and grown to capacity if needed; columns inherit whatever capacity their pooled instance last held (at least capacity). Callers must call Release exactly once when done with the batch.

func (*MeasureBatch) Release added in v0.11.0

func (b *MeasureBatch) Release()

Release returns the batch's Tag / Field columns to the per-type pool and the batch itself to the MeasureBatch pool. Parallel metadata slices keep their backing arrays (truncated to length 0) so the next Acquire can reuse them. Calling Release on a nil receiver is a no-op; calling Release twice on the same batch is a use-after-free and not supported.

func (*MeasureBatch) RowCount added in v0.11.0

func (b *MeasureBatch) RowCount() int

RowCount returns the number of rows in the batch. It reads len(Timestamps); callers must keep the parallel column lengths in sync.

type MeasureBatchResult added in v0.11.0

type MeasureBatchResult interface {
	// PullBatch returns the next batch from the underlying scan. It returns
	// (nil, nil) on EOF; (nil, err) on storage error. Once an error is
	// returned, subsequent calls must continue to return that same error
	// (sticky-error contract — matches MeasureQueryResult.Pull's
	// MeasureResult.Error semantics).
	PullBatch(ctx context.Context) (*MeasureBatch, error)

	// Release frees any resources held by the result. Idempotent.
	Release()
}

MeasureBatchResult is the columnar counterpart to MeasureQueryResult. Implementations return a *MeasureBatch carrying parallel typed slices instead of the row-shaped *modelv1.TagValue / *modelv1.FieldValue cells.

The contract is independent of MeasureQueryResult: a single underlying query may satisfy both interfaces (dual-emit) or only one. Callers that want the columnar path call PullBatch; callers that still want the row path call MeasureQueryResult.Pull. Release is shared semantics — the caller invokes it exactly once after iteration is complete; calling Release twice (e.g. once via each interface) is safe but unnecessary.

type MeasureGroupBy added in v0.11.0

type MeasureGroupBy struct {
	TagFamily string
	TagNames  []string
}

MeasureGroupBy describes a GroupBy clause for a measure query. v1 supports a single tag family; each entry in TagNames is a key column. An empty TagNames slice means the query carries no GroupBy clause.

type MeasureQueryOptions

type MeasureQueryOptions struct {
	Query           index.Query
	TimeRange       *timestamp.TimeRange
	Order           *index.OrderBy
	GroupBy         *MeasureGroupBy
	Agg             *MeasureAgg
	Name            string
	Entities        [][]*modelv1.TagValue
	TagProjection   []TagProjection
	FieldProjection []string
	Sort            modelv1.Sort
	Number          int32
	TopNFieldType   databasev1.FieldType
}

MeasureQueryOptions is the options of a measure query.

type MeasureQueryResult

type MeasureQueryResult interface {
	Pull() *MeasureResult
	Release()
}

MeasureQueryResult is the result of a measure query.

type MeasureResult

type MeasureResult struct {
	Error       error
	Timestamps  []int64
	Versions    []int64
	ShardIDs    []common.ShardID
	TagFamilies []TagFamily
	Fields      []Field
	SID         common.SeriesID
}

MeasureResult is the result of a query.

type StreamQueryOptions

type StreamQueryOptions struct {
	Name           string
	TimeRange      *timestamp.TimeRange
	Entities       [][]*modelv1.TagValue
	InvertedFilter index.Filter
	SkippingFilter index.Filter
	Order          *index.OrderBy
	TagProjection  []TagProjection
	MaxElementSize int
}

StreamQueryOptions is the options of a stream query.

func (*StreamQueryOptions) CopyFrom added in v0.8.0

func (s *StreamQueryOptions) CopyFrom(other *StreamQueryOptions)

CopyFrom copies the StreamQueryOptions from other to s.

func (*StreamQueryOptions) Reset added in v0.8.0

func (s *StreamQueryOptions) Reset()

Reset resets the StreamQueryOptions.

type StreamQueryResult

type StreamQueryResult interface {
	Pull(context.Context) *StreamResult
	Release()
}

StreamQueryResult is the result of a stream query.

type StreamResult

type StreamResult struct {
	Error       error
	Timestamps  []int64
	ElementIDs  []uint64
	TagFamilies []TagFamily
	SIDs        []common.SeriesID
	// contains filtered or unexported fields
}

StreamResult is the result of a query.

func MergeStreamResults added in v0.8.0

func MergeStreamResults(results []*StreamResult, topN int, asc bool) *StreamResult

MergeStreamResults merges multiple StreamResult slices into a single StreamResult.

func NewStreamResult added in v0.8.0

func NewStreamResult(topN int, asc bool) *StreamResult

NewStreamResult creates a new StreamResult.

func (*StreamResult) CopyFrom added in v0.8.0

func (sr *StreamResult) CopyFrom(tmp, other *StreamResult) bool

CopyFrom copies the topN results from other to sr using tmp as a temporary result.

func (*StreamResult) CopySingleFrom added in v0.8.0

func (sr *StreamResult) CopySingleFrom(other *StreamResult)

CopySingleFrom copies a single result from other to sr.

func (*StreamResult) Len added in v0.8.0

func (sr *StreamResult) Len() int

Len returns the length of the StreamResult.

func (*StreamResult) Reset added in v0.8.0

func (sr *StreamResult) Reset()

Reset resets the StreamResult.

type StreamResultHeap added in v0.8.0

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

StreamResultHeap is a min-heap of StreamResult pointers.

func (StreamResultHeap) Len added in v0.8.0

func (h StreamResultHeap) Len() int

func (StreamResultHeap) Less added in v0.8.0

func (h StreamResultHeap) Less(i, j int) bool

func (*StreamResultHeap) Pop added in v0.8.0

func (h *StreamResultHeap) Pop() interface{}

Pop pops a StreamResult pointer from the heap.

func (*StreamResultHeap) Push added in v0.8.0

func (h *StreamResultHeap) Push(x interface{})

Push pushes a StreamResult pointer to the heap.

func (StreamResultHeap) Swap added in v0.8.0

func (h StreamResultHeap) Swap(i, j int)

type Tag

type Tag struct {
	Name   string
	Values []*modelv1.TagValue
}

Tag is a tag name and its values.

type TagFamily

type TagFamily struct {
	Name string
	Tags []Tag
}

TagFamily is a tag family name and its tags.

type TagFilterMatcher added in v0.9.0

type TagFilterMatcher interface {
	// Match returns true if the given tags match the filter criteria.
	// tags is a slice of tags for a single element/row.
	Match(tags []*modelv1.Tag) (bool, error)
	// GetDecoder returns the decoder function for tag values.
	GetDecoder() TagValueDecoder
}

TagFilterMatcher is a simple interface for matching tags without schema dependency. This avoids cycle imports between logical and sidx packages.

type TagProjection

type TagProjection struct {
	Family string
	Names  []string
}

TagProjection is the projection of a tag family and its tags.

type TagValueDecoder added in v0.9.0

type TagValueDecoder func(valueType pbv1.ValueType, value []byte, valueArr [][]byte) *modelv1.TagValue

TagValueDecoder decodes a byte slice to a TagValue based on the value type.

type TagValueDecoderProvider added in v0.9.0

type TagValueDecoderProvider interface {
	GetTagValueDecoder() TagValueDecoder
}

TagValueDecoderProvider provides a decoder for tag values.

type TraceQueryOptions added in v0.9.0

type TraceQueryOptions struct {
	SkippingFilter index.Filter
	TagFilter      TagFilterMatcher
	TimeRange      *timestamp.TimeRange
	Order          *index.OrderBy
	TagProjection  *TagProjection
	Name           string
	Entities       [][]*modelv1.TagValue
	TraceIDs       []string
	MaxTraceSize   int
	MinVal         int64
	MaxVal         int64
}

TraceQueryOptions is the options of a trace query.

func (*TraceQueryOptions) CopyFrom added in v0.9.0

func (t *TraceQueryOptions) CopyFrom(other *TraceQueryOptions)

CopyFrom copies the TraceQueryOptions from other to t.

func (*TraceQueryOptions) Reset added in v0.9.0

func (t *TraceQueryOptions) Reset()

Reset resets the TraceQueryOptions.

type TraceQueryResult added in v0.9.0

type TraceQueryResult interface {
	Pull() *TraceResult
	Release()
}

TraceQueryResult is the result of a trace query.

type TraceResult added in v0.9.0

type TraceResult struct {
	Error      error
	TID        string
	Spans      [][]byte
	SpanIDs    []string
	Tags       []Tag
	Key        int64
	GroupIndex int
}

TraceResult is the result of a query.

Jump to

Keyboard shortcuts

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