/** * @param compressionAlgo * The compression algorithm to be used to for compression. * @throws IOException */ public WBlockState(Algorithm compressionAlgo, FSDataOutputStream fsOut, BytesWritable fsOutputBuffer, Configuration conf) throws IOException { this.compressAlgo = compressionAlgo; this.fsOut = fsOut; this.posStart = fsOut.getPos(); fsOutputBuffer.setCapacity(TFile.getFSOutputBufferSize(conf)); this.fsBufferedOutput = new SimpleBufferedOutputStream(this.fsOut, fsOutputBuffer.getBytes()); this.compressor = compressAlgo.getCompressor(); try { this.out = compressionAlgo.createCompressionStream(fsBufferedOutput, compressor, 0); } catch (IOException e) { compressAlgo.returnCompressor(compressor); throw e; } }
/** * Get the current position in file. * * @return The current byte offset in underlying file. * @throws IOException */ long getCurrentPos() throws IOException { return fsOut.getPos() + fsBufferedOutput.size(); }
@Override public void write(int b) throws IOException { if (count >= buf.length) { flushBuffer(); } buf[count++] = (byte) b; }
@Override public synchronized void flush() throws IOException { flushBuffer(); out.flush(); }
/** * Get the current position in file. * * @return The current byte offset in underlying file. * @throws IOException */ long getCurrentPos() throws IOException { return fsOut.getPos() + fsBufferedOutput.size(); }
IndexedFileOutputStreamState(Algorithm compressionName, FSDataOutputStream fsOut, Configuration conf, long offset) throws IOException { this.compressAlgo = compressionName; this.fsOut = fsOut; this.offset = offset; this.posStart = fsOut.getPos(); BytesWritable fsOutputBuffer = new BytesWritable(); fsOutputBuffer.setCapacity(LogAggregationIndexedFileController .getFSOutputBufferSize(conf)); this.fsBufferedOutput = new SimpleBufferedOutputStream(this.fsOut, fsOutputBuffer.getBytes()); this.compressor = compressAlgo.getCompressor(); try { this.out = compressAlgo.createCompressionStream( fsBufferedOutput, compressor, 0); } catch (IOException e) { LOG.warn(e.getMessage()); compressAlgo.returnCompressor(compressor); throw e; } }
@Override public void write(byte b[], int off, int len) throws IOException { if (len >= buf.length) { flushBuffer(); out.write(b, off, len); return; } if (len > buf.length - count) { flushBuffer(); } System.arraycopy(b, off, buf, count, len); count += len; }
/** * Get the current position in file. * * @return The current byte offset in underlying file. * @throws IOException */ long getCurrentPos() throws IOException { return fsOut.getPos() + fsBufferedOutput.size(); }
/** * @param compressionAlgo * The compression algorithm to be used to for compression. * @throws IOException */ public WBlockState(Algorithm compressionAlgo, FSDataOutputStream fsOut, BytesWritable fsOutputBuffer, Configuration conf) throws IOException { this.compressAlgo = compressionAlgo; this.fsOut = fsOut; this.posStart = fsOut.getPos(); fsOutputBuffer.setCapacity(TFile.getFSOutputBufferSize(conf)); this.fsBufferedOutput = new SimpleBufferedOutputStream(this.fsOut, fsOutputBuffer.getBytes()); this.compressor = compressAlgo.getCompressor(); try { this.out = compressionAlgo.createCompressionStream(fsBufferedOutput, compressor, 0); } catch (IOException e) { compressAlgo.returnCompressor(compressor); throw e; } }
@Override public void write(int b) throws IOException { if (count >= buf.length) { flushBuffer(); } buf[count++] = (byte) b; }
/** * Get the current position in file. * * @return The current byte offset in underlying file. * @throws IOException */ long getCurrentPos() throws IOException { return fsOut.getPos() + fsBufferedOutput.size(); }
/** * @param compressionAlgo * The compression algorithm to be used to for compression. * @throws IOException */ public WBlockState(Algorithm compressionAlgo, FSDataOutputStream fsOut, BytesWritable fsOutputBuffer, Configuration conf) throws IOException { this.compressAlgo = compressionAlgo; this.fsOut = fsOut; this.posStart = fsOut.getPos(); fsOutputBuffer.setCapacity(DTFile.getFSOutputBufferSize(conf)); this.fsBufferedOutput = new SimpleBufferedOutputStream(this.fsOut, fsOutputBuffer.getBytes()); this.compressor = compressAlgo.getCompressor(); try { this.out = compressionAlgo.createCompressionStream(fsBufferedOutput, compressor, 0); } catch (IOException e) { compressAlgo.returnCompressor(compressor); throw e; } }
@Override public void write(int b) throws IOException { if (count >= buf.length) { flushBuffer(); } buf[count++] = (byte) b; }
/** * Get the current position in file. * * @return The current byte offset in underlying file. * @throws IOException */ long getCurrentPos() throws IOException { return fsOut.getPos() + fsBufferedOutput.size(); }
/** * @param compressionAlgo * The compression algorithm to be used to for compression. * @throws IOException */ public WBlockState(Algorithm compressionAlgo, FSDataOutputStream fsOut, BytesWritable fsOutputBuffer, Configuration conf) throws IOException { this.compressAlgo = compressionAlgo; this.fsOut = fsOut; this.posStart = fsOut.getPos(); fsOutputBuffer.setCapacity(TFile.getFSOutputBufferSize(conf)); this.fsBufferedOutput = new SimpleBufferedOutputStream(this.fsOut, fsOutputBuffer.getBytes()); this.compressor = compressAlgo.getCompressor(); try { this.out = compressionAlgo.createCompressionStream(fsBufferedOutput, compressor, 0); } catch (IOException e) { compressAlgo.returnCompressor(compressor); throw e; } }
@Override public void write(int b) throws IOException { if (count >= buf.length) { flushBuffer(); } buf[count++] = (byte) b; }
/** * Get the current position in file. * * @return The current byte offset in underlying file. * @throws IOException */ long getCurrentPos() throws IOException { return fsOut.getPos() + fsBufferedOutput.size(); }
/** * @param compressionAlgo * The compression algorithm to be used to for compression. * @throws IOException */ public WBlockState(Algorithm compressionAlgo, FSDataOutputStream fsOut, BytesWritable fsOutputBuffer, Configuration conf) throws IOException { this.compressAlgo = compressionAlgo; this.fsOut = fsOut; this.posStart = fsOut.getPos(); fsOutputBuffer.setCapacity(TFile.getFSOutputBufferSize(conf)); this.fsBufferedOutput = new SimpleBufferedOutputStream(this.fsOut, fsOutputBuffer.getBytes()); this.compressor = compressAlgo.getCompressor(); try { this.out = compressionAlgo.createCompressionStream(fsBufferedOutput, compressor, 0); } catch (IOException e) { compressAlgo.returnCompressor(compressor); throw e; } }
@Override public void write(int b) throws IOException { if (count >= buf.length) { flushBuffer(); } buf[count++] = (byte) b; }
/** * Get the current position in file. * * @return The current byte offset in underlying file. * @throws IOException */ long getCurrentPos() throws IOException { return fsOut.getPos() + fsBufferedOutput.size(); }