diff --git a/core/service.go b/core/service.go index c94e2d60f..3b5063884 100644 --- a/core/service.go +++ b/core/service.go @@ -48,7 +48,7 @@ func NewService() *Service { service.WebService = NewWebService(service) service.Index = index.NewFragmentContainer() service.Hold = hold.NewHolder() - service.version = "0.0.19" + service.version = "0.0.20" service.name = "Cruncher" service.PrepareLogging() fmt.Printf("Pilosa %s\n", service.version) diff --git a/index/brand.go b/index/brand.go index 6403db638..cde080e4c 100644 --- a/index/brand.go +++ b/index/brand.go @@ -85,6 +85,7 @@ func (self *Brand) cache_it(bm IBitmap, bitmap_id uint64, category uint64) { if bm.Count() >= self.threshold_value { self.bitmap_cache[bitmap_id] = &Rank{&Pair{bitmap_id, bm.Count()}, bm, category} if len(self.bitmap_cache) > self.threshold_length { + log.Printf("RANK: %d %d", len(self.bitmap_cache), self.threshold_length) self.Rank() self.trim() } @@ -302,7 +303,13 @@ func (self *Brand) getFileName() string { func (self *Brand) Persist() error { log.Println("Brand Persist:", self.getFileName()) + self.storage.FlushBatch() + asize := len(self.bitmap_cache) + if asize == 0 { + log.Println("Nothing to save %s", self.getFileName()) + return nil + } w, err := util.Create(self.getFileName()) if err != nil { log.Println("Error opening outfile %s", self.getFileName()) @@ -312,7 +319,6 @@ func (self *Brand) Persist() error { defer w.Close() defer self.storage.Close() - asize := len(self.bitmap_cache) var list RankList for k, item := range self.bitmap_cache { list = append(list, &Rank{&Pair{k, item.bitmap.Count()}, item.bitmap, item.category}) diff --git a/index/storage.go b/index/storage.go index ac774066e..031be6c3d 100644 --- a/index/storage.go +++ b/index/storage.go @@ -6,5 +6,6 @@ type Storage interface { StoreBlock(id int64, db string, frame string, slice int, filter uint64, chunk int64, block_index int32, block int64) error BeginBatch() EndBatch() + FlushBatch() Close() } diff --git a/index/storage_cass.go b/index/storage_cass.go index 26b894f03..a8d7e168a 100644 --- a/index/storage_cass.go +++ b/index/storage_cass.go @@ -106,7 +106,7 @@ func (self *CassandraStorage) runBatch(batch *gocql.Batch) { } func (self *CassandraStorage) FlushBatch() { start := time.Now() - go self.runBatch(self.batch) //maybe this is crazy but i'll give it a whirl + self.runBatch(self.batch) //maybe this is crazy but i'll give it a whirl self.batch = nil self.batch_time = time.Now() self.batch_counter = 0 diff --git a/index/storage_mem.go b/index/storage_mem.go index 38043ba78..dd05474d5 100644 --- a/index/storage_mem.go +++ b/index/storage_mem.go @@ -22,6 +22,8 @@ func (c *MemoryStorage) Close() { } func (c *MemoryStorage) EndBatch() { } +func (c *MemoryStorage) FlushBatch() { +} func (c *MemoryStorage) Fetch(bitmap_id uint64, db string, frame string, slice int) (IBitmap, uint64) { // log.Println("hello")