mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 09:05:55 +00:00
performance enhancement for Difference
This commit is contained in:
parent
671036432f
commit
4190b720dc
2 changed files with 17 additions and 4 deletions
|
|
@ -121,6 +121,14 @@ func BlockArray_intersection(a *BlockArray, b *BlockArray) BlockArray {
|
|||
return o
|
||||
}
|
||||
|
||||
func BlockArray_difference(a *BlockArray, b *BlockArray) BlockArray {
|
||||
var o = BlockArray{}
|
||||
for i, _ := range a.Block {
|
||||
o.Block[i] = a.Block[i] &^ b.Block[i]
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (s *BlockArray) set_bit(BlockIndex uint8, bit uint8) bool {
|
||||
val := s.Block[BlockIndex] & (1 << bit)
|
||||
s.Block[BlockIndex] |= 1 << bit
|
||||
|
|
@ -295,9 +303,14 @@ func Difference(a_bm IBitmap, b_bm IBitmap) IBitmap {
|
|||
b = b.Next()
|
||||
} else if a.Item().Key == b.Item().Key {
|
||||
var a_node = a.Item()
|
||||
var b_node = BlockArray_invert(&b.Item().Value) //probably need to copy this out
|
||||
var o = BlockArray_intersection(&a_node.Value, &b_node)
|
||||
//var b_node = BlockArray_invert(&b.Item().Value) //probably need to copy this out
|
||||
//var o = BlockArray_intersection(&a_node.Value, &b_node)
|
||||
|
||||
var b_node = b.Item().Value
|
||||
var o = BlockArray_difference(&a_node.Value, &b_node)
|
||||
|
||||
var o_node = &Chunk{a_node.Key, o}
|
||||
|
||||
//could not add if all zero
|
||||
if o_node.Value.bitcount() > 0 {
|
||||
output.AddChunk(o_node)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
// "io/ioutil"
|
||||
// "time"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ func TestStorage(t *testing.T) {
|
|||
|
||||
fmt.Println("FETCH")
|
||||
bm, _ := storage.Fetch(bitmap_id, db, frame, slice)
|
||||
spew.Dump(bm)
|
||||
//spew.Dump(bm)
|
||||
SetBit(bm, 0)
|
||||
SetBit(bm, 1)
|
||||
SetBit(bm, 2)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue