Skip to content

Commit

Permalink
Skip empty segment while query/search (#27711)
Browse files Browse the repository at this point in the history
Signed-off-by: yah01 <[email protected]>
  • Loading branch information
yah01 authored Oct 15, 2023
1 parent 6cbb678 commit 50672f0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/querynodev2/segments/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 50672f0

Please sign in to comment.