@Override public void writeByte(int value) { ensureWritableBytes(SIZE_OF_BYTE); slice.setByteUnchecked(bufferPosition, value); bufferPosition += SIZE_OF_BYTE; }
@Override public void writeShort(int value) { ensureWritableBytes(SIZE_OF_SHORT); slice.setShortUnchecked(bufferPosition, value); bufferPosition += SIZE_OF_SHORT; }
@Override public void writeLong(long value) { ensureWritableBytes(SIZE_OF_LONG); slice.setLongUnchecked(bufferPosition, value); bufferPosition += SIZE_OF_LONG; }
private int ensureBatchSize(int length) { ensureWritableBytes(Math.min(MINIMUM_CHUNK_SIZE, length)); return Math.min(length, slice.length() - bufferPosition); }
@Override public void writeInt(int value) { ensureWritableBytes(SIZE_OF_INT); slice.setIntUnchecked(bufferPosition, value); bufferPosition += SIZE_OF_INT; }
@Override public void writeByte(int value) { ensureWritableBytes(SIZE_OF_BYTE); slice.setByteUnchecked(bufferPosition, value); bufferPosition += SIZE_OF_BYTE; }
@Override public void writeLong(long value) { ensureWritableBytes(SIZE_OF_LONG); slice.setLongUnchecked(bufferPosition, value); bufferPosition += SIZE_OF_LONG; }
private int ensureBatchSize(int length) { ensureWritableBytes(Math.min(MINIMUM_CHUNK_SIZE, length)); return Math.min(length, slice.length() - bufferPosition); }
@Override public void writeShort(int value) { ensureWritableBytes(SIZE_OF_SHORT); slice.setShortUnchecked(bufferPosition, value); bufferPosition += SIZE_OF_SHORT; }
@Override public void writeInt(int value) { ensureWritableBytes(SIZE_OF_INT); slice.setIntUnchecked(bufferPosition, value); bufferPosition += SIZE_OF_INT; }
@Override public void writeBytes(Slice source, int sourceIndex, int length) { // Write huge chunks direct to OutputStream if (length >= MINIMUM_CHUNK_SIZE) { flushBufferToOutputStream(); writeToOutputStream(source, sourceIndex, length); bufferOffset += length; } else { ensureWritableBytes(length); slice.setBytes(bufferPosition, source, sourceIndex, length); bufferPosition += length; } }
@Override public void writeBytes(byte[] source, int sourceIndex, int length) { // Write huge chunks direct to OutputStream if (length >= MINIMUM_CHUNK_SIZE) { flushBufferToOutputStream(); writeToOutputStream(source, sourceIndex, length); bufferOffset += length; } else { ensureWritableBytes(length); slice.setBytes(bufferPosition, source, sourceIndex, length); bufferPosition += length; } }
@Override public void writeBytes(Slice source, int sourceIndex, int length) { // Write huge chunks direct to OutputStream if (length >= MINIMUM_CHUNK_SIZE) { flushBufferToOutputStream(); writeToOutputStream(source, sourceIndex, length); bufferOffset += length; } else { ensureWritableBytes(length); slice.setBytes(bufferPosition, source, sourceIndex, length); bufferPosition += length; } }
@Override public void writeBytes(byte[] source, int sourceIndex, int length) { // Write huge chunks direct to OutputStream if (length >= MINIMUM_CHUNK_SIZE) { flushBufferToOutputStream(); writeToOutputStream(source, sourceIndex, length); bufferOffset += length; } else { ensureWritableBytes(length); slice.setBytes(bufferPosition, source, sourceIndex, length); bufferPosition += length; } }