Search in sources :

Example 1 with TestingPagesSerdeFactory

use of com.facebook.presto.execution.buffer.TestingPagesSerdeFactory in project presto by prestodb.

the class TestMemoryPools method setupConsumeRevocableMemory.

private RevocableMemoryOperator setupConsumeRevocableMemory(DataSize reservedPerPage, long numberOfPages) {
    AtomicReference<RevocableMemoryOperator> createOperator = new AtomicReference<>();
    setUp(() -> {
        DriverContext driverContext = taskContext.addPipelineContext(0, false, false, false).addDriverContext();
        OperatorContext revokableOperatorContext = driverContext.addOperatorContext(Integer.MAX_VALUE, new PlanNodeId("revokable_operator"), TableScanOperator.class.getSimpleName());
        OutputFactory outputFactory = new PageConsumerOutputFactory(types -> (page -> {
        }));
        Operator outputOperator = outputFactory.createOutputOperator(2, new PlanNodeId("output"), ImmutableList.of(), Function.identity(), Optional.empty(), new TestingPagesSerdeFactory()).createOperator(driverContext);
        RevocableMemoryOperator revocableMemoryOperator = new RevocableMemoryOperator(revokableOperatorContext, reservedPerPage, numberOfPages);
        createOperator.set(revocableMemoryOperator);
        Driver driver = Driver.createDriver(driverContext, revocableMemoryOperator, outputOperator);
        return ImmutableList.of(driver);
    });
    return createOperator.get();
}
Also used : PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) Page(com.facebook.presto.common.Page) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Assert.assertNull(org.testng.Assert.assertNull) MEGABYTE(io.airlift.units.DataSize.Unit.MEGABYTE) Supplier(com.google.common.base.Supplier) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) AfterMethod(org.testng.annotations.AfterMethod) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) JsonCodec.listJsonCodec(com.facebook.airlift.json.JsonCodec.listJsonCodec) SpillSpaceTracker(com.facebook.presto.spiller.SpillSpaceTracker) GIGABYTE(io.airlift.units.DataSize.Unit.GIGABYTE) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) Operator(com.facebook.presto.operator.Operator) LocalQueryRunner.queryRunnerWithInitialTransaction(com.facebook.presto.testing.LocalQueryRunner.queryRunnerWithInitialTransaction) Assert.assertFalse(org.testng.Assert.assertFalse) LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner) PageConsumerOutputFactory(com.facebook.presto.testing.PageConsumerOperator.PageConsumerOutputFactory) TaskContext(com.facebook.presto.operator.TaskContext) TestingTaskContext.createTaskContext(com.facebook.presto.testing.TestingTaskContext.createTaskContext) ImmutableMap(com.google.common.collect.ImmutableMap) Session(com.facebook.presto.Session) Assert.fail(org.testng.Assert.fail) LocalMemoryContext(com.facebook.presto.memory.context.LocalMemoryContext) TpchConnectorFactory(com.facebook.presto.tpch.TpchConnectorFactory) OutputFactory(com.facebook.presto.operator.OutputFactory) TestingGcMonitor(com.facebook.airlift.stats.TestingGcMonitor) Driver(com.facebook.presto.operator.Driver) TestingSession.testSessionBuilder(com.facebook.presto.testing.TestingSession.testSessionBuilder) TestingPagesSerdeFactory(com.facebook.presto.execution.buffer.TestingPagesSerdeFactory) Preconditions.checkState(com.google.common.base.Preconditions.checkState) MemoryPoolId(com.facebook.presto.spi.memory.MemoryPoolId) AtomicLong(java.util.concurrent.atomic.AtomicLong) Futures(com.google.common.util.concurrent.Futures) DataSize(io.airlift.units.DataSize) List(java.util.List) Predicate(com.google.common.base.Predicate) QueryId(com.facebook.presto.spi.QueryId) Optional(java.util.Optional) Assert.assertTrue(org.testng.Assert.assertTrue) DriverContext(com.facebook.presto.operator.DriverContext) TableScanOperator(com.facebook.presto.operator.TableScanOperator) TaskMemoryReservationSummary(com.facebook.presto.operator.TaskMemoryReservationSummary) OperatorContext(com.facebook.presto.operator.OperatorContext) BYTE(io.airlift.units.DataSize.Unit.BYTE) Operator(com.facebook.presto.operator.Operator) TableScanOperator(com.facebook.presto.operator.TableScanOperator) DriverContext(com.facebook.presto.operator.DriverContext) TableScanOperator(com.facebook.presto.operator.TableScanOperator) PageConsumerOutputFactory(com.facebook.presto.testing.PageConsumerOperator.PageConsumerOutputFactory) TestingPagesSerdeFactory(com.facebook.presto.execution.buffer.TestingPagesSerdeFactory) Driver(com.facebook.presto.operator.Driver) AtomicReference(java.util.concurrent.atomic.AtomicReference) PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) OperatorContext(com.facebook.presto.operator.OperatorContext) PageConsumerOutputFactory(com.facebook.presto.testing.PageConsumerOperator.PageConsumerOutputFactory) OutputFactory(com.facebook.presto.operator.OutputFactory)

