MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / GetInUseIndexesFromDefs

Method GetInUseIndexesFromDefs

db/database.go:795–830  ·  view source on GitHub ↗

GetInUseIndexesFromDefs returns the name of the indexes on this database. indexDefs refers to the global indexDefs as sgIndexes, or a testing seam passed in.

(indexDefs map[SGIndexType]SGIndex)

Source from the content-addressed store, hash-verified

793
794// GetInUseIndexesFromDefs returns the name of the indexes on this database. indexDefs refers to the global indexDefs as sgIndexes, or a testing seam passed in.
795func (dbCtx *DatabaseContext) GetInUseIndexesFromDefs(indexDefs map[SGIndexType]SGIndex) CollectionIndexes {
796 dataStores := dbCtx.getDataStores()
797 inUseIndexes := make(CollectionIndexes)
798 for _, ds := range dataStores {
799 options := InitializeIndexOptions{
800 NumPartitions: dbCtx.numIndexPartitions(),
801 NumReplicas: dbCtx.Options.NumIndexReplicas,
802 UseXattrs: dbCtx.UseXattrs(),
803 LegacySyncDocsIndex: dbCtx.UseLegacySyncDocsIndex(),
804 }
805 if base.IsDefaultCollection(ds.ScopeName(), ds.CollectionName()) {
806 if dbCtx.HasDefaultCollection() {
807 options.MetadataIndexes = IndexesAll
808 } else {
809 options.MetadataIndexes = IndexesMetadataOnly
810 }
811 } else {
812 options.MetadataIndexes = IndexesWithoutMetadata
813 }
814 dsName := base.ScopeAndCollectionName{
815 Scope: ds.ScopeName(),
816 Collection: ds.CollectionName(),
817 }
818 // datastore can be listed twice for explicit default and for metadata store
819 if _, ok := inUseIndexes[dsName]; !ok {
820 inUseIndexes[dsName] = make(map[string]struct{})
821 }
822 if dbCtx.UseViews() {
823 continue
824 }
825 for _, index := range GetIndexNames(options, indexDefs) {
826 inUseIndexes[dsName][index] = struct{}{}
827 }
828 }
829 return inUseIndexes
830}
831
832// Trigger terminate check handling for connected continuous replications.
833// TODO: The underlying code (NotifyCheckForTermination) doesn't actually leverage the specific username - should be refactored

Callers 3

GetInUseIndexesMethod · 0.95

Calls 10

getDataStoresMethod · 0.95
numIndexPartitionsMethod · 0.95
UseXattrsMethod · 0.95
HasDefaultCollectionMethod · 0.95
UseViewsMethod · 0.95
IsDefaultCollectionFunction · 0.92
GetIndexNamesFunction · 0.85
ScopeNameMethod · 0.45
CollectionNameMethod · 0.45

Tested by 2