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)
| 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. |
| 795 | func (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 |