@Override public void writeByte(int value) { ensureWritableBytes(SIZE_OF_BYTE); slice.setByte(bufferPosition, value); bufferPosition += SIZE_OF_BYTE; }
@Override public void writeShort(int value) { ensureWritableBytes(SIZE_OF_SHORT); slice.setShort(bufferPosition, value); bufferPosition += SIZE_OF_SHORT; }
@Override public void writeByte(int value) { ensureWritableBytes(SIZE_OF_BYTE); slice.setByte(bufferPosition, value); bufferPosition += SIZE_OF_BYTE; }
@Override public void writeInt(int value) { ensureWritableBytes(SIZE_OF_INT); slice.setInt(bufferPosition, value); bufferPosition += SIZE_OF_INT; }
private int ensureBatchSize(int length) { ensureWritableBytes(min(DIRECT_FLUSH_SIZE, length)); return min(length, slice.length() - bufferPosition); }
@Override public void writeInt(int value) { ensureWritableBytes(SIZE_OF_INT); slice.setInt(bufferPosition, value); bufferPosition += SIZE_OF_INT; }
@Override public void writeLong(long value) { ensureWritableBytes(SIZE_OF_LONG); slice.setLong(bufferPosition, value); bufferPosition += SIZE_OF_LONG; }
@Override public void writeShort(int value) { ensureWritableBytes(SIZE_OF_SHORT); slice.setShort(bufferPosition, value); bufferPosition += SIZE_OF_SHORT; }
@Override public void writeLong(long value) { ensureWritableBytes(SIZE_OF_LONG); slice.setLong(bufferPosition, value); bufferPosition += SIZE_OF_LONG; }
private int ensureBatchSize(int length) { ensureWritableBytes(min(DIRECT_FLUSH_SIZE, length)); return min(length, slice.length() - bufferPosition); }
@Override public void writeBytes(byte[] source, int sourceIndex, int length) { // Write huge chunks direct to OutputStream if (length >= DIRECT_FLUSH_SIZE) { // todo fill buffer before flushing flushBufferToOutputStream(); writeDirectlyToOutputStream(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 >= DIRECT_FLUSH_SIZE) { // todo fill buffer before flushing flushBufferToOutputStream(); writeDirectlyToOutputStream(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 >= DIRECT_FLUSH_SIZE) { flushBufferToOutputStream(); writeDirectlyToOutputStream((byte[]) source.getBase(), sourceIndex + (int) (source.getAddress() - ARRAY_BYTE_BASE_OFFSET), 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 >= DIRECT_FLUSH_SIZE) { flushBufferToOutputStream(); writeDirectlyToOutputStream((byte[]) source.getBase(), sourceIndex + (int) (source.getAddress() - ARRAY_BYTE_BASE_OFFSET), length); bufferOffset += length; } else { ensureWritableBytes(length); slice.setBytes(bufferPosition, source, sourceIndex, length); bufferPosition += length; } }