mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-08 20:07:51 +00:00
more unexports - index methods and fields
This commit is contained in:
parent
f78af41565
commit
06ad83b64b
7 changed files with 31 additions and 31 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
14
holder.go
14
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() {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
34
index.go
34
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])
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue