示例#1
0
        public virtual void TestIFileReaderWithCodec()
        {
            Configuration conf    = new Configuration();
            FileSystem    localFs = FileSystem.GetLocal(conf);
            FileSystem    rfs     = ((LocalFileSystem)localFs).GetRaw();
            Path          path    = new Path(new Path("build/test.ifile"), "data");
            DefaultCodec  codec   = new GzipCodec();

            codec.SetConf(conf);
            FSDataOutputStream @out = rfs.Create(path);

            IFile.Writer <Text, Text> writer = new IFile.Writer <Text, Text>(conf, @out, typeof(
                                                                                 Text), typeof(Text), codec, null);
            writer.Close();
            FSDataInputStream @in = rfs.Open(path);

            IFile.Reader <Text, Text> reader = new IFile.Reader <Text, Text>(conf, @in, rfs.GetFileStatus
                                                                                 (path).GetLen(), codec, null);
            reader.Close();
            // test check sum
            byte[] ab     = new byte[100];
            int    readed = reader.checksumIn.ReadWithChecksum(ab, 0, ab.Length);

            NUnit.Framework.Assert.AreEqual(readed, reader.checksumIn.GetChecksum().Length);
        }
示例#2
0
 /// <exception cref="System.IO.IOException"/>
 internal virtual void CloseReader()
 {
     if (reader != null)
     {
         reader.Close();
         reader = null;
     }
 }