more logging

This commit is contained in:
Todd Gruben 2014-04-17 12:21:36 -05:00
parent 83a05152c3
commit 1424d18e8b
5 changed files with 12 additions and 3 deletions

View file

@ -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)

View file

@ -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})

View file

@ -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()
}

View file

@ -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

View file

@ -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")