use of com.facebook.presto.sql.gen.PageFunctionCompiler in project presto by prestodb.
the class PredicateFilterBenchmark method createOperatorFactories.
@Override
protected List<? extends OperatorFactory> createOperatorFactories() {
Metadata metadata = localQueryRunner.getMetadata();
OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "totalprice");
RowExpression filter = call(GREATER_THAN_OR_EQUAL.name(), metadata.getFunctionAndTypeManager().resolveOperator(GREATER_THAN_OR_EQUAL, fromTypes(DOUBLE, DOUBLE)), BOOLEAN, field(0, DOUBLE), constant(50000.0, DOUBLE));
ExpressionCompiler expressionCompiler = new ExpressionCompiler(metadata, new PageFunctionCompiler(metadata, 0));
Supplier<PageProcessor> pageProcessor = expressionCompiler.compilePageProcessor(localQueryRunner.getDefaultSession().getSqlFunctionProperties(), Optional.of(filter), ImmutableList.of(field(0, DOUBLE)));
FilterAndProjectOperator.FilterAndProjectOperatorFactory filterAndProjectOperator = new FilterAndProjectOperator.FilterAndProjectOperatorFactory(1, new PlanNodeId("test"), pageProcessor, ImmutableList.of(DOUBLE), new DataSize(0, BYTE), 0);
return ImmutableList.of(tableScanOperator, filterAndProjectOperator);
}
use of com.facebook.presto.sql.gen.PageFunctionCompiler in project presto by prestodb.
the class TestFilterAndProjectOperator method testMergeOutput.
@Test
public void testMergeOutput() {
List<Page> input = rowPagesBuilder(VARCHAR, BIGINT).addSequencePage(100, 0, 0).addSequencePage(100, 0, 0).addSequencePage(100, 0, 0).addSequencePage(100, 0, 0).build();
MetadataManager metadata = createTestMetadataManager();
RowExpression filter = call(EQUAL.name(), metadata.getFunctionAndTypeManager().resolveOperator(EQUAL, fromTypes(BIGINT, BIGINT)), BOOLEAN, field(1, BIGINT), constant(10L, BIGINT));
ExpressionCompiler compiler = new ExpressionCompiler(metadata, new PageFunctionCompiler(metadata, 0));
Supplier<PageProcessor> processor = compiler.compilePageProcessor(TEST_SESSION.getSqlFunctionProperties(), Optional.of(filter), ImmutableList.of(field(1, BIGINT)));
OperatorFactory operatorFactory = new FilterAndProjectOperator.FilterAndProjectOperatorFactory(0, new PlanNodeId("test"), processor, ImmutableList.of(BIGINT), new DataSize(64, KILOBYTE), 2);
List<Page> expected = rowPagesBuilder(BIGINT).row(10L).row(10L).row(10L).row(10L).build();
assertOperatorEquals(operatorFactory, ImmutableList.of(BIGINT), driverContext, input, expected);
}
use of com.facebook.presto.sql.gen.PageFunctionCompiler in project presto by prestodb.
the class TaskTestUtils method createTestingPlanner.
public static LocalExecutionPlanner createTestingPlanner() {
MetadataManager metadata = MetadataManager.createTestMetadataManager();
PageSourceManager pageSourceManager = new PageSourceManager();
pageSourceManager.addConnectorPageSourceProvider(CONNECTOR_ID, new TestingPageSourceProvider());
// we don't start the finalizer so nothing will be collected, which is ok for a test
FinalizerService finalizerService = new FinalizerService();
NodeScheduler nodeScheduler = new NodeScheduler(new LegacyNetworkTopology(), new InMemoryNodeManager(), new NodeSelectionStats(), new NodeSchedulerConfig().setIncludeCoordinator(true), new NodeTaskMap(finalizerService), new ThrowingNodeTtlFetcherManager(), new NoOpQueryManager(), new SimpleTtlNodeSelectorConfig());
PartitioningProviderManager partitioningProviderManager = new PartitioningProviderManager();
NodePartitioningManager nodePartitioningManager = new NodePartitioningManager(nodeScheduler, partitioningProviderManager, new NodeSelectionStats());
PageFunctionCompiler pageFunctionCompiler = new PageFunctionCompiler(metadata, 0);
return new LocalExecutionPlanner(metadata, Optional.empty(), pageSourceManager, new IndexManager(), partitioningProviderManager, nodePartitioningManager, new PageSinkManager(), new ConnectorMetadataUpdaterManager(), new ExpressionCompiler(metadata, pageFunctionCompiler), pageFunctionCompiler, new JoinFilterFunctionCompiler(metadata), new IndexJoinLookupStats(), new TaskManagerConfig(), new MemoryManagerConfig(), new GenericSpillerFactory((types, spillContext, memoryContext) -> {
throw new UnsupportedOperationException();
}), (types, spillContext, memoryContext) -> {
throw new UnsupportedOperationException();
}, (types, partitionFunction, spillContext, memoryContext) -> {
throw new UnsupportedOperationException();
}, new BlockEncodingManager(), new PagesIndex.TestingFactory(false), new JoinCompiler(MetadataManager.createTestMetadataManager(), new FeaturesConfig()), new LookupJoinOperators(), new OrderingCompiler(), jsonCodec(TableCommitContext.class), new RowExpressionDeterminismEvaluator(metadata), new NoOpFragmentResultCacheManager(), new ObjectMapper(), (session) -> {
throw new UnsupportedOperationException();
});
}
use of com.facebook.presto.sql.gen.PageFunctionCompiler in project presto by prestodb.
the class TestPageProcessorCompiler method setup.
@BeforeClass
public void setup() {
metadataManager = createTestMetadataManager();
compiler = new ExpressionCompiler(metadataManager, new PageFunctionCompiler(metadataManager, 0));
}
use of com.facebook.presto.sql.gen.PageFunctionCompiler in project presto by prestodb.
the class TestPageProcessor method testExpressionProfiler.
@Test
public void testExpressionProfiler() {
MetadataManager metadata = createTestMetadataManager();
CallExpression add10Expression = call(ADD.name(), metadata.getFunctionAndTypeManager().resolveOperator(ADD, fromTypes(BIGINT, BIGINT)), BIGINT, field(0, BIGINT), constant(10L, BIGINT));
TestingTicker testingTicker = new TestingTicker();
PageFunctionCompiler functionCompiler = new PageFunctionCompiler(metadata, 0);
Supplier<PageProjection> projectionSupplier = functionCompiler.compileProjection(SESSION.getSqlFunctionProperties(), add10Expression, Optional.empty());
PageProjection projection = projectionSupplier.get();
Page page = new Page(createLongSequenceBlock(1, 11));
ExpressionProfiler profiler = new ExpressionProfiler(testingTicker, SPLIT_RUN_QUANTA);
for (int i = 0; i < 100; i++) {
profiler.start();
Work<List<Block>> work = projection.project(SESSION.getSqlFunctionProperties(), new DriverYieldSignal(), page, SelectedPositions.positionsRange(0, page.getPositionCount()));
if (i < 10) {
// increment the ticker with a large value to mark the expression as expensive
testingTicker.increment(10, SECONDS);
profiler.stop(page.getPositionCount());
assertTrue(profiler.isExpressionExpensive());
} else {
testingTicker.increment(0, NANOSECONDS);
profiler.stop(page.getPositionCount());
assertFalse(profiler.isExpressionExpensive());
}
work.process();
}
}
Aggregations