Example 2 with TestingPagesSerdeFactory

use of com.facebook.presto.execution.buffer.TestingPagesSerdeFactory in project presto by prestodb.

the class TestSpillCipherPagesSerde method test.

@Test
public void test() {
    SpillCipher cipher = new AesSpillCipher();
    PagesSerde serde = new TestingPagesSerdeFactory().createPagesSerdeForSpill(Optional.of(cipher));
    List<Type> types = ImmutableList.of(VARCHAR);
    Page emptyPage = new Page(VARCHAR.createBlockBuilder(null, 0).build());
    assertPageEquals(types, serde.deserialize(serde.serialize(emptyPage)), emptyPage);
    BlockBuilder blockBuilder = VARCHAR.createBlockBuilder(null, 2);
    VARCHAR.writeString(blockBuilder, "hello");
    VARCHAR.writeString(blockBuilder, "world");
    Page helloWorldPage = new Page(blockBuilder.build());
    SerializedPage serialized = serde.serialize(helloWorldPage);
    assertPageEquals(types, serde.deserialize(serialized), helloWorldPage);
    assertTrue(ENCRYPTED.isSet(serialized.getPageCodecMarkers()), "page should be encrypted");
    cipher.destroy();
    assertFailure(() -> serde.serialize(helloWorldPage), "Spill cipher already destroyed");
    assertFailure(() -> serde.deserialize(serialized), "Spill cipher already destroyed");
}
Also used : Type(com.facebook.presto.common.type.Type) PagesSerde(com.facebook.presto.spi.page.PagesSerde) TestingPagesSerdeFactory(com.facebook.presto.execution.buffer.TestingPagesSerdeFactory) Page(com.facebook.presto.common.Page) SerializedPage(com.facebook.presto.spi.page.SerializedPage) SerializedPage(com.facebook.presto.spi.page.SerializedPage) SpillCipher(com.facebook.presto.spi.spiller.SpillCipher) BlockBuilder(com.facebook.presto.common.block.BlockBuilder) Test(org.testng.annotations.Test)

Example 3 with TestingPagesSerdeFactory

use of com.facebook.presto.execution.buffer.TestingPagesSerdeFactory in project presto by prestodb.

the class TestMergeOperator method setUp.

@BeforeMethod
public void setUp() {
    executor = newSingleThreadScheduledExecutor(daemonThreadsNamed("test-merge-operator-%s"));
    serdeFactory = new TestingPagesSerdeFactory();
    taskBuffers = CacheBuilder.newBuilder().build(CacheLoader.from(TestingTaskBuffer::new));
    httpClient = new TestingHttpClient(new TestingExchangeHttpClientHandler(taskBuffers), executor);
    exchangeClientFactory = new ExchangeClientFactory(new ExchangeClientConfig(), httpClient, new TestingDriftClient<>(), executor);
    orderingCompiler = new OrderingCompiler();
}
Also used : TestingPagesSerdeFactory(com.facebook.presto.execution.buffer.TestingPagesSerdeFactory) TestingHttpClient(com.facebook.airlift.http.client.testing.TestingHttpClient) OrderingCompiler(com.facebook.presto.sql.gen.OrderingCompiler) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

TestingPagesSerdeFactory (com.facebook.presto.execution.buffer.TestingPagesSerdeFactory)3 Page (com.facebook.presto.common.Page)2 TestingHttpClient (com.facebook.airlift.http.client.testing.TestingHttpClient)1 JsonCodec.listJsonCodec (com.facebook.airlift.json.JsonCodec.listJsonCodec)1 TestingGcMonitor (com.facebook.airlift.stats.TestingGcMonitor)1 Session (com.facebook.presto.Session)1 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)1 Type (com.facebook.presto.common.type.Type)1 LocalMemoryContext (com.facebook.presto.memory.context.LocalMemoryContext)1 Driver (com.facebook.presto.operator.Driver)1 DriverContext (com.facebook.presto.operator.DriverContext)1 Operator (com.facebook.presto.operator.Operator)1 OperatorContext (com.facebook.presto.operator.OperatorContext)1 OutputFactory (com.facebook.presto.operator.OutputFactory)1 TableScanOperator (com.facebook.presto.operator.TableScanOperator)1 TaskContext (com.facebook.presto.operator.TaskContext)1 TaskMemoryReservationSummary (com.facebook.presto.operator.TaskMemoryReservationSummary)1 QueryId (com.facebook.presto.spi.QueryId)1 MemoryPoolId (com.facebook.presto.spi.memory.MemoryPoolId)1 PagesSerde (com.facebook.presto.spi.page.PagesSerde)1