Search in sources :

Example 1 with TestingPagesSerdeFactory

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());
}
Also used : Type(io.prestosql.spi.type.Type) PagesSerde(io.hetu.core.transport.execution.buffer.PagesSerde) TestingPagesSerdeFactory(io.prestosql.testing.TestingPagesSerdeFactory) Block(io.prestosql.spi.block.Block) DynamicSliceOutput(io.airlift.slice.DynamicSliceOutput) Page(io.prestosql.spi.Page) BlockBuilder(io.prestosql.spi.block.BlockBuilder) Test(org.testng.annotations.Test)

Example 2 with TestingPagesSerdeFactory

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();
}
Also used : PagesSerde(io.hetu.core.transport.execution.buffer.PagesSerde) TestingPagesSerdeFactory(io.prestosql.testing.TestingPagesSerdeFactory) Slice(io.airlift.slice.Slice) DynamicSliceOutput(io.airlift.slice.DynamicSliceOutput) Page(io.prestosql.spi.Page)

Example 3 with TestingPagesSerdeFactory

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"));
}
Also used : TestingPagesSerdeFactory(io.prestosql.testing.TestingPagesSerdeFactory) DataSize(io.airlift.units.DataSize) MemoryTableManager(io.prestosql.plugin.memory.data.MemoryTableManager) TestingTypeManager(io.prestosql.spi.type.testing.TestingTypeManager) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

TestingPagesSerdeFactory (io.prestosql.testing.TestingPagesSerdeFactory)3 DynamicSliceOutput (io.airlift.slice.DynamicSliceOutput)2 PagesSerde (io.hetu.core.transport.execution.buffer.PagesSerde)2 Page (io.prestosql.spi.Page)2 Slice (io.airlift.slice.Slice)1 DataSize (io.airlift.units.DataSize)1 MemoryTableManager (io.prestosql.plugin.memory.data.MemoryTableManager)1 Block (io.prestosql.spi.block.Block)1 BlockBuilder (io.prestosql.spi.block.BlockBuilder)1 Type (io.prestosql.spi.type.Type)1 TestingTypeManager (io.prestosql.spi.type.testing.TestingTypeManager)1 BeforeMethod (org.testng.annotations.BeforeMethod)1 Test (org.testng.annotations.Test)1