Skip empty segment while query/search (#27711)

Signed-off-by: yah01 <yah2er0ne@outlook.com>
pull/27713/head
yah01 2023-10-15 16:10:04 +08:00 committed by GitHub
parent 6cbb67832f
commit 50672f0d60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -42,6 +42,12 @@ import (
type SegmentFilter func(segment Segment) bool
func WithSkipEmpty() SegmentFilter {
return func(segment Segment) bool {
return segment.InsertCount() > 0
}
}
func WithPartition(partitionID UniqueID) SegmentFilter {
return func(segment Segment) bool {
return segment.Partition() == partitionID
@ -284,6 +290,8 @@ func (mgr *segmentManager) GetAndPinBy(filters ...SegmentFilter) ([]Segment, err
mgr.mu.RLock()
defer mgr.mu.RUnlock()
filters = append(filters, WithSkipEmpty())
ret := make([]Segment, 0)
var err error
defer func() {
@ -320,6 +328,8 @@ func (mgr *segmentManager) GetAndPin(segments []int64, filters ...SegmentFilter)
mgr.mu.RLock()
defer mgr.mu.RUnlock()
filters = append(filters, WithSkipEmpty())
lockedSegments := make([]Segment, 0, len(segments))
var err error
defer func() {