@Override public void writeData(SliceOutput sliceOutput) { sliceOutput.writeBytes(slice); } };
private void encodeValue(Block block, int position, SliceOutput output) { if (type.getBoolean(block, position)) { output.writeBytes(TRUE); } else { output.writeBytes(FALSE); } }
private static void writeLengthPrefixedString(SliceOutput output, String string) { byte[] bytes = string.getBytes(UTF_8); output.writeInt(bytes.length); output.writeBytes(bytes); } }
@Override public BlockBuilder writeBytes(Slice source, int sourceIndex, int length) { if (length != fixedSize) { throw new IllegalStateException("Expected entry size to be exactly " + fixedSize + " but was " + currentEntrySize); } checkCapacity(); sliceOutput.writeBytes(source, sourceIndex, length); currentEntrySize += length; return this; }
public StreamDataOutput(Slice slice, Stream stream) { this( sliceOutput -> { sliceOutput.writeBytes(slice); return slice.length(); }, stream); }
private static void writeLengthPrefixedString(SliceOutput output, String value) { byte[] bytes = value.getBytes(UTF_8); output.writeInt(bytes.length); output.writeBytes(bytes); } }
@Override public BlockBuilder writeBytes(Slice source, int sourceIndex, int length) { if (!initialized) { initializeCapacity(); } sliceOutput.writeBytes(source, sourceIndex, length); currentEntrySize += length; return this; }
@Override public void encodeValueInto(int depth, Block block, int position, SliceOutput output) { Slice slice = type.getSlice(block, position); if (escapeByte != null && slice.indexOfByte(escapeByte) < 0) { throw new IllegalArgumentException("escape not implemented"); } output.writeBytes(slice); }
public int writeDataTo(SliceOutput outputStream) { checkState(bufferPosition == 0, "Buffer must be closed before writeDataTo can be called"); for (Slice slice : compressedOutputStream.getSlices()) { outputStream.writeBytes(slice); } return compressedOutputStream.size(); }
public static void writeLengthPrefixedString(SliceOutput out, Slice slice) { writeVInt(out, slice.length()); out.writeBytes(slice); }
@Override public void encodeValueInto(int depth, Block block, int position, SliceOutput output) { Slice slice = type.getSlice(block, position); byte[] data = slice.getBytes(); slice = Slices.wrappedBuffer(base64Encoder.encode(data)); output.writeBytes(slice); }
@Override public void encodeValueInto(Block block, int position, SliceOutput output) { Slice slice = type.getSlice(block, position); // Note strings nested in complex structures do no use the empty string marker writeVInt(output, slice.length()); output.writeBytes(slice); }
@Override public void encodeValueInto(Block block, int position, SliceOutput output) { Slice slice = type.getSlice(block, position); // Note binary nested in complex structures do no use the empty marker. // Therefore, empty VARBINARY values are ok. writeVInt(output, slice.length()); output.writeBytes(slice); }
private static void writeLengthPrefixedString(SliceOutput output, String value) { byte[] bytes = value.getBytes(UTF_8); output.writeInt(bytes.length); output.writeBytes(bytes); } }
@Override public final void encodeValueInto(Block block, int position, SliceOutput output) { buffer.reset(); encodeValue(block, position, buffer); // structural types nested in structural types are length prefixed Slice slice = buffer.slice(); output.writeInt(Integer.reverseBytes(slice.length())); output.writeBytes(slice); }
static Slice concatSlice(Slice... slices) { int totalLength = Arrays.stream(slices) .mapToInt(Slice::length) .sum(); Slice value = Slices.allocate(totalLength); SliceOutput output = value.getOutput(); for (Slice slice : slices) { output.writeBytes(slice); } return value; } }
@Override public void encodeColumn(Block block, SliceOutput output, EncodeOutput encodeOutput) { for (int position = 0; position < block.getPositionCount(); position++) { if (block.isNull(position)) { output.writeBytes(nullSequence); } else { encodeValue(block, position, output); } encodeOutput.closeEntry(); } }
private void encodeValue(Block block, int position, SliceOutput output) { if (isShortDecimal(type)) { output.writeBytes(utf8Slice(Decimals.toString(type.getLong(block, position), type.getScale()))); } else { output.writeBytes(utf8Slice(Decimals.toString(type.getSlice(block, position), type.getScale()))); } }
public static void writeSerializedPage(SliceOutput output, SerializedPage page) { output.writeInt(page.getPositionCount()); output.writeByte(page.getCompression().getMarker()); output.writeInt(page.getUncompressedSizeInBytes()); output.writeInt(page.getSizeInBytes()); output.writeBytes(page.getSlice()); }
@Override public void writeBlock(BlockEncodingSerde blockEncodingSerde, SliceOutput sliceOutput, Block block) { SingleMapBlock singleMapBlock = (SingleMapBlock) block; TypeSerde.writeType(sliceOutput, singleMapBlock.keyType); int offset = singleMapBlock.getOffset(); int positionCount = singleMapBlock.getPositionCount(); blockEncodingSerde.writeBlock(sliceOutput, singleMapBlock.getRawKeyBlock().getRegion(offset / 2, positionCount / 2)); blockEncodingSerde.writeBlock(sliceOutput, singleMapBlock.getRawValueBlock().getRegion(offset / 2, positionCount / 2)); int[] hashTable = singleMapBlock.getHashTable(); sliceOutput.appendInt(positionCount / 2 * HASH_MULTIPLIER); sliceOutput.writeBytes(wrappedIntArray(hashTable, offset / 2 * HASH_MULTIPLIER, positionCount / 2 * HASH_MULTIPLIER)); }