From 7d897c1cf73081ae511afb1a36b9f1a274440f3a Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Wed, 22 Jan 2014 12:05:27 -0600 Subject: [PATCH] missed some files --- index/fragment_container_test.go | 72 +++++++++++++++++++------------- index/general.go | 7 ++++ index/storage_test.go | 26 ++++++------ 3 files changed, 63 insertions(+), 42 deletions(-) diff --git a/index/fragment_container_test.go b/index/fragment_container_test.go index de96ddb2e..ab43c01bc 100644 --- a/index/fragment_container_test.go +++ b/index/fragment_container_test.go @@ -1,7 +1,6 @@ package index import ( - "log" "testing" // "io/ioutil" @@ -92,50 +91,63 @@ func TestFragment(t *testing.T) { So(num, ShouldEqual, 2) }) - Convey("Brand SetBit", t, func() { - bi1 := uint64(1231) - bi2 := uint64(1232) - bi3 := uint64(1233) - bi4 := uint64(1234) + Convey("Brand SetBit Small", t, func() { + bi1 := uint64(1029) for x := uint64(0); x < 1000; x++ { - if x < 100 { - dummy.SetBit(brand, bi1, x) - dummy.SetBit(brand, bi4, x) - } - if x < 500 { - dummy.SetBit(brand, bi2, x) - } - if x%3 == 0 { - dummy.SetBit(brand, bi3, x) - } - if x > 700 { - dummy.SetBit(brand, bi4, x) - } + dummy.SetBit(brand, bi1, x) } - bh1, _ := dummy.Get(brand, bi1) - // dummy.Rank() - log.Println(dummy.TopN(brand, bh1, 4)) 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) + Convey("Brand SetBit Big", t, func() { + bi1 := uint64(1231) + bi2 := uint64(1232) + bi3 := uint64(1233) + bi4 := uint64(1234) + for x := uint64(0); x < 60000; x++ { + if x < 100 { + dummy.SetBit(brand, bi1, x) + dummy.SetBit(brand, bi4, x) + } + if x < 500 { + dummy.SetBit(brand, bi2, x) + } + if x%3 == 0 && x < 1000 { + dummy.SetBit(brand, bi3, x) + } + if x > 700 && x < 1000 { + dummy.SetBit(brand, bi4, x) + } + if x > 1000 { + dummy.SetBit(brand, x, x) } - } - bh1, _ := dummy.Get(brand, uint64(4999)) + bh1, _ := dummy.Get(brand, bi1) + // dummy.Rank() log.Println(dummy.TopN(brand, bh1, 4)) - + 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("Clear ", t, func() { res, _ := dummy.Clear(general) So(res, ShouldEqual, true) }) + Convey("store ", t, func() { b := uint64(1029) compressed := "H4sIAAAJbogA/2JmYRBQ+9/IzMjI6pxRmpfN+L+JgZGJkdk7tZKRjYGRNSwxpzSV8X8LAwOD8v9moDIup5z85GzHoqLESpAwI1AjWITxfxtQjdT/VqAIV7SxUWxpZl6JmQlImJGN0YGB4R+j+v8mJkaFH/8h4B+M8X+UgcwAhZTm/yZgMCLCarC4bbAxYGHFNBpWBBmwsGIeDSuCDFhYsYyGFUEGLKxYR8OKIAMWVmyjYUWQwcDwfyYwqNgHLKjk4Q7BBAAAAAD//wEAAP//QNipzzcJAAA=" diff --git a/index/general.go b/index/general.go index bdc8bc0a6..07dcd1d04 100644 --- a/index/general.go +++ b/index/general.go @@ -54,3 +54,10 @@ func (self *General) Store(bitmap_id uint64, bm IBitmap) { self.storage.Store(int64(bitmap_id), self.db, self.slice, bm.(*Bitmap)) self.bitmap_cache.Add(bitmap_id, bm) } + +func (self *General) Stats() interface{} { + + stats := map[string]interface{}{ + "total size of cache in items": self.bitmap_cache.Len()} + return stats +} diff --git a/index/storage_test.go b/index/storage_test.go index 8fd31b710..7c27451ee 100644 --- a/index/storage_test.go +++ b/index/storage_test.go @@ -25,19 +25,21 @@ func TestStorage(t *testing.T) { So(BitCount(bm), ShouldEqual, 3) }) - Convey("cassandra", t, func() { - storage, _ := NewCassStorage("127.0.0.1", "hotbox") + /* + Convey("cassandra", t, func() { + storage, _ := NewCassStorage("127.0.0.1", "hotbox") - bm := storage.Fetch(bitmap_id, db, slice) - SetBit(bm, 0) - SetBit(bm, 1) - SetBit(bm, 2) - storage.Store(int64(bitmap_id), db, slice, bm.(*Bitmap)) - bm2 := storage.Fetch(bitmap_id, db, slice) - So(BitCount(bm), ShouldEqual, BitCount(bm2)) - So(BitCount(bm), ShouldEqual, bm.Count()) - So(BitCount(bm), ShouldEqual, 3) + bm := storage.Fetch(bitmap_id, db, slice) + SetBit(bm, 0) + SetBit(bm, 1) + SetBit(bm, 2) + storage.Store(int64(bitmap_id), db, slice, bm.(*Bitmap)) + bm2 := storage.Fetch(bitmap_id, db, slice) + So(BitCount(bm), ShouldEqual, BitCount(bm2)) + So(BitCount(bm), ShouldEqual, bm.Count()) + So(BitCount(bm), ShouldEqual, 3) - }) + }) + */ }