node

package
v0.80.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAnd

func NewAnd(left, right Node) *nodeAnd

func NewNAnd

func NewNAnd(negative, regular Node) *nodeNAnd

func NewNot

func NewNot(child Node, minID, maxID LID) *nodeNot

func NewOr

func NewOr(left, right Node) *nodeOr

func NewRange

func NewRange(minVal, maxVal LID) *nodeRange

func OrMulti added in v0.77.0

func OrMulti(batches []LIDBatch, asc bool) (result LIDBatch, residuals []LIDBatch)

OrMulti unions multiple batches in the given LID order and returns result and unprocessed parts for each input batch.

func TreeFold

func TreeFold[V any](op func(V, V) V, def V, values []V) V

Types

type BatchedNode added in v0.72.0

type BatchedNode interface {
	fmt.Stringer
	// NextBatch returns next batch. Returns empty batch when exhausted.
	NextBatch() LIDBatch
	// NextBatchGeq returns next batch (LIDs >= minLID). Returns empty batch when exhausted.
	NextBatchGeq(nextID LID) LIDBatch
}

func EmptyBatched added in v0.77.0

func EmptyBatched() BatchedNode

func NewAndBatched added in v0.77.0

func NewAndBatched(left, right BatchedNode, asc bool) BatchedNode

NewAndBatched returns a BatchedNode that intersects two batched iterators. asc is the LID traversal order for NextBatch / NextBatchGeq (true = low to high).

func NewBatcherNode added in v0.77.0

func NewBatcherNode(source Node, asc bool) BatchedNode

func NewNAndBatched added in v0.77.0

func NewNAndBatched(neg, reg BatchedNode, asc bool) BatchedNode

NewNAndBatched returns a BatchedNode that computes AND NOT of two batched iterators. asc is the LID traversal order for NextBatch / NextBatchGeq (true = low to high).

func NewOrBatched added in v0.77.0

func NewOrBatched(left, right BatchedNode, asc bool) BatchedNode

NewOrBatched returns a BatchedNode that unions two batched iterators. asc is the LID traversal order for NextBatch / NextBatchGeq (true = low to high).

func NewOrBatchedMulti added in v0.77.0

func NewOrBatchedMulti(children []BatchedNode, asc bool) BatchedNode

func NewStaticBatched added in v0.77.0

func NewStaticBatched(data []uint32, asc bool) BatchedNode

NewStaticBatched returns a BatchedNode over sorted LID data.

type Iter added in v0.77.0

type Iter interface {
	Next() (uint32, bool)
	NextGeq(geq uint32) (uint32, bool)
}

type LID added in v0.69.0

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

LID is an encoded representation of LID and order flag made specifically for fast compare operations.

For asc LID order the value is stored as is and mask is zero. For desc LID order the value is inverted as follows: "MaxUint32 - LID" formula using XOR mask. Terminal LID value is 0 instead of MaxUint32 in desc order, but 0 is XORed to MaxUint32. Which means, null value will always have lid field set to 0xFFFFFFFF (math.MaxUint32) regardless of order flag.

func Max added in v0.69.0

func Max(left, right LID) LID

func Min added in v0.69.0

func Min(left, right LID) LID

func NewAscLID added in v0.69.0

func NewAscLID(lid uint32) LID

NewAscLID returns LIDs for asc LID order.

func NewAscZeroLID added in v0.72.0

func NewAscZeroLID() LID

func NewDescLID added in v0.69.0

func NewDescLID(lid uint32) LID

NewDescLID returns LIDs for desc LID order.

func NewDescZeroLID added in v0.72.0

func NewDescZeroLID() LID

func NewLID added in v0.69.0

func NewLID(lid uint32, asc bool) LID

func NullLID added in v0.69.0

func NullLID() LID

func (LID) Eq added in v0.69.0

func (c LID) Eq(other LID) bool

func (LID) Inc added in v0.69.0

func (c LID) Inc() LID

func (LID) IsNull added in v0.69.0

func (c LID) IsNull() bool

func (LID) Less added in v0.69.0

func (c LID) Less(other LID) bool

