public override void Execute(WorkContext context) { if (ReduceKeys.Length == 0) { return; } var viewGenerator = context.IndexDefinitionStorage.GetViewGenerator(Index); if (viewGenerator == null) { return; // deleted view? } context.TransactionaStorage.Batch(actions => { var itemsToFind = ReduceKeys .Select(reduceKey => new GetMappedResultsParams(Index, reduceKey, MapReduceIndex.ComputeHash(Index, reduceKey))) .OrderBy(x => x.ViewAndReduceKeyHashed, new ByteComparer()) .ToArray(); var mappedResults = actions.MappedResults.GetMappedResults(itemsToFind) .Select(JsonToExpando.Convert); var sp = Stopwatch.StartNew(); log.Debug("Starting to read {0} reduce keys for index {1}", ReduceKeys.Length, Index); var results = mappedResults.ToArray(); log.Debug("Read {0} reduce keys in {1} with {2} results for index {3}", ReduceKeys.Length, sp.Elapsed, results.Length, Index); sp = Stopwatch.StartNew(); context.IndexStorage.Reduce(Index, viewGenerator, results, context, actions, ReduceKeys); log.Debug("Indexed {0} reduce keys in {1} with {2} results for index {3}", ReduceKeys.Length, sp.Elapsed, results.Length, Index); }); }
public override bool TryMerge(Task task) { var reduceTask = ((ReduceTask)task); ReduceKeys = ReduceKeys.Concat(reduceTask.ReduceKeys).Distinct().ToArray(); return(true); }