コード例 #1
0
        /// <summary>
        /// Tests the class loader set by
        /// <see cref="Org.Apache.Hadoop.Conf.Configuration.SetClassLoader(Sharpen.ClassLoader)
        ///     "/>
        /// is inherited by any
        /// <see cref="WrappedRecordReader{K, U}"/>
        /// s created by
        /// <see cref="CompositeRecordReader{K, V, X}"/>
        /// </summary>
        /// <exception cref="System.Exception"/>
        public virtual void TestClassLoader()
        {
            Configuration conf = new Configuration();

            TestWrappedRRClassloader.Fake_ClassLoader classLoader = new TestWrappedRRClassloader.Fake_ClassLoader
                                                                        ();
            conf.SetClassLoader(classLoader);
            NUnit.Framework.Assert.IsTrue(conf.GetClassLoader() is TestWrappedRRClassloader.Fake_ClassLoader
                                          );
            FileSystem fs      = FileSystem.Get(conf);
            Path       testdir = new Path(Runtime.GetProperty("test.build.data", "/tmp")).MakeQualified
                                     (fs);
            Path @base = new Path(testdir, "/empty");

            Path[] src = new Path[] { new Path(@base, "i0"), new Path("i1"), new Path("i2") };
            conf.Set(CompositeInputFormat.JoinExpr, CompositeInputFormat.Compose("outer", typeof(
                                                                                     TestWrappedRRClassloader.IF_ClassLoaderChecker), src));
            CompositeInputFormat <NullWritable> inputFormat = new CompositeInputFormat <NullWritable
                                                                                        >();
            // create dummy TaskAttemptID
            TaskAttemptID tid = new TaskAttemptID("jt", 1, TaskType.Map, 0, 0);

            conf.Set(MRJobConfig.TaskAttemptId, tid.ToString());
            inputFormat.CreateRecordReader(inputFormat.GetSplits(Job.GetInstance(conf))[0], new
                                           TaskAttemptContextImpl(conf, tid));
        }
コード例 #2
0
        /// <exception cref="System.Exception"/>
        public virtual int TestFormat(Configuration conf, int tupleSize, bool firstTuple,
                                      bool secondTuple, TestJoinProperties.TestType ttype)
        {
            Job job = Job.GetInstance(conf);
            CompositeInputFormat format = new CompositeInputFormat();
            int count = 0;

            foreach (InputSplit split in (IList <InputSplit>)format.GetSplits(job))
            {
                TaskAttemptContext context = MapReduceTestUtil.CreateDummyMapTaskAttemptContext(conf
                                                                                                );
                RecordReader reader   = format.CreateRecordReader(split, context);
                MapContext   mcontext = new MapContextImpl(conf, context.GetTaskAttemptID(), reader
                                                           , null, null, MapReduceTestUtil.CreateDummyReporter(), split);
                reader.Initialize(split, mcontext);
                WritableComparable key   = null;
                Writable           value = null;
                while (reader.NextKeyValue())
                {
                    key   = (WritableComparable)reader.GetCurrentKey();
                    value = (Writable)reader.GetCurrentValue();
                    ValidateKeyValue(key, value, tupleSize, firstTuple, secondTuple, ttype);
                    count++;
                }
            }
            return(count);
        }