private void ReadAllAggregations(DbIterator it) { Slice prefix = "aggregators/"; it.Seek(prefix); while(it.WithPrefix(prefix)) { string name = Encoding.UTF8.GetString(it.Key.Array, it.Key.Offset, it.Key.Count); using (var stream = it.CreateValueStream()) { var indexDefinition = new JsonSerializer().Deserialize<IndexDefinition>(new JsonTextReader(new StreamReader(stream))); _log.Info("Reading aggregator {0}", indexDefinition.Name); AbstractViewGenerator generator = null; try { var dynamicViewCompiler = new DynamicViewCompiler(indexDefinition.Name, indexDefinition, Path.Combine(_path, "Generators")); generator = dynamicViewCompiler.GenerateInstance(); } catch (Exception e) { _log.WarnException("Could not create instance of aggregator " + indexDefinition.Name, e); // could not create generator, ignoring this and deleting the generator RemoveAggregation(name); } if (generator != null) { var aggregator = new Aggregator(this, indexDefinition.Name, generator); _aggregations.TryAdd(indexDefinition.Name, aggregator); Background.Work(aggregator.StartAggregation); } } it.Next(); } }