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 Aliaksandr Valialkin
parent f7834767c1
commit 77033dbfb6
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1

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 {
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
n--
}
@ -493,7 +493,7 @@ func (p *part) searchByStreamIDs(so *searchOptions, bhss *blockHeaders, workCh c
n = sort.Search(len(ibhs), func(i int) bool {
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
n--
}