@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); }
@Test public void testWriteHugeByteChucks() { int size = 1024 * 1024; byte[] largeByteArray = new byte[size]; Arrays.fill(largeByteArray, (byte) 0xA); OrcOutputBuffer sliceOutput = new OrcOutputBuffer(CompressionKind.NONE, 256 * 1024); DynamicSliceOutput output = new DynamicSliceOutput(size); sliceOutput.writeBytes(largeByteArray, 10, size - 10); assertEquals(sliceOutput.writeDataTo(output), size - 10); assertEquals(output.slice(), wrappedBuffer(largeByteArray, 10, size - 10)); sliceOutput.reset(); output.reset(); sliceOutput.writeBytes(wrappedBuffer(largeByteArray), 100, size - 100); assertEquals(sliceOutput.writeDataTo(output), size - 100); assertEquals(output.slice(), wrappedBuffer(largeByteArray, 100, size - 100)); }
} catch (Throwable e) { LOGGER.error(e, "Error while sending request to webhook"); slice.reset();
execute.close(); slice.reset();
@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); }
@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); }
@Test public void testWriteHugeByteChucks() { int size = 1024 * 1024; byte[] largeByteArray = new byte[size]; Arrays.fill(largeByteArray, (byte) 0xA); OrcOutputBuffer sliceOutput = new OrcOutputBuffer(CompressionKind.NONE, 256 * 1024); DynamicSliceOutput output = new DynamicSliceOutput(size); sliceOutput.writeBytes(largeByteArray, 10, size - 10); assertEquals(sliceOutput.writeDataTo(output), size - 10); assertEquals(output.slice(), wrappedBuffer(largeByteArray, 10, size - 10)); sliceOutput.reset(); output.reset(); sliceOutput.writeBytes(wrappedBuffer(largeByteArray), 100, size - 100); assertEquals(sliceOutput.writeDataTo(output), size - 100); assertEquals(output.slice(), wrappedBuffer(largeByteArray, 100, size - 100)); }
@Test public void testWriteHugeByteChucks() { int size = 1024 * 1024; byte[] largeByteArray = new byte[size]; Arrays.fill(largeByteArray, (byte) 0xA); OrcOutputBuffer sliceOutput = new OrcOutputBuffer(CompressionKind.NONE, 256 * 1024); DynamicSliceOutput output = new DynamicSliceOutput(size); sliceOutput.writeBytes(largeByteArray, 10, size - 10); assertEquals(sliceOutput.writeDataTo(output), size - 10); assertEquals(output.slice(), wrappedBuffer(largeByteArray, 10, size - 10)); sliceOutput.reset(); output.reset(); sliceOutput.writeBytes(wrappedBuffer(largeByteArray), 100, size - 100); assertEquals(sliceOutput.writeDataTo(output), size - 100); assertEquals(output.slice(), wrappedBuffer(largeByteArray, 100, size - 100)); }
@Test public void testWriteHugeByteChucks() { int size = 1024 * 1024; byte[] largeByteArray = new byte[size]; Arrays.fill(largeByteArray, (byte) 0xA); OrcOutputBuffer sliceOutput = new OrcOutputBuffer(CompressionKind.NONE, 256 * 1024); DynamicSliceOutput output = new DynamicSliceOutput(size); sliceOutput.writeBytes(largeByteArray, 10, size - 10); assertEquals(sliceOutput.writeDataTo(output), size - 10); assertEquals(output.slice(), wrappedBuffer(largeByteArray, 10, size - 10)); sliceOutput.reset(); output.reset(); sliceOutput.writeBytes(wrappedBuffer(largeByteArray), 100, size - 100); assertEquals(sliceOutput.writeDataTo(output), size - 100); assertEquals(output.slice(), wrappedBuffer(largeByteArray, 100, size - 100)); }