Exemplo n.º 1
0
        public virtual void TestMidKeyOnCurrentApi()
        {
            // Write a mapfile of simple data: keys are
            string TestPrefix = "testMidKeyOnCurrentApi.mapfile";

            MapFile.Writer writer = null;
            MapFile.Reader reader = null;
            try
            {
                writer = CreateWriter(TestPrefix, typeof(IntWritable), typeof(IntWritable));
                // 0,1,....9
                int Size = 10;
                for (int i = 0; i < Size; i++)
                {
                    writer.Append(new IntWritable(i), new IntWritable(i));
                }
                writer.Close();
                reader = CreateReader(TestPrefix, typeof(IntWritable));
                Assert.Equal(new IntWritable((Size - 1) / 2), reader.MidKey());
            }
            finally
            {
                IOUtils.Cleanup(null, writer, reader);
            }
        }
Exemplo n.º 2
0
        public virtual void TestMidKeyEmpty()
        {
            // Write a mapfile of simple data: keys are
            Path       dirName          = new Path(TestDir, "testMidKeyEmpty.mapfile");
            FileSystem fs               = FileSystem.GetLocal(conf);
            Path       qualifiedDirName = fs.MakeQualified(dirName);

            MapFile.Writer writer = new MapFile.Writer(conf, fs, qualifiedDirName.ToString(),
                                                       typeof(IntWritable), typeof(IntWritable));
            writer.Close();
            // Now do getClosest on created mapfile.
            MapFile.Reader reader = new MapFile.Reader(qualifiedDirName, conf);
            try
            {
                Assert.Equal(null, reader.MidKey());
            }
            finally
            {
                reader.Close();
            }
        }