/// <summary>Partitions the summation into parts and then return them as splits</summary> public override IList <InputSplit> GetSplits(JobContext context) { //read sigma from conf Configuration conf = context.GetConfiguration(); Summation sigma = SummationWritable.Read(typeof(DistSum), conf); int nParts = conf.GetInt(NParts, 0); //create splits IList <InputSplit> splits = new AList <InputSplit>(nParts); Summation[] parts = sigma.Partition(nParts); for (int i = 0; i < parts.Length; ++i) { splits.AddItem(new DistSum.Machine.SummationSplit(parts[i])); } //LOG.info("parts[" + i + "] = " + parts[i]); return(splits); }
/// <summary>Partition sigma and execute the computations.</summary> private Summation Execute(string name, Summation sigma) { Summation[] summations = sigma.Partition(parameters.nJobs); IList <DistSum.Computation> computations = new AList <DistSum.Computation>(); for (int i = 0; i < summations.Length; i++) { computations.AddItem(new DistSum.Computation(this, i, name, summations[i])); } try { Org.Apache.Hadoop.Examples.PI.Util.Execute(parameters.nThreads, computations); } catch (Exception e) { throw new RuntimeException(e); } IList <Summation> combined = Org.Apache.Hadoop.Examples.PI.Util.Combine(Arrays.AsList (summations)); return(combined.Count == 1 ? combined[0] : null); }