cleanup and comments

This commit is contained in:
Todd Gruben 2020-03-24 11:24:02 -05:00
parent 40a3dce93c
commit af068e08e7
2 changed files with 13 additions and 16 deletions

View file

@ -413,11 +413,10 @@ func (f *Field) AvailableShards() *roaring.Bitmap {
return b
}
// constainsShard is used for limiting unnecessary CreateShard broadcast
func (f *Field) containsShard(shard uint64) bool {
f.mu.RLock()
defer f.mu.RUnlock()
fmt.Println("CONTAINS SHARD:", shard, f.Name())
fmt.Println(f.remoteAvailableShards)
return f.remoteAvailableShards.Contains(shard)
}
@ -1187,7 +1186,7 @@ func (f *Field) newView(path, name string) *view {
view.rowAttrStore = f.rowAttrStore
view.stats = f.Stats
view.broadcaster = f.broadcaster
view.shardPresent = f.containsShard
view.remoteShardPresent = f.containsShard
if f.snapshotQueue != nil {
view.snapshotQueue = f.snapshotQueue
}

24
view.go
View file

@ -55,12 +55,12 @@ type view struct {
// Fragments by shard.
fragments map[uint64]*fragment
broadcaster broadcaster
stats stats.StatsClient
rowAttrStore AttrStore
logger logger.Logger
snapshotQueue snapshotQueue
shardPresent func(uint64) bool
broadcaster broadcaster
stats stats.StatsClient
rowAttrStore AttrStore
logger logger.Logger
snapshotQueue snapshotQueue
remoteShardPresent func(uint64) bool
}
// newView returns a new instance of View.
@ -77,10 +77,10 @@ func newView(path, index, field, name string, fieldOptions FieldOptions) *view {
fragments: make(map[uint64]*fragment),
broadcaster: NopBroadcaster,
stats: stats.NopStatsClient,
logger: logger.NopLogger,
shardPresent: func(uint64) bool { return false },
broadcaster: NopBroadcaster,
stats: stats.NopStatsClient,
logger: logger.NopLogger,
remoteShardPresent: func(uint64) bool { return false },
}
}
@ -283,11 +283,9 @@ func (v *view) CreateFragmentIfNotExists(shard uint64) (*fragment, error) {
}
func (v *view) notifyIfNew(shard uint64) {
fmt.Println("Present", shard)
if v.shardPresent(shard) {
if v.remoteShardPresent(shard) { //checks the fields remoteShards bitmap to see if broadcast needed
return
}
fmt.Println("BROADCAST", shard)
broadcastChan := make(chan struct{})
go func() {