public class TestDictionaryEncodedBlockSerde
{
@Test
public void testRoundTrip()
{
Block block = VARCHAR.createBlockBuilder(new BlockBuilderStatus())
.appendSlice(Slices.utf8Slice("alice"))
.appendSlice(Slices.utf8Slice("bob"))
.appendSlice(Slices.utf8Slice("charlie"))
.appendSlice(Slices.utf8Slice("dave"))
.build();
DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024);
BlockEncoding blockEncoding = new DictionaryEncoder(new UncompressedEncoder(sliceOutput)).append(block).append(block).append(block).finish();
Block actualBlock = blockEncoding.readBlock(sliceOutput.slice().getInput());
assertBlockEquals(actualBlock, VARCHAR.createBlockBuilder(new BlockBuilderStatus())
.appendSlice(Slices.utf8Slice("alice"))
.appendSlice(Slices.utf8Slice("bob"))
.appendSlice(Slices.utf8Slice("charlie"))
.appendSlice(Slices.utf8Slice("dave"))
.appendSlice(Slices.utf8Slice("alice"))