private static string GetTreeName(BlittableJsonReaderObject reduceEntry, IndexDefinitionBase indexDefinition, JsonOperationContext context) { HashSet <string> groupByFields; if (indexDefinition is MapReduceIndexDefinition) { groupByFields = ((MapReduceIndexDefinition)indexDefinition).GroupByFields; } else if (indexDefinition is AutoMapReduceIndexDefinition) { groupByFields = ((AutoMapReduceIndexDefinition)indexDefinition).GroupByFields.Keys.ToHashSet(); } else { throw new InvalidOperationException("Invalid map reduce index definition: " + indexDefinition.GetType()); } foreach (var prop in reduceEntry.GetPropertyNames()) { if (groupByFields.Contains(prop)) { continue; } if (reduceEntry.Modifications == null) { reduceEntry.Modifications = new DynamicJsonValue(reduceEntry); } reduceEntry.Modifications.Remove(prop); } var reduceKey = context.ReadObject(reduceEntry, "debug: creating reduce tree name"); return(reduceKey.ToString()); }
private static string GetTreeName(BlittableJsonReaderObject reduceEntry, IndexDefinitionBase indexDefinition, JsonOperationContext context) { HashSet <CompiledIndexField> groupByFields; if (indexDefinition is MapReduceIndexDefinition) { groupByFields = ((MapReduceIndexDefinition)indexDefinition).GroupByFields; } else if (indexDefinition is AutoMapReduceIndexDefinition) { groupByFields = ((AutoMapReduceIndexDefinition)indexDefinition).GroupByFields.Keys .Select(x => (CompiledIndexField) new SimpleField(x)) .ToHashSet(); } else { throw new InvalidOperationException("Invalid map reduce index definition: " + indexDefinition.GetType()); } foreach (var prop in reduceEntry.GetPropertyNames()) { var skip = false; foreach (var groupByField in groupByFields) { if (groupByField.IsMatch(prop)) { skip = true; break; } } if (skip) { continue; } if (reduceEntry.Modifications == null) { reduceEntry.Modifications = new DynamicJsonValue(reduceEntry); } reduceEntry.Modifications.Remove(prop); } var reduceKey = context.ReadObject(reduceEntry, "debug: creating reduce tree name"); return(reduceKey.ToString()); }