Less compares two values. It also does an implicit null check, since we store math.MaxUint32 for null values. Which means if we call x.Less(y), then we know for sure that x is not null. Therefore, this Less call can work as both "null check + less" combo.

func (LID) LessOrEq added in v0.69.0

func (c LID) LessOrEq(other LID) bool

func (LID) String added in v0.69.0

func (c LID) String() string

func (LID) ToSeqLID added in v0.72.0

func (c LID) ToSeqLID() seq.LID

func (LID) Unpack added in v0.69.0

func (c LID) Unpack() uint32

type LIDBatch added in v0.72.0

type LIDBatch interface {
	Len() int
	IsEmpty() bool
	// Min returns minimum (first) value. Panics if batch is empty.
	Min() uint32
	// Max returns max (last) value. Panics if batch is empty.
	Max() uint32
	ManyIter(asc bool) ManyIter
	// Iter iterates lids in ascending way.
	Iter() Iter
	// ReverseIter iterates lids in descending way.
	ReverseIter() Iter
	// Narrow returns a batch containing only LIDs from minLID to maxLID (inclusive both).
	Narrow(minLID, maxLID uint32) LIDBatch
}

LIDBatch is batch of lids. It's immutable and can not be modified. Lids are always sorted in ascending way for every underlying implementation.

func And added in v0.77.0

func And(left, right LIDBatch, asc bool) (result, leftResidual, rightResidual LIDBatch)

And intersects two batches in the given LID order and returns result and unprocessed parts (either left or right will be empty). For AND operation left and right residuals are equal to provided left or right batch, it's safe.

func AndNot added in v0.77.0

func AndNot(reg, neg LIDBatch, asc bool) (result, regResidual, negResidual LIDBatch)

AndNot finds "AND NOT" result for two batches and returns result and unprocessed parts.

func EmptyBatch added in v0.77.0

func EmptyBatch() LIDBatch

func NewBitmapBatch added in v0.77.0

func NewBitmapBatch(b *roaring.Bitmap) LIDBatch

func NewBitmapBatchFromLids added in v0.77.0

func NewBitmapBatchFromLids(lids []uint32) LIDBatch

func NewSliceBatch added in v0.77.0

func NewSliceBatch(lids []uint32) LIDBatch

func Or added in v0.77.0

func Or(left, right LIDBatch, asc bool) (result, leftResidual, rightResidual LIDBatch)

Or unions two batches in the given LID order and returns result and unprocessed parts (either left or right will be empty).

type LIDsIter added in v0.80.0

type LIDsIter interface {
	NextBatch(lids, offsets []uint32) (outLids, outOffsets []uint32, isFirstLID bool)
}

type ManyIter added in v0.77.0

type ManyIter interface {
	CopyLIDs(dst []LID, tmp []uint32) int
	// CopyRawLIDs copies raw lids (exactly as they stored)
	CopyRawLIDs(dst []uint32) int
}

type Node

type Node interface {
	fmt.Stringer // for testing
	Next() LID
	// NextGeq returns next greater or equal (GEQ) lid
	NextGeq(nextID LID) LID
}

func BuildORTree

func BuildORTree(nodes []Node) Node

func MakeStaticNodes

func MakeStaticNodes(data [][]uint32) []Node

MakeStaticNodes is currently used only for tests

func NewStatic

func NewStatic(data []uint32, asc bool) Node

type Sourced

type Sourced interface {
	fmt.Stringer // for testing
	// aggregation need source
	NextSourced() (id LID, source uint32)
	NextSourcedGeq(nextLID LID) (id LID, source uint32)
	// Release releases resources held by the sourced node (e.g. pooled buffers).
	Release()
}

func BuildORTreeAgg

func BuildORTreeAgg(nodes []Node) Sourced

func NewColumnAgg added in v0.80.0

func NewColumnAgg(postings LIDsIter, minLID, maxLID uint32, asc bool) Sourced

func NewNodeOrAgg

func NewNodeOrAgg(left, right Sourced) Sourced

func NewSourcedNodeWrapper

func NewSourcedNodeWrapper(d Node, source int) Sourced

func WrapWithSource

func WrapWithSource(nodes []Node) []Sourced

Jump to

Keyboard shortcuts

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