/// <summary> /// Verify SplitSampler contract in mapred.lib.InputSampler, which is added /// back for binary compatibility of M/R 1.x /// </summary> /// <exception cref="System.Exception"/> public virtual void TestMapredSplitSampler() { // IntWritable comparator not typesafe int TotSplits = 15; int NumSplits = 5; int StepSample = 5; int NumSamples = NumSplits * StepSample; InputSampler.Sampler <IntWritable, NullWritable> sampler = new InputSampler.SplitSampler <IntWritable, NullWritable>(NumSamples, NumSplits); int[] inits = new int[TotSplits]; for (int i = 0; i < TotSplits; ++i) { inits[i] = i * StepSample; } object[] samples = sampler.GetSample(new TestInputSampler.TestMapredInputSamplerIF (100000, TotSplits, inits), new JobConf()); NUnit.Framework.Assert.AreEqual(NumSamples, samples.Length); Arrays.Sort(samples, new IntWritable.Comparator()); for (int i_1 = 0; i_1 < NumSamples; ++i_1) { // mapred.lib.InputSampler.SplitSampler has a sampling step NUnit.Framework.Assert.AreEqual(i_1 % StepSample + TotSplits * (i_1 / StepSample) , ((IntWritable)samples[i_1]).Get()); } }
public virtual void TestSplitSampler() { // IntWritable comparator not typesafe int TotSplits = 15; int NumSplits = 5; int StepSample = 5; int NumSamples = NumSplits * StepSample; InputSampler.Sampler <IntWritable, NullWritable> sampler = new InputSampler.SplitSampler <IntWritable, NullWritable>(NumSamples, NumSplits); int[] inits = new int[TotSplits]; for (int i = 0; i < TotSplits; ++i) { inits[i] = i * StepSample; } Job ignored = Job.GetInstance(); object[] samples = sampler.GetSample(new TestInputSampler.TestInputSamplerIF(100000 , TotSplits, inits), ignored); NUnit.Framework.Assert.AreEqual(NumSamples, samples.Length); Arrays.Sort(samples, new IntWritable.Comparator()); for (int i_1 = 0; i_1 < NumSamples; ++i_1) { NUnit.Framework.Assert.AreEqual(i_1, ((IntWritable)samples[i_1]).Get()); } }