Package org.apache.hadoop.io.simpleseekableformat

Examples of org.apache.hadoop.io.simpleseekableformat.SimpleSeekableFormatOutputStream


    ByteArrayOutputStream write(final Random dataRandom) throws Exception {

      // Create the in-memory file and start to write to it.
      ByteArrayOutputStream inMemoryFile = new ByteArrayOutputStream();
      SimpleSeekableFormatOutputStream out = new SimpleSeekableFormatOutputStream(inMemoryFile);

      // Set compression Codec
      Configuration conf = new Configuration();
      if (codecClass != null) {
        conf.setClass(SimpleSeekableFormat.FILEFORMAT_SSF_CODEC_CONF, codecClass,
            CompressionCodec.class);
      }
      out.setConf(conf);

      // Write some data
      for (int r = 0; r < numRecord; r++) {
        byte[] b = new byte[dataRandom.nextInt(maxRecordSize)];
        // Generate some compressible random data
        UtilsForTests.nextBytes(dataRandom, b, 16);
        out.write(b);
        if (r % 100 == 99) {
          out.flush();
        }
      }
      out.close();

      return inMemoryFile;
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.io.simpleseekableformat.SimpleSeekableFormatOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.