From 06ad83b64b9a9cfda0df1369c4374c120c79326a Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Tue, 3 Jul 2018 08:10:33 -0500 Subject: [PATCH] more unexports - index methods and fields --- cluster.go | 2 +- diagnostics.go | 2 +- executor.go | 2 +- holder.go | 14 +++++++------- holder_internal_test.go | 4 ++-- index.go | 34 +++++++++++++++++----------------- server.go | 4 ++-- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/cluster.go b/cluster.go index 4bd02c76c..acf06dae0 100644 --- a/cluster.go +++ b/cluster.go @@ -623,7 +623,7 @@ func (c *cluster) fragsByHost(idx *Index) fragsByHost { } } - return c.fragCombos(idx.Name(), idx.MaxShard(), fieldViews) + return c.fragCombos(idx.Name(), idx.maxShard(), fieldViews) } // fragCombos returns a map (by uri) of lists of fragments for a given index diff --git a/diagnostics.go b/diagnostics.go index 74e7eebcf..6ad6e16b1 100644 --- a/diagnostics.go +++ b/diagnostics.go @@ -223,7 +223,7 @@ func (d *DiagnosticsCollector) EnrichWithSchemaProperties() { timeQuantumEnabled := false for _, index := range d.server.holder.Indexes() { - numShards += index.MaxShard() + 1 + numShards += index.maxShard() + 1 numIndexes += 1 for _, field := range index.Fields() { numFields += 1 diff --git a/executor.go b/executor.go index b8a7713a7..1a81e92bd 100644 --- a/executor.go +++ b/executor.go @@ -135,7 +135,7 @@ func (e *executor) execute(ctx context.Context, index string, q *pql.Query, shar if idx == nil { return nil, ErrIndexNotFound } - maxShard := idx.MaxShard() + maxShard := idx.maxShard() // Generate a slice of all shards. shards = make([]uint64, maxShard+1) diff --git a/holder.go b/holder.go index 4fb84aefc..bc255abba 100644 --- a/holder.go +++ b/holder.go @@ -204,7 +204,7 @@ func (h *Holder) HasData() (bool, error) { func (h *Holder) maxShards() map[string]uint64 { a := make(map[string]uint64) for _, index := range h.Indexes() { - a[index.Name()] = index.MaxShard() + a[index.Name()] = index.maxShard() } return a } @@ -267,7 +267,7 @@ func (h *Holder) encodeMaxShards() *internal.MaxShards { // encodeSchema creates an internal representation of schema. func (h *Holder) encodeSchema() *internal.Schema { return &internal.Schema{ - Indexes: EncodeIndexes(h.Indexes()), + Indexes: encodeIndexes(h.Indexes()), } } @@ -358,11 +358,11 @@ func (h *Holder) newIndex(path, name string) (*Index, error) { if err != nil { return nil, err } - index.Logger = h.Logger + index.logger = h.Logger index.Stats = h.Stats.WithTags(fmt.Sprintf("index:%s", index.Name())) index.broadcaster = h.broadcaster - index.NewAttrStore = h.NewAttrStore - index.columnAttrStore = h.NewAttrStore(filepath.Join(index.path, ".data")) + index.newAttrStore = h.NewAttrStore + index.columnAttrs = h.NewAttrStore(filepath.Join(index.path, ".data")) return index, nil } @@ -623,7 +623,7 @@ func (s *holderSyncer) SyncHolder() error { return nil } - for shard := uint64(0); shard <= s.Holder.Index(di.Name).MaxShard(); shard++ { + for shard := uint64(0); shard <= s.Holder.Index(di.Name).maxShard(); shard++ { // Ignore shards that this host doesn't own. if !s.Cluster.ownsShard(s.Node.ID, di.Name, shard) { continue @@ -804,7 +804,7 @@ func (c *holderCleaner) CleanHolder() error { } // Get the fragments that node is responsible for (based on hash(index, node)). - containedShards := c.Cluster.containsShards(index.Name(), index.MaxShard(), c.Node) + containedShards := c.Cluster.containsShards(index.Name(), index.maxShard(), c.Node) // Get the fragments registered in memory. for _, field := range index.Fields() { diff --git a/holder_internal_test.go b/holder_internal_test.go index 95ce55be4..425873005 100644 --- a/holder_internal_test.go +++ b/holder_internal_test.go @@ -211,8 +211,8 @@ func TestHolderCleaner_CleanHolder(t *testing.T) { hldr0.SetBit("y", "z", 10, (2*ShardWidth)+7) // Set highest shard. - hldr0.Index("i").SetRemoteMaxShard(1) - hldr0.Index("y").SetRemoteMaxShard(2) + hldr0.Index("i").setRemoteMaxShard(1) + hldr0.Index("y").setRemoteMaxShard(2) // Keep replication the same and ensure we get the expected results. cluster.ReplicaN = 2 diff --git a/index.go b/index.go index c1ae5de9e..d1a6a8ee5 100644 --- a/index.go +++ b/index.go @@ -41,15 +41,15 @@ type Index struct { // Max shard on any node in the cluster, according to this node. remoteMaxShard uint64 - NewAttrStore func(string) AttrStore + newAttrStore func(string) AttrStore // Column attribute storage and cache. - columnAttrStore AttrStore + columnAttrs AttrStore broadcaster broadcaster Stats StatsClient - Logger Logger + logger Logger } // NewIndex returns a new instance of Index. @@ -66,12 +66,12 @@ func NewIndex(path, name string) (*Index, error) { remoteMaxShard: 0, - NewAttrStore: newNopAttrStore, - columnAttrStore: nopStore, + newAttrStore: newNopAttrStore, + columnAttrs: nopStore, broadcaster: NopBroadcaster, Stats: NopStatsClient, - Logger: NopLogger, + logger: NopLogger, }, nil } @@ -85,7 +85,7 @@ func (i *Index) Path() string { return i.path } func (i *Index) Keys() bool { return i.keys } // ColumnAttrStore returns the storage for column attributes. -func (i *Index) ColumnAttrStore() AttrStore { return i.columnAttrStore } +func (i *Index) ColumnAttrStore() AttrStore { return i.columnAttrs } // Options returns all options for this index. func (i *Index) Options() IndexOptions { @@ -114,7 +114,7 @@ func (i *Index) Open() error { return errors.Wrap(err, "opening fields") } - if err := i.columnAttrStore.Open(); err != nil { + if err := i.columnAttrs.Open(); err != nil { return errors.Wrap(err, "opening attrstore") } @@ -197,7 +197,7 @@ func (i *Index) Close() error { defer i.mu.Unlock() // Close the attribute store. - i.columnAttrStore.Close() + i.columnAttrs.Close() // Close all fields. for _, f := range i.fields { @@ -210,8 +210,8 @@ func (i *Index) Close() error { return nil } -// MaxShard returns the max shard in the index according to this node. -func (i *Index) MaxShard() uint64 { +// maxShard returns the max shard in the index according to this node. +func (i *Index) maxShard() uint64 { if i == nil { return 0 } @@ -229,8 +229,8 @@ func (i *Index) MaxShard() uint64 { return max } -// SetRemoteMaxShard sets the remote max shard value received from another node. -func (i *Index) SetRemoteMaxShard(newmax uint64) { +// setRemoteMaxShard sets the remote max shard value received from another node. +func (i *Index) setRemoteMaxShard(newmax uint64) { i.mu.Lock() defer i.mu.Unlock() i.remoteMaxShard = newmax @@ -334,10 +334,10 @@ func (i *Index) newField(path, name string) (*Field, error) { if err != nil { return nil, err } - f.Logger = i.Logger + f.Logger = i.logger f.Stats = i.Stats.WithTags(fmt.Sprintf("field:%s", name)) f.broadcaster = i.broadcaster - f.rowAttrStore = i.NewAttrStore(filepath.Join(f.path, ".data")) + f.rowAttrStore = i.newAttrStore(filepath.Join(f.path, ".data")) return f, nil } @@ -386,8 +386,8 @@ func (p indexInfoSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } func (p indexInfoSlice) Len() int { return len(p) } func (p indexInfoSlice) Less(i, j int) bool { return p[i].Name < p[j].Name } -// EncodeIndexes converts a into its internal representation. -func EncodeIndexes(a []*Index) []*internal.Index { +// encodeIndexes converts a into its internal representation. +func encodeIndexes(a []*Index) []*internal.Index { other := make([]*internal.Index, len(a)) for i := range a { other[i] = encodeIndex(a[i]) diff --git a/server.go b/server.go index 93a5dac36..7fbd94066 100644 --- a/server.go +++ b/server.go @@ -439,7 +439,7 @@ func (s *Server) ReceiveMessage(pb proto.Message) error { if idx == nil { return fmt.Errorf("Local Index not found: %s", obj.Index) } - idx.SetRemoteMaxShard(obj.Shard) + idx.setRemoteMaxShard(obj.Shard) case *internal.CreateIndexMessage: opt := IndexOptions{} _, err := s.holder.CreateIndex(obj.Index, opt) @@ -622,7 +622,7 @@ func (s *Server) mergeRemoteStatus(ns *internal.NodeStatus) error { } if newMax > oldmaxshards[index] { oldmaxshards[index] = newMax - localIndex.SetRemoteMaxShard(newMax) + localIndex.setRemoteMaxShard(newMax) } }