github.com/weaviate/weaviate@v1.24.6/adapters/repos/db/shard_accessors.go (about)

     1  //                           _       _
     2  // __      _____  __ ___   ___  __ _| |_ ___
     3  // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
     4  //  \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
     5  //   \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
     6  //
     7  //  Copyright © 2016 - 2024 Weaviate B.V. All rights reserved.
     8  //
     9  //  CONTACT: hello@weaviate.io
    10  //
    11  
    12  // Some standard accessors for the shard struct.
    13  // It is important to NEVER access the shard struct directly, because we lazy load shards, so the information might not be there.
    14  package db
    15  
    16  import (
    17  	"github.com/weaviate/weaviate/adapters/repos/db/indexcounter"
    18  	"github.com/weaviate/weaviate/adapters/repos/db/inverted"
    19  	"github.com/weaviate/weaviate/adapters/repos/db/lsmkv"
    20  	"github.com/weaviate/weaviate/entities/schema"
    21  )
    22  
    23  func (s *Shard) Queue() *IndexQueue {
    24  	return s.queue
    25  }
    26  
    27  func (s *Shard) Queues() map[string]*IndexQueue {
    28  	return s.queues
    29  }
    30  
    31  func (s *Shard) VectorIndex() VectorIndex {
    32  	return s.vectorIndex
    33  }
    34  
    35  func (s *Shard) VectorIndexes() map[string]VectorIndex {
    36  	return s.vectorIndexes
    37  }
    38  
    39  func (s *Shard) VectorIndexForName(targetVector string) VectorIndex {
    40  	return s.vectorIndexes[targetVector]
    41  }
    42  
    43  func (s *Shard) Versioner() *shardVersioner {
    44  	return s.versioner
    45  }
    46  
    47  func (s *Shard) Index() *Index {
    48  	return s.index
    49  }
    50  
    51  // Shard name(identifier?)
    52  func (s *Shard) Name() string {
    53  	return s.name
    54  }
    55  
    56  // The physical data store
    57  func (s *Shard) Store() *lsmkv.Store {
    58  	return s.store
    59  }
    60  
    61  func (s *Shard) Counter() *indexcounter.Counter {
    62  	return s.counter
    63  }
    64  
    65  // Tracks the lengths of all properties.  Must be updated on inserts/deletes.
    66  func (s *Shard) GetPropertyLengthTracker() *inverted.JsonPropertyLengthTracker {
    67  	return s.propLenTracker
    68  }
    69  
    70  // Tracks the lengths of all properties.  Must be updated on inserts/deletes.
    71  func (s *Shard) SetPropertyLengthTracker(tracker *inverted.JsonPropertyLengthTracker) {
    72  	s.propLenTracker = tracker
    73  }
    74  
    75  // Grafana metrics
    76  func (s *Shard) Metrics() *Metrics {
    77  	return s.metrics
    78  }
    79  
    80  func (s *Shard) setFallbackToSearchable(fallback bool) {
    81  	s.fallbackToSearchable = fallback
    82  }
    83  
    84  func (s *Shard) addJobToQueue(job job) {
    85  	s.centralJobQueue <- job
    86  }
    87  
    88  func (s *Shard) hasGeoIndex() bool {
    89  	s.propertyIndicesLock.RLock()
    90  	defer s.propertyIndicesLock.RUnlock()
    91  
    92  	for _, idx := range s.propertyIndices {
    93  		if idx.Type == schema.DataTypeGeoCoordinates {
    94  			return true
    95  		}
    96  	}
    97  	return false
    98  }