lib/logstorage: fix streamID and tenantID search (#4856) (#5295)

This commit is contained in:
XLONG96 2023-11-14 06:09:39 +08:00 committed by GitHub
parent 8eed04b2c6
commit 89dcbc2fe7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -382,7 +382,7 @@ func (p *part) searchByTenantIDs(so *searchOptions, bhss *blockHeaders, workCh c
n = sort.Search(len(ibhs), func(i int) bool { n = sort.Search(len(ibhs), func(i int) bool {
return !ibhs[i].streamID.tenantID.less(tenantID) return !ibhs[i].streamID.tenantID.less(tenantID)
}) })
if n == len(ibhs) || n > 0 && ibhs[n].streamID.tenantID.equal(tenantID) { if n == len(ibhs) || n > 0 && !ibhs[n].streamID.tenantID.equal(tenantID) {
// The end of ibhs[n-1] may contain blocks for the given tenantID, so move it backwards // The end of ibhs[n-1] may contain blocks for the given tenantID, so move it backwards
n-- n--
} }
@ -493,7 +493,7 @@ func (p *part) searchByStreamIDs(so *searchOptions, bhss *blockHeaders, workCh c
n = sort.Search(len(ibhs), func(i int) bool { n = sort.Search(len(ibhs), func(i int) bool {
return !ibhs[i].streamID.less(streamID) return !ibhs[i].streamID.less(streamID)
}) })
if n == len(ibhs) || n > 0 && ibhs[n].streamID.equal(streamID) { if n == len(ibhs) || n > 0 && !ibhs[n].streamID.equal(streamID) {
// The end of ibhs[n-1] may contain blocks for the given streamID, so move it backwards // The end of ibhs[n-1] may contain blocks for the given streamID, so move it backwards
n-- n--
} }