@Override public void serialize(Block block, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { SliceOutput output = new DynamicSliceOutput(64); writeBlock(blockEncodingSerde, output, block); String encoded = Base64.getEncoder().encodeToString(output.slice().getBytes()); jsonGenerator.writeString(encoded); } }
static void writeRawPage(Page page, SliceOutput output, BlockEncodingSerde serde) { output.writeInt(page.getChannelCount()); for (int channel = 0; channel < page.getChannelCount(); channel++) { writeBlock(serde, output, page.getBlock(channel)); } }
private Slice blockToSlice(Block block) { // This function is strictly for testing use only SliceOutput sliceOutput = new DynamicSliceOutput(1000); BlockSerdeUtil.writeBlock(blockEncodingSerde, sliceOutput, block); return sliceOutput.slice(); }
private Slice blockToSlice(Block block) { // This function is strictly for testing use only SliceOutput sliceOutput = new DynamicSliceOutput(1000); BlockSerdeUtil.writeBlock(blockEncodingSerde, sliceOutput, block); return sliceOutput.slice(); }
BlockSerdeUtil.writeBlock(blockEncodingSerde, output, (Block) object); object = output.slice();
writeBlock(blockEncodingSerde, actualSliceOutput, (Block) type.getObject(block, position)); SliceOutput expectedSliceOutput = new DynamicSliceOutput(actualSliceOutput.size()); writeBlock(blockEncodingSerde, expectedSliceOutput, (Block) expectedStackValue); assertEquals(actualSliceOutput.slice(), expectedSliceOutput.slice()); try {
@Test public void testStackRepresentation() { Block actualBlock = arrayBlockOf(new ArrayType(BIGINT), arrayBlockOf(BIGINT, 1L, 2L), arrayBlockOf(BIGINT, 3L)); DynamicSliceOutput actualSliceOutput = new DynamicSliceOutput(100); writeBlock(functionAssertions.getMetadata().getBlockEncodingSerde(), actualSliceOutput, actualBlock); Block expectedBlock = new ArrayType(BIGINT) .createBlockBuilder(null, 3) .appendStructure(BIGINT.createBlockBuilder(null, 2).writeLong(1).closeEntry().writeLong(2).closeEntry().build()) .appendStructure(BIGINT.createBlockBuilder(null, 1).writeLong(3).closeEntry().build()) .build(); DynamicSliceOutput expectedSliceOutput = new DynamicSliceOutput(100); writeBlock(functionAssertions.getMetadata().getBlockEncodingSerde(), expectedSliceOutput, expectedBlock); assertEquals(actualSliceOutput.slice(), expectedSliceOutput.slice()); }
@Override public void serialize(Block block, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { SliceOutput output = new DynamicSliceOutput(64); writeBlock(blockEncodingSerde, output, block); String encoded = Base64.getEncoder().encodeToString(output.slice().getBytes()); jsonGenerator.writeString(encoded); } }
public PagesWriter append(Page page) { requireNonNull(page, "page is null"); Block[] blocks = page.getBlocks(); output.writeInt(page.getPositionCount()); output.writeInt(blocks.length); for (int i = 0; i < blocks.length; i++) { writeBlock(serde, output, blocks[i]); } return this; } }
private Slice blockToSlice(Block block) { // This function is strictly for testing use only SliceOutput sliceOutput = new DynamicSliceOutput(1000); BlockSerdeUtil.writeBlock(blockEncodingSerde, sliceOutput, block); return sliceOutput.slice(); }
private Slice blockToSlice(Block block) { // This function is strictly for testing use only SliceOutput sliceOutput = new DynamicSliceOutput(1000); BlockSerdeUtil.writeBlock(blockEncodingSerde, sliceOutput, block); return sliceOutput.slice(); }
private static Slice blockToSlice(Block block) { // This function is strictly for testing use only SliceOutput sliceOutput = new DynamicSliceOutput(1000); BlockSerdeUtil.writeBlock(sliceOutput, block.copyRegion(0, block.getPositionCount())); return sliceOutput.slice(); }
private static Slice blockToSlice(Block block) { // This function is strictly for testing use only SliceOutput sliceOutput = new DynamicSliceOutput(1000); BlockSerdeUtil.writeBlock(sliceOutput, block.copyRegion(0, block.getPositionCount())); return sliceOutput.slice(); }
BlockSerdeUtil.writeBlock(output, (Block) object); object = output.slice();
@Test public void testStackRepresentation() throws Exception { Block array = arrayBlockOf(BIGINT, 1L, 2L); Block actualBlock = mapBlockOf(DOUBLE, new ArrayType(BIGINT), ImmutableMap.of(1.0, array)); DynamicSliceOutput actualSliceOutput = new DynamicSliceOutput(100); writeBlock(actualSliceOutput, actualBlock); Block expectedBlock = new InterleavedBlockBuilder(ImmutableList.<Type>of(DOUBLE, new ArrayType(BIGINT)), new BlockBuilderStatus(), 3) .writeDouble(1.0) .closeEntry() .writeObject( BIGINT .createBlockBuilder(new BlockBuilderStatus(), 1) .writeLong(1L) .closeEntry() .writeLong(2L) .closeEntry() .build() ) .closeEntry() .build(); DynamicSliceOutput expectedSliceOutput = new DynamicSliceOutput(100); writeBlock(expectedSliceOutput, expectedBlock); assertEquals(actualSliceOutput.slice(), expectedSliceOutput.slice()); }
writeBlock(actualSliceOutput, (Block) type.getObject(block, position)); SliceOutput expectedSliceOutput = new DynamicSliceOutput(actualSliceOutput.size()); writeBlock(expectedSliceOutput, (Block) expectedStackValue); assertEquals(actualSliceOutput.slice(), expectedSliceOutput.slice()); try {
@Test public void testStackRepresentation() throws Exception { Block actualBlock = arrayBlockOf(new ArrayType(BIGINT), arrayBlockOf(BIGINT, 1L, 2L), arrayBlockOf(BIGINT, 3L)); DynamicSliceOutput actualSliceOutput = new DynamicSliceOutput(100); writeBlock(actualSliceOutput, actualBlock); Block expectedBlock = new ArrayType(BIGINT) .createBlockBuilder(new BlockBuilderStatus(), 3) .writeObject(BIGINT.createBlockBuilder(new BlockBuilderStatus(), 2).writeLong(1).closeEntry().writeLong(2).closeEntry().build()) .closeEntry() .writeObject(BIGINT.createBlockBuilder(new BlockBuilderStatus(), 1).writeLong(3).closeEntry().build()) .closeEntry() .build(); DynamicSliceOutput expectedSliceOutput = new DynamicSliceOutput(100); writeBlock(expectedSliceOutput, expectedBlock); assertEquals(actualSliceOutput.slice(), expectedSliceOutput.slice()); }