Skip to content

Commit 708c7d3

Browse files
authored
support filter on dist func in Reader (#23183)
- implement filter by distance in Reader for IVFFlat - replace per-block heaps by universal heap to reduce copy - refactor some interfaces Approved by: @zhangxu19830126, @heni02, @LeftHandCold, @XuPeng-SH, @fengttt, @ouyuanning
1 parent 447e92f commit 708c7d3

34 files changed

+4072
-2660
lines changed

pkg/defines/type.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ type InSp struct{}
253253
// This key is set on context when invoking internal SQL from ivf_search.
254254
type IvfBloomFilter struct{}
255255

256+
// IvfReaderParam carries DistRange for ivf entries scan in internal SQL executor.
257+
// This key is set on context when invoking internal SQL from ivf_search.
258+
type IvfReaderParam struct{}
259+
256260
// PkCheckByTN whether TN does primary key uniqueness check against transaction's workspace or not.
257261
type PkCheckByTN struct{}
258262

pkg/frontend/test/engine_mock.go

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/objectio/types.go

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/matrixorigin/matrixone/pkg/container/batch"
2222
"github.com/matrixorigin/matrixone/pkg/container/types"
2323
"github.com/matrixorigin/matrixone/pkg/fileservice"
24+
"github.com/matrixorigin/matrixone/pkg/pb/plan"
2425
"github.com/matrixorigin/matrixone/pkg/vectorindex/metric"
2526
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/containers"
2627
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/index"
@@ -64,12 +65,37 @@ func (f BlockReadFilter) DecideSearchFunc(isSortedBlk bool) ReadFilterSearchFunc
6465
return nil
6566
}
6667

67-
type BlockReadTopOp struct {
68-
Typ types.T
69-
Metric metric.MetricType
70-
ColPos int32
71-
NumVec []byte
72-
Limit uint64
68+
type Float64Heap []float64
69+
70+
func (h Float64Heap) Len() int { return len(h) }
71+
func (h Float64Heap) Less(i, j int) bool { return h[i] > h[j] }
72+
func (h Float64Heap) Swap(i, j int) { h[i], h[j] = h[j], h[i] }
73+
74+
func (h *Float64Heap) Push(x any) {
75+
*h = append(*h, x.(float64))
76+
}
77+
78+
func (h *Float64Heap) Pop() any {
79+
old := *h
80+
n := len(old)
81+
x := old[n-1]
82+
*h = old[0 : n-1]
83+
return x
84+
}
85+
86+
type IndexReaderTopOp struct {
87+
Typ types.T
88+
MetricType metric.MetricType
89+
ColPos int32
90+
NumVec []byte
91+
Limit uint64
92+
93+
LowerBoundType plan.BoundType
94+
UpperBoundType plan.BoundType
95+
LowerBound float64
96+
UpperBound float64
97+
98+
DistHeap Float64Heap
7399
}
74100

75101
type WriteOptions struct {

0 commit comments

Comments
 (0)