mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-01 03:18:29 +08:00
Update filterSegmentByPK (#9450)
Signed-off-by: yudong.cai <yudong.cai@zilliz.com>
This commit is contained in:
parent
e52586a052
commit
12d640a023
@ -13,7 +13,6 @@ package datanode
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
@ -68,23 +67,20 @@ func (dn *deleteNode) Operate(in []Msg) []Msg {
|
||||
// filterSegmentByPK returns the bloom filter check result.
|
||||
// If the key may exists in the segment, returns it in map.
|
||||
// If the key not exists in the segment, the segment is filter out.
|
||||
func (dn *deleteNode) filterSegmentByPK(partID UniqueID, pks []int64) (map[int64][]int64, error) {
|
||||
if pks == nil {
|
||||
return nil, errors.New("pks is nil")
|
||||
}
|
||||
results := make(map[int64][]int64)
|
||||
func (dn *deleteNode) filterSegmentByPK(partID UniqueID, pks []int64) map[int64][]int64 {
|
||||
result := make(map[int64][]int64)
|
||||
buf := make([]byte, 8)
|
||||
segments := dn.replica.filterSegments(dn.channelName, partID)
|
||||
for _, segment := range segments {
|
||||
for _, pk := range pks {
|
||||
for _, pk := range pks {
|
||||
for _, segment := range segments {
|
||||
binary.BigEndian.PutUint64(buf, uint64(pk))
|
||||
exist := segment.pkFilter.Test(buf)
|
||||
if exist {
|
||||
results[pk] = append(results[pk], segment.segmentID)
|
||||
result[pk] = append(result[pk], segment.segmentID)
|
||||
}
|
||||
}
|
||||
}
|
||||
return results, nil
|
||||
return result
|
||||
}
|
||||
|
||||
func newDeleteNode(replica Replica, channelName string, flushCh <-chan *flushMsg) *deleteNode {
|
||||
|
@ -148,8 +148,7 @@ func Test_GetSegmentsByPKs(t *testing.T) {
|
||||
mockReplica.flushedSegments[segment5.segmentID] = segment5
|
||||
mockReplica.flushedSegments[segment6.segmentID] = segment6
|
||||
dn := newDeleteNode(mockReplica, "test", make(chan *flushMsg))
|
||||
results, err := dn.filterSegmentByPK(0, []int64{0, 1, 2, 3, 4})
|
||||
assert.Nil(t, err)
|
||||
results := dn.filterSegmentByPK(0, []int64{0, 1, 2, 3, 4})
|
||||
expected := map[int64][]int64{
|
||||
0: {1, 2, 3},
|
||||
1: {1, 2, 3},
|
||||
|
Loading…
Reference in New Issue
Block a user