/** * {@inheritDoc} * WARNING: using this method will lead to very poor performance! */ @Override public void write(final int singleByte) throws IOException { checkNotClosed(); if (_position >= _outputBuffer.length) { writeCompressedBlock(); } _outputBuffer[_position++] = (byte) singleByte; }
public PLZFOutputStream(final OutputStream outputStream) { this(outputStream, DEFAULT_OUTPUT_BUFFER_SIZE, getNThreads()); }
@Override public synchronized int write(final ByteBuffer src) throws IOException { int r = src.remaining(); if (r <= 0) { return r; } writeCompressedBlock(); // will flush _outputBuffer if (src.hasArray()) { // direct compression from backing array write(src.array(), src.arrayOffset(), src.limit() - src.arrayOffset()); } else { // need to copy to heap array first while (src.hasRemaining()) { int toRead = Math.min(src.remaining(), _outputBuffer.length); src.get(_outputBuffer, 0, toRead); _position = toRead; writeCompressedBlock(); } } return r; }
writeCompressedBlock(); writeExecutor.shutdownNow(); blockManager = null; checkWriteException();
public void write(final InputStream in) throws IOException { writeCompressedBlock(); // will flush _outputBuffer int read; while ((read = in.read(_outputBuffer)) >= 0) { _position = read; writeCompressedBlock(); } }
/** * This <code>flush</code> method does nothing. */ @Override public void flush() throws IOException { checkNotClosed(); }
/** * Compress and write the current block to the OutputStream */ protected void writeCompressedBlock() throws IOException { if (_position == 0) { return; } Future<LZFChunk> lzfFuture = compressExecutor.submit(new CompressTask(_outputBuffer, 0, _position, blockManager)); writeExecutor.execute(new WriteTask(out, lzfFuture, this)); _outputBuffer = blockManager.getBlockFromPool(); _position = 0; checkWriteException(); }
public void write(final FileChannel in) throws IOException { MappedByteBuffer src = in.map(MapMode.READ_ONLY, 0, in.size()); write(src); }
@Override public synchronized int write(final ByteBuffer src) throws IOException { int r = src.remaining(); if (r <= 0) { return r; } writeCompressedBlock(); // will flush _outputBuffer if (src.hasArray()) { // direct compression from backing array write(src.array(), src.arrayOffset(), src.limit() - src.arrayOffset()); } else { // need to copy to heap array first while (src.hasRemaining()) { int toRead = Math.min(src.remaining(), _outputBuffer.length); src.get(_outputBuffer, 0, toRead); _position = toRead; writeCompressedBlock(); } } return r; }
writeCompressedBlock(); writeExecutor.shutdownNow(); blockManager = null; checkWriteException();
public void write(final InputStream in) throws IOException { writeCompressedBlock(); // will flush _outputBuffer int read; while ((read = in.read(_outputBuffer)) >= 0) { _position = read; writeCompressedBlock(); } }
/** * This <code>flush</code> method does nothing. */ @Override public void flush() throws IOException { checkNotClosed(); }
/** * Compress and write the current block to the OutputStream */ protected void writeCompressedBlock() throws IOException { if (_position == 0) { return; } Future<LZFChunk> lzfFuture = compressExecutor.submit(new CompressTask(_outputBuffer, 0, _position, blockManager)); writeExecutor.execute(new WriteTask(out, lzfFuture, this)); _outputBuffer = blockManager.getBlockFromPool(); _position = 0; checkWriteException(); }
public void write(final FileChannel in) throws IOException { MappedByteBuffer src = in.map(MapMode.READ_ONLY, 0, in.size()); write(src); }
/** * {@inheritDoc} * WARNING: using this method will lead to very poor performance! */ @Override public void write(final int singleByte) throws IOException { checkNotClosed(); if (_position >= _outputBuffer.length) { writeCompressedBlock(); } _outputBuffer[_position++] = (byte) singleByte; }
@Override public synchronized int write(final ByteBuffer src) throws IOException { int r = src.remaining(); if (r <= 0) { return r; } writeCompressedBlock(); // will flush _outputBuffer if (src.hasArray()) { // direct compression from backing array write(src.array(), src.arrayOffset(), src.limit() - src.arrayOffset()); } else { // need to copy to heap array first while (src.hasRemaining()) { int toRead = Math.min(src.remaining(), _outputBuffer.length); src.get(_outputBuffer, 0, toRead); _position = toRead; writeCompressedBlock(); } } return r; }
writeCompressedBlock(); writeExecutor.shutdownNow(); blockManager = null; checkWriteException();
public void write(final InputStream in) throws IOException { writeCompressedBlock(); // will flush _outputBuffer int read; while ((read = in.read(_outputBuffer)) >= 0) { _position = read; writeCompressedBlock(); } }
/** * This <code>flush</code> method does nothing. */ @Override public void flush() throws IOException { checkNotClosed(); }
/** * Compress and write the current block to the OutputStream */ protected void writeCompressedBlock() throws IOException { if (_position == 0) { return; } Future<LZFChunk> lzfFuture = compressExecutor.submit(new CompressTask(_outputBuffer, 0, _position, blockManager)); writeExecutor.execute(new WriteTask(out, lzfFuture, this)); _outputBuffer = blockManager.getBlockFromPool(); _position = 0; checkWriteException(); }