Skip to content

Commit 1e0adf1

Browse files
authored
feat(log): optimize query process of bloomfilter (openGemini#605)
Signed-off-by: noFloat <[email protected]>
1 parent ac29950 commit 1e0adf1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

engine/index/bloomfilter/multi_field_filter_reader.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -190,20 +190,23 @@ func (s *MultilFieldVerticalFilterReader) isExist(blockId int64, elem *rpn.SKRPN
190190
if _, ok2 := s.groupNewPreCache[groupIndex]; !ok2 {
191191
s.groupNewPreCache = s.groupNewCache
192192
s.groupNewCache = make(map[int64]map[int64][]uint64)
193-
pieceNum := PIECE_NUM
194-
if groupIndex+pieceNum > s.verticalPieceCount {
195-
pieceNum = s.verticalPieceCount - groupIndex
193+
pieceIndex := groupIndex / PIECE_NUM
194+
startPieceIndex := pieceIndex * PIECE_NUM
195+
endPieceIndex := startPieceIndex + PIECE_NUM
196+
if startPieceIndex+PIECE_NUM > s.verticalPieceCount {
197+
endPieceIndex = s.verticalPieceCount
196198
}
197-
for i := int64(0); i < pieceNum; i++ {
199+
for startPieceIndex < endPieceIndex {
198200
for _, hashes := range s.hashes {
199201
for _, hash := range hashes {
200-
pieceOffset, offsetInLong := s.getPieceOffset(hash, groupIndex+i)
202+
pieceOffset, offsetInLong := s.getPieceOffset(hash, startPieceIndex)
201203
offsetsSet[pieceOffset] = true
202204
if offsetInLong != 0 {
203205
offsetsSet[pieceOffset+verticalPieceDiskSize] = true
204206
}
205207
}
206208
}
209+
startPieceIndex++
207210
}
208211
offsetsLen := len(offsetsSet)
209212
offsets := make([]int64, 0)

0 commit comments

Comments
 (0)