From c1597842d0cb9fe67d68e95254052d497f659c16 Mon Sep 17 00:00:00 2001 From: Steve Yen Date: Fri, 11 Mar 2016 15:47:09 -0800 Subject: [PATCH] moss lowerLevelUpdate didn't handle batches of size 1 --- index/store/moss/lower.go | 21 ++++++++++++++------- index/store/moss/store.go | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/index/store/moss/lower.go b/index/store/moss/lower.go index 842b3d3f..11740380 100644 --- a/index/store/moss/lower.go +++ b/index/store/moss/lower.go @@ -55,9 +55,11 @@ func initLowerLevelStore( } llStore := &llStore{ - refs: 0, - kvStore: kvStore, - logf: logf, + refs: 0, + config: config, + llConfig: lowerLevelStoreConfig, + kvStore: kvStore, + logf: logf, } llUpdate := func(ssHigher moss.Snapshot) (ssLower moss.Snapshot, err error) { @@ -80,6 +82,9 @@ func initLowerLevelStore( type llStore struct { kvStore store.KVStore + config map[string]interface{} + llConfig map[string]interface{} + logf func(format string, a ...interface{}) m sync.Mutex // Protects fields that follow. @@ -219,6 +224,8 @@ func (s *llStore) update(ssHigher moss.Snapshot, maxBatchSize uint64) ( " unexpected operation, ex: %v", ex) } + i++ + err = iter.Next() if err == moss.ErrIteratorDone { break @@ -240,19 +247,19 @@ func (s *llStore) update(ssHigher moss.Snapshot, maxBatchSize uint64) ( batch = kvWriter.NewBatch() } - - i++ } if i > 0 { - s.logf("llStore.update, total: %d, ExecuteBatch: ...", i) + s.logf("llStore.update, ExecuteBatch,"+ + " path: %s, total: %d, start", s.llConfig["path"], i) err = kvWriter.ExecuteBatch(batch) if err != nil { return nil, err } - s.logf("llStore.update, total: %d, ExecuteBatch: done", i) + s.logf("llStore.update, ExecuteBatch,"+ + " path: %s: total: %d, done", s.llConfig["path"], i) } } diff --git a/index/store/moss/store.go b/index/store/moss/store.go index ca51b48a..4ae12e5a 100644 --- a/index/store/moss/store.go +++ b/index/store/moss/store.go @@ -82,7 +82,7 @@ func New(mo store.MergeOperator, config map[string]interface{}) ( // -------------------------------------------------- - if options.Log == nil { + if options.Log == nil || options.Debug <= 0 { options.Log = func(format string, a ...interface{}) {} }