public static string FindDynamicIndexName(this DocumentDatabase self, string entityName, IndexQuery query) { var result = new DynamicQueryOptimizer(self).SelectAppropriateIndex(entityName, query.Clone()); if (result.MatchType == DynamicQueryMatchType.Complete) return result.IndexName; return null; }
private Tuple<string, bool> GetAppropriateIndexToQuery(string entityName, IndexQuery query, DynamicQueryMapping map) { var appropriateIndex = new DynamicQueryOptimizer(documentDatabase).SelectAppropriateIndex(entityName, query); if (appropriateIndex != null) { if (appropriateIndex.StartsWith("Temp/"))// temporary index, we need to increase its usage { return TouchTemporaryIndex(appropriateIndex, "Auto/" + appropriateIndex.Substring(5), () => documentDatabase.IndexDefinitionStorage.GetIndexDefinition(appropriateIndex)); } return Tuple.Create(appropriateIndex, false); } return TouchTemporaryIndex(map.TemporaryIndexName, map.PermanentIndexName, map.CreateIndexDefinition); }
private Tuple <string, bool> GetAppropriateIndexToQuery(string entityName, IndexQuery query, DynamicQueryMapping map) { var appropriateIndex = new DynamicQueryOptimizer(documentDatabase).SelectAppropriateIndex(entityName, query); if (appropriateIndex.MatchType == DynamicQueryMatchType.Complete) { map.IndexName = appropriateIndex.IndexName; return(Tuple.Create(appropriateIndex.IndexName, false)); } if (appropriateIndex.MatchType == DynamicQueryMatchType.Partial) { // At this point, we found an index that has some fields we need and // isn't incompatible with anything else we're asking for // We need to clone that other index // We need to add all our requested indexes information to our cloned index // We can then use our new index instead var currentIndex = documentDatabase.IndexDefinitionStorage.GetIndexDefinition(appropriateIndex.IndexName); map.AddExistingIndexDefinition(currentIndex, documentDatabase, query); } return(CreateAutoIndex(map.IndexName, map.CreateIndexDefinition)); }
private Tuple<string, bool> GetAppropriateIndexToQuery(string entityName, IndexQuery query, DynamicQueryMapping map) { var appropriateIndex = new DynamicQueryOptimizer(documentDatabase).SelectAppropriateIndex(entityName, query); if (appropriateIndex.MatchType == DynamicQueryMatchType.Complete) { map.IndexName = appropriateIndex.IndexName; return Tuple.Create(appropriateIndex.IndexName, false); } else if (appropriateIndex.MatchType == DynamicQueryMatchType.Partial) { // At this point, we found an index that has some fields we need and // isn't incompatible with anything else we're asking for // We need to clone that other index // We need to add all our requested indexes information to our cloned index // We can then use our new index instead var currentIndex = documentDatabase.IndexDefinitionStorage.GetIndexDefinition(appropriateIndex.IndexName); map.AddExistingIndexDefinition(currentIndex, documentDatabase, query); } return CreateAutoIndex(map.IndexName, map.CreateIndexDefinition); }