List of usage examples for org.apache.hadoop.io.compress GzipCodec GzipCodec
GzipCodec
From source file:tests.it.crs4.seal.common.TestSamInputFormat.java
License:Open Source License
@Test public void testGzCompressedInput() throws IOException { // write gzip-compressed data GzipCodec codec = new GzipCodec(); PrintWriter out = new PrintWriter( new BufferedOutputStream(codec.createOutputStream(new FileOutputStream(tempGz)))); out.write(twoRecords);//from w w w . j av a2s.co m out.close(); // now try to read it split = new FileSplit(new Path(tempGz.toURI().toString()), 0, twoRecords.length(), null); SamRecordReader reader = new SamRecordReader(); reader.initialize(split, Utils.getTaskAttemptContext(conf)); boolean retval = reader.nextKeyValue(); assertTrue(retval); assertEquals("Read/2", reader.getCurrentValue().getAnyRead().getName()); retval = reader.nextKeyValue(); assertTrue(retval); assertEquals("Read/1", reader.getCurrentValue().getAnyRead().getName()); }
From source file:tests.it.crs4.seal.common.TestSamInputFormat.java
License:Open Source License
@Test(expected = RuntimeException.class) public void testCompressedSplit() throws IOException { // write gzip-compressed data GzipCodec codec = new GzipCodec(); PrintWriter out = new PrintWriter( new BufferedOutputStream(codec.createOutputStream(new FileOutputStream(tempGz)))); out.write(twoRecords);/* w ww.ja v a 2s. c o m*/ out.close(); // now try to read it starting from the middle SamInputFormat inputFormat = new SamInputFormat(); split = new FileSplit(new Path(tempGz.toURI().toString()), 10, twoRecords.length(), null); RecordReader<LongWritable, ReadPair> reader = inputFormat.createRecordReader(split, Utils.getTaskAttemptContext(conf)); }