Skip to content

Commit

Permalink
Fix bitmap AndNot
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangxu19830126 committed Nov 6, 2019
1 parent 215f996 commit 1d5f6b7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/proxy/aggregation_bitmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func (p *RedisProxy) doBMXorMerge(args [][]byte, rsps ...*raftcmdpb.Response) *r
return p.buildResult(bm, args)
}

// and not A - (A and B)
func (p *RedisProxy) doBMAndNotMerge(args [][]byte, rsps ...*raftcmdpb.Response) *raftcmdpb.Response {
targets := make([]*roaring.Bitmap, 0, len(rsps))
for _, rsp := range rsps {
Expand All @@ -167,15 +168,14 @@ func (p *RedisProxy) doBMAndNotMerge(args [][]byte, rsps ...*raftcmdpb.Response)
}
}

union := targets[0]
bm := targets[0]
and := targets[0]

for _, bm := range targets[1:] {
union = union.Union(bm)
and = and.Intersect(bm)
}

return p.buildResult(union.Xor(and), args)
return p.buildResult(bm.Xor(and), args)
}

func (p *RedisProxy) buildResult(bm *roaring.Bitmap, args [][]byte) *raftcmdpb.Response {
Expand Down

0 comments on commit 1d5f6b7

Please sign in to comment.