Beispiel #1
0
        /// <exception cref="System.Exception"/>
        public virtual void TestAppendSort()
        {
            GenericTestUtils.AssumeInNativeProfile();
            Path file = new Path(RootPath, "testseqappendSort.seq");

            fs.Delete(file, true);
            Path sortedFile = new Path(RootPath, "testseqappendSort.seq.sort");

            fs.Delete(sortedFile, true);
            SequenceFile.Sorter sorter = new SequenceFile.Sorter(fs, new JavaSerializationComparator
                                                                 <long>(), typeof(long), typeof(string), conf);
            SequenceFile.Writer.Option compressOption = SequenceFile.Writer.Compression(SequenceFile.CompressionType
                                                                                        .Block, new GzipCodec());
            SequenceFile.Writer writer = SequenceFile.CreateWriter(conf, SequenceFile.Writer.
                                                                   File(file), SequenceFile.Writer.KeyClass(typeof(long)), SequenceFile.Writer.ValueClass
                                                                       (typeof(string)), compressOption);
            writer.Append(2L, "two");
            writer.Append(1L, "one");
            writer.Close();
            writer = SequenceFile.CreateWriter(conf, SequenceFile.Writer.File(file), SequenceFile.Writer
                                               .KeyClass(typeof(long)), SequenceFile.Writer.ValueClass(typeof(string)), SequenceFile.Writer
                                               .AppendIfExists(true), compressOption);
            writer.Append(4L, "four");
            writer.Append(3L, "three");
            writer.Close();
            // Sort file after append
            sorter.Sort(file, sortedFile);
            VerifyAll4Values(sortedFile);
            fs.DeleteOnExit(file);
            fs.DeleteOnExit(sortedFile);
        }
 /// <exception cref="System.IO.IOException"/>
 private void SortTest(FileSystem fs, int count, int megabytes, int factor, bool fast
                       , Path file)
 {
     fs.Delete(new Path(file + ".sorted"), true);
     SequenceFile.Sorter sorter = NewSorter(fs, fast, megabytes, factor);
     Log.Debug("sorting " + count + " records");
     sorter.Sort(file, file.Suffix(".sorted"));
     Log.Info("done sorting " + count + " debug");
 }
        /// <exception cref="System.IO.IOException"/>
        private void SortMetadataTest(FileSystem fs, Path unsortedFile, Path sortedFile,
                                      SequenceFile.Metadata metadata)
        {
            fs.Delete(sortedFile, true);
            Log.Info("sorting: " + unsortedFile + " to: " + sortedFile);
            WritableComparator comparator = WritableComparator.Get(typeof(RandomDatum));

            SequenceFile.Sorter sorter = new SequenceFile.Sorter(fs, comparator, typeof(RandomDatum
                                                                                        ), typeof(RandomDatum), conf, metadata);
            sorter.Sort(new Path[] { unsortedFile }, sortedFile, false);
        }