mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 00:55:55 +00:00
category missing from setbit bug
This commit is contained in:
parent
d8ceef1b0a
commit
0598bfc686
3 changed files with 32 additions and 28 deletions
|
|
@ -37,8 +37,6 @@ type IntSet struct {
|
|||
func NewIntSet() *IntSet {
|
||||
x := new(IntSet)
|
||||
x.set = make(map[uint64]bool)
|
||||
x.set[0] = true
|
||||
log.Println(x.set)
|
||||
return x
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,9 +66,13 @@ func (self *Brand) Get(bitmap_id uint64) IBitmap {
|
|||
}
|
||||
//I should fetch the category here..need to come up with a good source
|
||||
b, filter := self.storage.Fetch(bitmap_id, self.db, self.frame, self.slice)
|
||||
|
||||
self.cache_it(b, bitmap_id, filter)
|
||||
return b
|
||||
}
|
||||
|
||||
func (self *Brand) GetFilter(bitmap_id, filter uint64) IBitmap {
|
||||
b, _ := self.storage.Fetch(bitmap_id, self.db, self.frame, self.slice)
|
||||
self.cache_it(b, bitmap_id, filter)
|
||||
return b
|
||||
}
|
||||
|
||||
|
|
@ -90,7 +94,13 @@ func (self *Brand) trim() {
|
|||
}
|
||||
|
||||
func (self *Brand) SetBit(bitmap_id uint64, bit_pos uint64, filter uint64) bool {
|
||||
bm := self.Get(bitmap_id)
|
||||
bm1, ok := self.bitmap_cache[bitmap_id]
|
||||
var bm IBitmap
|
||||
if ok {
|
||||
bm = bm1.bitmap
|
||||
} else {
|
||||
bm = self.GetFilter(bitmap_id, filter) //aways overwrites what is in cass filter type
|
||||
}
|
||||
change, chunk, address := SetBit(bm, bit_pos)
|
||||
if change {
|
||||
val := chunk.Value.Block[address.BlockIndex]
|
||||
|
|
@ -105,7 +115,6 @@ func (self *Brand) SetBit(bitmap_id uint64, bit_pos uint64, filter uint64) bool
|
|||
}
|
||||
|
||||
func (self *Brand) Rank() {
|
||||
log.Println("RANK")
|
||||
if self.rank_counter <= 0 {
|
||||
self.rank_counter = self.skip
|
||||
} else {
|
||||
|
|
@ -127,7 +136,9 @@ func (self *Brand) Rank() {
|
|||
} else {
|
||||
self.threshold_value = 0
|
||||
}
|
||||
log.Println("RANK DONE")
|
||||
|
||||
//dump(self.rankings, 10)
|
||||
|
||||
}
|
||||
|
||||
func packagePairs(r RankList) []Pair {
|
||||
|
|
@ -176,20 +187,16 @@ func (self *Brand) TopN(src_bitmap IBitmap, n int, categories []uint64) []Pair {
|
|||
self.rank_counter = 0
|
||||
self.Rank() // TODO: TERRIBLE REMOVE THIS ASAP
|
||||
is := NewIntSet()
|
||||
log.Println("ok")
|
||||
|
||||
for _, v := range categories {
|
||||
log.Println(is)
|
||||
log.Println(v)
|
||||
is.Add(v)
|
||||
|
||||
}
|
||||
log.Println("more")
|
||||
|
||||
return self.TopNCat(src_bitmap, n, is)
|
||||
}
|
||||
func dump(r RankList, n int) {
|
||||
for i, v := range r {
|
||||
println("DUMPING:", i, v.Key, v.Count)
|
||||
log.Println(i, v)
|
||||
if i > n {
|
||||
return
|
||||
}
|
||||
|
|
@ -303,9 +310,7 @@ func (self *Brand) Persist() error {
|
|||
list = append(list, &Rank{&Pair{k, item.bitmap.Count()}, item.bitmap, item.category})
|
||||
}
|
||||
|
||||
log.Println("Sorting..")
|
||||
sort.Sort(list)
|
||||
log.Println("..Done")
|
||||
|
||||
results := make([]uint64, asize)
|
||||
i := 0
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ func TestFragment(t *testing.T) {
|
|||
brand := util.Hex_to_SUUID("2")
|
||||
dummy := NewFragmentContainer()
|
||||
dummy.AddFragment("25", "general", 0, general)
|
||||
dummy.AddFragment("25", "Brand", 0, brand)
|
||||
dummy.AddFragment("25", "b.n", 0, brand)
|
||||
|
||||
Convey("Get ", t, func() {
|
||||
bh, _ := dummy.Get(general, 1234)
|
||||
|
|
@ -129,20 +129,21 @@ func TestFragment(t *testing.T) {
|
|||
log.Println(dummy.Stats(brand))
|
||||
So(1, ShouldEqual, 1)
|
||||
})
|
||||
Convey("Brand TopN", t, func() {
|
||||
max_brands := uint64(5000)
|
||||
for i := uint64(0); i < max_brands; i++ {
|
||||
for x := uint64(0); x < i; x = x + 1 {
|
||||
dummy.SetBit(brand, uint64(i), x)
|
||||
}
|
||||
|
||||
}
|
||||
bh1, _ := dummy.Get(brand, uint64(4999))
|
||||
log.Println(dummy.TopN(brand, bh1, 4))
|
||||
|
||||
So(1, ShouldEqual, 1)
|
||||
})
|
||||
*/
|
||||
Convey("Brand TopN", t, func() {
|
||||
dummy.SetBit(brand, uint64(1), 1, 2)
|
||||
dummy.SetBit(brand, uint64(1), 2, 2)
|
||||
dummy.SetBit(brand, uint64(1), 3, 2)
|
||||
dummy.SetBit(brand, uint64(2), 1, 2)
|
||||
dummy.SetBit(brand, uint64(2), 2, 2)
|
||||
dummy.SetBit(brand, uint64(3), 1, 2)
|
||||
bh1, _ := dummy.Get(brand, uint64(1))
|
||||
c := []uint64{2}
|
||||
results, _ := dummy.TopN(brand, bh1, 4, c)
|
||||
pair := results[0]
|
||||
So(pair.Key, ShouldEqual, 1)
|
||||
So(pair.Count, ShouldEqual, 3)
|
||||
})
|
||||
Convey("Clear ", t, func() {
|
||||
res, _ := dummy.Clear(general)
|
||||
So(res, ShouldEqual, true)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue