use of io.prestosql.testing.TestingPagesSerdeFactory in project hetu-core by openlookeng.
the class TestPagesSerde method testRoundTrip.
@Test
public void testRoundTrip() {
PagesSerde serde = new TestingPagesSerdeFactory().createPagesSerde();
BlockBuilder expectedBlockBuilder = VARCHAR.createBlockBuilder(null, 5);
VARCHAR.writeString(expectedBlockBuilder, "alice");
VARCHAR.writeString(expectedBlockBuilder, "bob");
VARCHAR.writeString(expectedBlockBuilder, "charlie");
VARCHAR.writeString(expectedBlockBuilder, "dave");
Block expectedBlock = expectedBlockBuilder.build();
Page expectedPage = new Page(expectedBlock, expectedBlock, expectedBlock);
DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024);
writePages(serde, sliceOutput, expectedPage, expectedPage, expectedPage);
List<Type> types = ImmutableList.of(VARCHAR, VARCHAR, VARCHAR);
Iterator<Page> pageIterator = readPages(serde, sliceOutput.slice().getInput());
assertPageEquals(types, pageIterator.next(), expectedPage);
assertPageEquals(types, pageIterator.next(), expectedPage);
assertPageEquals(types, pageIterator.next(), expectedPage);
assertFalse(pageIterator.hasNext());
}
use of io.prestosql.testing.TestingPagesSerdeFactory in project hetu-core by openlookeng.
the class TestPagesSerde method serializedSize.
private static int serializedSize(List<? extends Type> types, Page expectedPage) {
PagesSerde serde = new TestingPagesSerdeFactory().createPagesSerde();
DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024);
writePages(serde, sliceOutput, expectedPage);
Slice slice = sliceOutput.slice();
Iterator<Page> pageIterator = readPages(serde, slice.getInput());
if (pageIterator.hasNext()) {
assertPageEquals(types, pageIterator.next(), expectedPage);
} else {
assertEquals(expectedPage.getPositionCount(), 0);
}
assertFalse(pageIterator.hasNext());
return slice.length();
}
use of io.prestosql.testing.TestingPagesSerdeFactory in project hetu-core by openlookeng.
the class TestMemoryTableManager method setUp.
@BeforeMethod
public void setUp() throws IOException {
synchronized (MemoryThreadManager.class) {
if (!MemoryThreadManager.isSharedThreadPoolInitilized()) {
MemoryThreadManager.initSharedThreadPool(4);
}
}
pagesStore = new MemoryTableManager(new MemoryConfig().setMaxDataPerNode(new DataSize(1, DataSize.Unit.MEGABYTE)).setSpillRoot(Files.createTempDirectory("test-memory-table").toString()), sorter, new TestingTypeManager(), new TestingPagesSerdeFactory().createPagesSerde());
pageSinkProvider = new MemoryPageSinkProvider(pagesStore, HostAddress.fromString("localhost:8080"));
}
Aggregations