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();
}
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");
}
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();
}
Aggregations