cleanup TypedDBPerShardGetShardsForIndex logic

This commit is contained in:
Jason E. Aten 2020-10-29 22:25:06 +00:00
parent f8e7b27a6f
commit 18e253870e

View file

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