Documentation
¶
Index ¶
- Constants
- Variables
- func AnySegmentOverlaps(objZM ZM, segments [][]byte) bool
- func BatchUpdateZM(zm ZM, vec *vector.Vector) (err error)
- func DecodeBloomFilter(sf StaticFilter, buf []byte) error
- func EncodeZM(zm *ZM) []byte
- func MustZMToVector(zm ZM, vec *vector.Vector, m *mpool.MPool) *vector.Vector
- func NewSimpleARTMap() *simpleARTMap
- func SetZMSum(zm ZM, vec *vector.Vector)
- func StrictlyCompareZmMaxAndMin(maxBuf, minBuf []byte, t types.T, scale1, scale2 int32) int
- func UpdateZM(zm ZM, v []byte)
- func UpdateZMAny(zm ZM, v any)
- func ZMToVector(zm ZM, vec *vector.Vector, m *mpool.MPool) (*vector.Vector, error)
- type BloomFilter
- type HybridBloomFilter
- type Positions
- type PrefixFn
- type SecondaryIndex
- type StaticFilter
- func NewBloomFilter(vec containers.Vector, buf *[]uint64, builder *xorfilter.BinaryFuseBuilder, ...) (StaticFilter, error)
- func NewBloomFilter2(vectors []containers.Vector, buf *[]uint64, ...) (StaticFilter, error)
- func NewEmptyBloomFilter() StaticFilter
- func NewEmptyBloomFilterWithType(t uint8) StaticFilter
- func NewHybridBloomFilter(data containers.Vector, level1PrefixFnId uint8, ...) (StaticFilter, error)
- func NewPrefixBloomFilter(data containers.Vector, prefixFnId uint8, prefixFn func([]byte) []byte, ...) (StaticFilter, error)
- type ZM
- func (zm ZM) And(o ZM) (res bool, ok bool)
- func (zm ZM) AnyBetween(lb, ub ZM) (res bool, ok bool)
- func (zm ZM) AnyGE(o ZM) (res bool, ok bool)
- func (zm ZM) AnyGEByValue(k []byte) bool
- func (zm ZM) AnyGT(o ZM) (res bool, ok bool)
- func (zm ZM) AnyGTByValue(k []byte) bool
- func (zm ZM) AnyIn(vec *vector.Vector) bool
- func (zm ZM) AnyLE(o ZM) (res bool, ok bool)
- func (zm ZM) AnyLEByValue(k []byte) bool
- func (zm ZM) AnyLT(o ZM) (res bool, ok bool)
- func (zm ZM) AnyLTByValue(k []byte) bool
- func (zm ZM) Between(lb, ub []byte) bool
- func (zm ZM) Clone() ZM
- func (zm ZM) CompareMax(o ZM) int
- func (zm ZM) CompareMin(o ZM) int
- func (zm ZM) Contains(k any) bool
- func (zm ZM) ContainsKey(k []byte) bool
- func (zm ZM) Encode() []byte
- func (zm ZM) FastContainsAny(keys *vector.Vector) (ok bool)
- func (zm ZM) FastIntersect(o ZM) (res bool)
- func (zm ZM) FastLEValue(v []byte, scale int32) (res bool)
- func (zm ZM) GetBuf() []byte
- func (zm ZM) GetMax() any
- func (zm ZM) GetMaxBuf() []byte
- func (zm ZM) GetMin() any
- func (zm ZM) GetMinBuf() []byte
- func (zm ZM) GetScale() int32
- func (zm ZM) GetSum() any
- func (zm ZM) GetSumBuf() []byte
- func (zm ZM) GetType() types.T
- func (zm ZM) HasSum() bool
- func (zm ZM) InRange(lb, ub []byte, hint uint8) bool
- func (zm ZM) Intersect(o ZM) (res bool, ok bool)
- func (zm ZM) IsArray() bool
- func (zm ZM) IsInited() bool
- func (zm ZM) IsString() bool
- func (zm ZM) Marshal() ([]byte, error)
- func (zm ZM) MaxTruncated() bool
- func (zm ZM) Or(o ZM) (res bool, ok bool)
- func (zm ZM) PrefixBetween(lb, ub []byte) bool
- func (zm ZM) PrefixEq(s []byte) bool
- func (zm ZM) PrefixGT(s []byte) bool
- func (zm ZM) PrefixIn(vec *vector.Vector) bool
- func (zm ZM) PrefixInRange(lb, ub []byte, hint uint8) bool
- func (zm ZM) Reset()
- func (zm ZM) ResetMinMax()
- func (zm ZM) RowidPrefixEq(s []byte) bool
- func (zm ZM) RowidPrefixGT(s []byte) bool
- func (zm ZM) SetMaxTruncated()
- func (zm ZM) SetScale(scale int32)
- func (zm ZM) SetSum(v []byte)
- func (zm ZM) SetType(t types.T)
- func (zm ZM) String() string
- func (zm ZM) StringForCompose() string
- func (zm ZM) StringForHex() string
- func (zm ZM) SubVecIn(vec *vector.Vector) (int, int)
- func (zm ZM) Unmarshal(buf []byte) (err error)
- func (zm ZM) Update(v any) (err error)
- func (zm ZM) Valid() bool
Constants ¶
const ( BF = iota PBF HBF )
const ( PrefixFnID_Object uint8 = iota PrefixFnID_Block )
const FuseFilterErrorMsg = "too many iterations"
const (
ZMSize = 64
)
Variables ¶
var ( ErrNotFound = moerr.NewInternalErrorNoCtx("tae index: key not found") ErrDuplicate = moerr.NewInternalErrorNoCtx("tae index: key duplicate") ErrPrefix = moerr.NewInternalErrorNoCtx("tae index: prefix filter error") )
var ( ObjectPrefixFn = PrefixFn{Id: PrefixFnID_Object, Fn: func(b []byte) []byte { return b[:types.ObjectBytesSize] }} BlockPrefixFn = PrefixFn{Id: PrefixFnID_Block, Fn: func(b []byte) []byte { return b[:types.BlockidSize] }} )
var MaxBytesValue []byte
Functions ¶
func AnySegmentOverlaps ¶
AnySegmentOverlaps reports whether any segment in the sorted, non-overlapping segment list overlaps with objZM.
Each segment is a 64-byte ZoneMap (same encoding as ZM) passed as a raw []byte slice. This avoids forcing the engine package to import the index package — callers store segments as [][]byte in engine.PKFilter and pass them here unchanged.
Segments must satisfy two invariants (guaranteed by the gap-based streaming construction algorithm):
- Sorted by min: segments[i].min ≤ segments[i+1].min
- Non-overlapping: segments[i].max < segments[i+1].min
Because of these invariants the max values are also monotonically increasing, so a single binary search on max suffices.
Overlap condition for two ranges [a_min, a_max] and [b_min, b_max]:
a_max ≥ b_min AND a_min ≤ b_max
Complexity: O(log N) where N = len(segments).
Returns true when segments is empty (no filter ⇒ match everything).
func DecodeBloomFilter ¶ added in v0.8.0
func DecodeBloomFilter(sf StaticFilter, buf []byte) error
func MustZMToVector ¶ added in v0.8.0
func NewSimpleARTMap ¶
func NewSimpleARTMap() *simpleARTMap
func StrictlyCompareZmMaxAndMin ¶
StrictlyCompareZmMaxAndMin Consider this scenario:
- If not truncated, maxBuf is smaller than minBuf.
- If truncated, maxBuf is equal to or larger than minBuf.
For example:
maxBuf: 0xa 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff ==> 0xb 0x00 0x00 0x00 0x00 0x00 0x00 0x00
minBuf: 0xb
maxBuf should be smaller than minBuf, but after truncating, maxBuf is bigger than minBuf.
this is not accepted in overlap check.
maxBuf: 0xa 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff ==> 0xb 0x00 0x00 0x00 0x00 0x00 0x00 0x00
minBuf: 0xb 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xff ==> 0xb 0x00 0x00 0x00 0x00 0x00 0x00 0x00
maxBuf should be smaller than minBuf, but after truncating, maxBuf is equal to minBuf.
In this case, StrictlyCompareZmMaxAndMin will return -1 even when truncated, indicating a possibly false negative response to the declaration that two ZMs intersect
Types ¶
type BloomFilter ¶
type BloomFilter = bloomFilter
type HybridBloomFilter ¶
type HybridBloomFilter = hybridFilter
type SecondaryIndex ¶
type StaticFilter ¶
type StaticFilter interface {
MayContainsKey(key []byte) (bool, error)
MayContainsAnyKeys(keys containers.Vector) (bool, *nulls.Bitmap, error)
MayContainsAny(keys *vector.Vector, lowerBound int, upperBound int) bool
PrefixMayContainsKey(key []byte, prefixFnId uint8, level uint8) (bool, error)
PrefixMayContainsAny(
keys *vector.Vector, lowerBound int, upperBound int, prefixFnId uint8, level uint8,
) bool
Marshal() ([]byte, error)
// MarshalWithBuffer marshals the filter into an existing, reusable buffer.
// The caller must copy buf.Bytes() before the next Reset/reuse of buf.
MarshalWithBuffer(buf *bytes.Buffer) error
Unmarshal(buf []byte) error
String() string
PrefixFnId(level uint8) uint8
GetType() uint8
MaxLevel() uint8
}
func NewBloomFilter ¶
func NewBloomFilter(vec containers.Vector, buf *[]uint64, builder *xorfilter.BinaryFuseBuilder, alloc func(int) []byte) (StaticFilter, error)
NewBloomFilter builds a BinaryFuse8 bloom filter for a single vector. buf is an optional scratch buffer; pass &mySlice to reuse it across calls. builder is an optional BinaryFuseBuilder; pass &myBuilder to reuse internal buffers across filter builds.
func NewBloomFilter2 ¶
func NewBloomFilter2(vectors []containers.Vector, buf *[]uint64, builder *xorfilter.BinaryFuseBuilder, alloc func(int) []byte) (StaticFilter, error)
NewBloomFilter2 builds a BinaryFuse8 bloom filter over multiple vectors. buf is an optional scratch buffer; pass &mySlice to reuse it across calls. builder is an optional BinaryFuseBuilder for reusing internal buffers.
func NewEmptyBloomFilter ¶
func NewEmptyBloomFilter() StaticFilter
func NewEmptyBloomFilterWithType ¶
func NewEmptyBloomFilterWithType(t uint8) StaticFilter
func NewHybridBloomFilter ¶
func NewHybridBloomFilter( data containers.Vector, level1PrefixFnId uint8, level1Prefix func([]byte) []byte, level2PrefixFnId uint8, level2Prefix func([]byte) []byte, buf *[]uint64, builder *xorfilter.BinaryFuseBuilder, alloc func(int) []byte, ) (StaticFilter, error)
NewHybridBloomFilter builds three BinaryFuse8 filters (full-key, level-1 prefix, level-2 prefix) in a single ForeachWindowBytes pass. buf is an optional scratch buffer; pass &mySlice to reuse it across calls. When provided, the buffer is grown to 3×n capacity and partitioned into three non-overlapping sub-slices — one allocation for all three hash arrays. builder is an optional BinaryFuseBuilder for reusing internal buffers.
func NewPrefixBloomFilter ¶
func NewPrefixBloomFilter( data containers.Vector, prefixFnId uint8, prefixFn func([]byte) []byte, buf *[]uint64, builder *xorfilter.BinaryFuseBuilder, alloc func(int) []byte, ) (StaticFilter, error)
NewPrefixBloomFilter builds a BinaryFuse8 bloom filter over prefix-transformed values. buf is an optional scratch buffer; pass &mySlice to reuse it across calls. builder is an optional BinaryFuseBuilder for reusing internal buffers.
type ZM ¶ added in v0.8.0
type ZM []byte
func VectorToZM ¶ added in v0.8.0
if zm is not of length 2, return not initilized zm
func (ZM) And ¶ added in v0.8.0
both zm should be of type bool, otherwise, ok is false res is true only when zm.min == true and o.min == true
func (ZM) CompareMax ¶ added in v1.2.0
caller need to do compareCheck
func (ZM) CompareMin ¶ added in v1.2.0
func (ZM) ContainsKey ¶ added in v0.8.0
func (ZM) FastContainsAny ¶ added in v0.8.0
func (ZM) FastIntersect ¶ added in v0.8.0
func (ZM) FastLEValue ¶
no init check no type check max <= v
func (ZM) MaxTruncated ¶ added in v0.8.0
func (ZM) Or ¶ added in v0.8.0
both zm should be of type bool, otherwise, ok is false res is false only when zm.max == false and o.max == false
func (ZM) PrefixBetween ¶ added in v1.1.1
func (ZM) ResetMinMax ¶ added in v0.8.0
func (zm ZM) ResetMinMax()
func (ZM) RowidPrefixEq ¶
func (ZM) RowidPrefixGT ¶
func (ZM) SetMaxTruncated ¶ added in v1.2.0
func (zm ZM) SetMaxTruncated()