Ejemplo n.º 1
0
        /// <summary>test DBInputFormat class.</summary>
        /// <remarks>test DBInputFormat class. Class should split result for chunks</remarks>
        /// <exception cref="System.Exception"/>
        public virtual void TestDBInputFormat()
        {
            JobConf configuration = new JobConf();

            SetupDriver(configuration);
            DBInputFormat <DBInputFormat.NullDBWritable> format = new DBInputFormat <DBInputFormat.NullDBWritable
                                                                                     >();

            format.SetConf(configuration);
            format.SetConf(configuration);
            DBInputFormat.DBInputSplit splitter = new DBInputFormat.DBInputSplit(1, 10);
            Reporter reporter = Org.Mockito.Mockito.Mock <Reporter>();
            RecordReader <LongWritable, DBInputFormat.NullDBWritable> reader = format.GetRecordReader
                                                                                   (splitter, configuration, reporter);

            configuration.SetInt(MRJobConfig.NumMaps, 3);
            InputSplit[] lSplits = format.GetSplits(configuration, 3);
            NUnit.Framework.Assert.AreEqual(5, lSplits[0].GetLength());
            NUnit.Framework.Assert.AreEqual(3, lSplits.Length);
            // test reader .Some simple tests
            NUnit.Framework.Assert.AreEqual(typeof(LongWritable), reader.CreateKey().GetType(
                                                ));
            NUnit.Framework.Assert.AreEqual(0, reader.GetPos());
            NUnit.Framework.Assert.AreEqual(0, reader.GetProgress(), 0.001);
            reader.Close();
        }
Ejemplo n.º 2
0
        /// <summary>return progress based on the amount of data processed so far.</summary>
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="System.Exception"/>
        public override float GetProgress()
        {
            long subprogress = 0;

            // bytes processed in current split
            if (null != curReader)
            {
                // idx is always one past the current subsplit's true index.
                subprogress = (long)(curReader.GetProgress() * split.GetLength(idx - 1));
            }
            return(Math.Min(1.0f, (progress + subprogress) / (float)(split.GetLength())));
        }
Ejemplo n.º 3
0
        public virtual void TestFormat()
        {
            PipesNonJavaInputFormat inputFormat = new PipesNonJavaInputFormat();
            JobConf  conf     = new JobConf();
            Reporter reporter = Org.Mockito.Mockito.Mock <Reporter>();
            RecordReader <FloatWritable, NullWritable> reader = inputFormat.GetRecordReader(new
                                                                                            TestPipeApplication.FakeSplit(), conf, reporter);

            NUnit.Framework.Assert.AreEqual(0.0f, reader.GetProgress(), 0.001);
            // input and output files
            FilePath input1 = new FilePath(workSpace + FilePath.separator + "input1");

            if (!input1.GetParentFile().Exists())
            {
                NUnit.Framework.Assert.IsTrue(input1.GetParentFile().Mkdirs());
            }
            if (!input1.Exists())
            {
                NUnit.Framework.Assert.IsTrue(input1.CreateNewFile());
            }
            FilePath input2 = new FilePath(workSpace + FilePath.separator + "input2");

            if (!input2.Exists())
            {
                NUnit.Framework.Assert.IsTrue(input2.CreateNewFile());
            }
            // set data for splits
            conf.Set(FileInputFormat.InputDir, StringUtils.EscapeString(input1.GetAbsolutePath
                                                                            ()) + "," + StringUtils.EscapeString(input2.GetAbsolutePath()));
            InputSplit[] splits = inputFormat.GetSplits(conf, 2);
            NUnit.Framework.Assert.AreEqual(2, splits.Length);
            PipesNonJavaInputFormat.PipesDummyRecordReader dummyRecordReader = new PipesNonJavaInputFormat.PipesDummyRecordReader
                                                                                   (conf, splits[0]);
            // empty dummyRecordReader
            NUnit.Framework.Assert.IsNull(dummyRecordReader.CreateKey());
            NUnit.Framework.Assert.IsNull(dummyRecordReader.CreateValue());
            NUnit.Framework.Assert.AreEqual(0, dummyRecordReader.GetPos());
            NUnit.Framework.Assert.AreEqual(0.0, dummyRecordReader.GetProgress(), 0.001);
            // test method next
            NUnit.Framework.Assert.IsTrue(dummyRecordReader.Next(new FloatWritable(2.0f), NullWritable
                                                                 .Get()));
            NUnit.Framework.Assert.AreEqual(2.0, dummyRecordReader.GetProgress(), 0.001);
            dummyRecordReader.Close();
        }
Ejemplo n.º 4
0
 /// <summary>Request progress from proxied RR.</summary>
 /// <exception cref="System.IO.IOException"/>
 public virtual float GetProgress()
 {
     return(rr.GetProgress());
 }
Ejemplo n.º 5
0
 /// <summary>Request progress from proxied RR.</summary>
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 public override float GetProgress()
 {
     return(rr.GetProgress());
 }
 /// <exception cref="System.IO.IOException"/>
 public virtual float GetProgress()
 {
     return(delegate_.GetProgress());
 }
Ejemplo n.º 7
0
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 public override float GetProgress()
 {
     return(originalRR.GetProgress());
 }
Ejemplo n.º 8
0
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 public override float GetProgress()
 {
     return(delegate_.GetProgress());
 }