From f8e7b27a6f236c7dcb67120c79bb4369ae477a03 Mon Sep 17 00:00:00 2001 From: "Jason E. Aten" Date: Thu, 29 Oct 2020 22:09:55 +0000 Subject: [PATCH 1/2] don't apply startup shard cache to roaring with a specified view path - avoids creating a new empty 8 byte shard file under all the views that don't have them already. --- dbshard.go | 15 +++++++++++++++ txfactory.go | 2 ++ 2 files changed, 17 insertions(+) diff --git a/dbshard.go b/dbshard.go index ae69c8867..81efa7537 100644 --- a/dbshard.go +++ b/dbshard.go @@ -698,6 +698,21 @@ func (per *DBPerShard) TypedDBPerShardGetShardsForIndex(ty txtype, idx *Index, r per.Mu.Lock() defer per.Mu.Unlock() + if ty == roaringTxn && roaringViewPath != "" { + rx := &RoaringTx{ + Index: idx, + } + sos, err := rx.SliceOfShards("", "", "", roaringViewPath) + if err != nil { + return nil, err + } + shardMap = make(map[uint64]bool) + for _, shard := range sos { + shardMap[shard] = true + } + return shardMap, nil + } + i2ss, ok := per.index2shards[ty] if !ok { // index -> shardSet diff --git a/txfactory.go b/txfactory.go index 17ef34c75..e4a868806 100644 --- a/txfactory.go +++ b/txfactory.go @@ -1307,6 +1307,8 @@ func (f *TxFactory) green2blue(holder *Holder) (err error) { return nil } + holder.Logger.Printf("green2blue analysis begins.") + blueDest := f.types[0] greenSrc := f.types[1] From 18e253870eadabf0e171a69897f0d197d6d254b0 Mon Sep 17 00:00:00 2001 From: "Jason E. Aten" Date: Thu, 29 Oct 2020 22:25:06 +0000 Subject: [PATCH 2/2] cleanup TypedDBPerShardGetShardsForIndex logic --- dbshard.go | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/dbshard.go b/dbshard.go index 81efa7537..74d36c771 100644 --- a/dbshard.go +++ b/dbshard.go @@ -734,32 +734,24 @@ func (per *DBPerShard) TypedDBPerShardGetShardsForIndex(ty txtype, idx *Index, r // Upon return, cache the setOfShards value and reuse it next time if ty == roaringTxn { + // INVAR: roaringViewPath == "", because the other case is + // handled above. rx := &RoaringTx{ Index: idx, } - if roaringViewPath == "" { - fields := idx.Fields() - for _, field := range fields { - for _, view := range field.views() { - sos, err := rx.SliceOfShards("", "", "", view.path) - if err != nil { - return nil, - errors.Wrap(err, fmt.Sprintf( - "TypedDBPerShardGetLocalShardsForIndex roaringTxn view.path='%v'", view.path)) - } - for _, shard := range sos { - setOfShards.add(shard) - } + fields := idx.Fields() + for _, field := range fields { + for _, view := range field.views() { + sos, err := rx.SliceOfShards("", "", "", view.path) + if err != nil { + return nil, + errors.Wrap(err, fmt.Sprintf( + "TypedDBPerShardGetLocalShardsForIndex roaringTxn view.path='%v'", view.path)) + } + for _, shard := range sos { + setOfShards.add(shard) } } - return setOfShards.CloneMaybe(), nil - } - sos, err := rx.SliceOfShards("", "", "", roaringViewPath) - if err != nil { - return nil, err - } - for _, shard := range sos { - setOfShards.add(shard) } return setOfShards.CloneMaybe(), nil }