use of com.facebook.presto.operator.OperatorFactory in project presto by prestodb.
the class HashBuildAndJoinBenchmark method createDrivers.
/*
select orderkey, quantity, totalprice
from lineitem join orders using (orderkey)
*/
@Override
protected List<Driver> createDrivers(TaskContext taskContext) {
ImmutableList.Builder<OperatorFactory> driversBuilder = ImmutableList.builder();
driversBuilder.add(ordersTableScan);
OperatorFactory source = ordersTableScan;
Optional<Integer> hashChannel = Optional.empty();
if (hashEnabled) {
source = createHashProjectOperator(1, new PlanNodeId("test"), ImmutableList.of(BIGINT, DOUBLE));
driversBuilder.add(source);
hashChannel = Optional.of(2);
}
// hash build
HashBuilderOperatorFactory hashBuilder = new HashBuilderOperatorFactory(2, new PlanNodeId("test"), source.getTypes(), ImmutableList.of(0, 1), ImmutableMap.of(), Ints.asList(0), hashChannel, false, Optional.empty(), 1_500_000, 1, new PagesIndex.TestingFactory());
driversBuilder.add(hashBuilder);
DriverFactory hashBuildDriverFactory = new DriverFactory(0, true, false, driversBuilder.build(), OptionalInt.empty());
Driver hashBuildDriver = hashBuildDriverFactory.createDriver(taskContext.addPipelineContext(0, true, false).addDriverContext());
hashBuildDriverFactory.close();
// join
ImmutableList.Builder<OperatorFactory> joinDriversBuilder = ImmutableList.builder();
joinDriversBuilder.add(lineItemTableScan);
source = lineItemTableScan;
hashChannel = Optional.empty();
if (hashEnabled) {
source = createHashProjectOperator(1, new PlanNodeId("test"), ImmutableList.of(BIGINT, BIGINT));
joinDriversBuilder.add(source);
hashChannel = Optional.of(2);
}
OperatorFactory joinOperator = LOOKUP_JOIN_OPERATORS.innerJoin(2, new PlanNodeId("test"), hashBuilder.getLookupSourceFactory(), source.getTypes(), Ints.asList(0), hashChannel, Optional.empty());
joinDriversBuilder.add(joinOperator);
joinDriversBuilder.add(new NullOutputOperatorFactory(3, new PlanNodeId("test"), joinOperator.getTypes()));
DriverFactory joinDriverFactory = new DriverFactory(1, true, true, joinDriversBuilder.build(), OptionalInt.empty());
Driver joinDriver = joinDriverFactory.createDriver(taskContext.addPipelineContext(1, true, true).addDriverContext());
joinDriverFactory.close();
return ImmutableList.of(hashBuildDriver, joinDriver);
}
use of com.facebook.presto.operator.OperatorFactory in project presto by prestodb.
the class FunctionAssertions method interpretedFilterProject.
private Operator interpretedFilterProject(Expression filter, Expression projection, Session session) {
FilterFunction filterFunction = new InterpretedInternalFilterFunction(filter, SYMBOL_TYPES, INPUT_MAPPING, metadata, SQL_PARSER, session);
ProjectionFunction projectionFunction = new InterpretedProjectionFunction(projection, SYMBOL_TYPES, INPUT_MAPPING, metadata, SQL_PARSER, session);
OperatorFactory operatorFactory = new FilterAndProjectOperator.FilterAndProjectOperatorFactory(0, new PlanNodeId("test"), () -> new GenericPageProcessor(filterFunction, ImmutableList.of(projectionFunction)), toTypes(ImmutableList.of(projectionFunction)));
return operatorFactory.createOperator(createDriverContext(session));
}
use of com.facebook.presto.operator.OperatorFactory in project presto by prestodb.
the class FunctionAssertions method executeProjectionWithAll.
private List<Object> executeProjectionWithAll(String projection, Type expectedType, Session session, ExpressionCompiler compiler) {
requireNonNull(projection, "projection is null");
Expression projectionExpression = createExpression(projection, metadata, SYMBOL_TYPES);
List<Object> results = new ArrayList<>();
// If the projection does not need bound values, execute query using full engine
if (!needsBoundValue(projectionExpression)) {
MaterializedResult result = runner.execute("SELECT " + projection);
assertType(result.getTypes(), expectedType);
assertEquals(result.getTypes().size(), 1);
assertEquals(result.getMaterializedRows().size(), 1);
Object queryResult = Iterables.getOnlyElement(result.getMaterializedRows()).getField(0);
results.add(queryResult);
}
// execute as standalone operator
OperatorFactory operatorFactory = compileFilterProject(TRUE_LITERAL, projectionExpression, compiler);
assertType(operatorFactory.getTypes(), expectedType);
Object directOperatorValue = selectSingleValue(operatorFactory, session);
results.add(directOperatorValue);
// interpret
Operator interpretedFilterProject = interpretedFilterProject(TRUE_LITERAL, projectionExpression, session);
assertType(interpretedFilterProject.getTypes(), expectedType);
Object interpretedValue = selectSingleValue(interpretedFilterProject);
results.add(interpretedValue);
// execute over normal operator
SourceOperatorFactory scanProjectOperatorFactory = compileScanFilterProject(TRUE_LITERAL, projectionExpression, compiler);
assertType(scanProjectOperatorFactory.getTypes(), expectedType);
Object scanOperatorValue = selectSingleValue(scanProjectOperatorFactory, createNormalSplit(), session);
results.add(scanOperatorValue);
// execute over record set
Object recordValue = selectSingleValue(scanProjectOperatorFactory, createRecordSetSplit(), session);
results.add(recordValue);
// If the projection does not need bound values, execute query using full engine
if (!needsBoundValue(projectionExpression)) {
MaterializedResult result = runner.execute("SELECT " + projection);
assertType(result.getTypes(), expectedType);
assertEquals(result.getTypes().size(), 1);
assertEquals(result.getMaterializedRows().size(), 1);
Object queryResult = Iterables.getOnlyElement(result.getMaterializedRows()).getField(0);
results.add(queryResult);
}
return results;
}
use of com.facebook.presto.operator.OperatorFactory in project presto by prestodb.
the class IndexBuildDriverFactoryProvider method createStreaming.
public DriverFactory createStreaming(PageBuffer pageBuffer, Page indexKeyTuple) {
ImmutableList.Builder<OperatorFactory> operatorFactories = ImmutableList.<OperatorFactory>builder().addAll(coreOperatorFactories);
if (dynamicTupleFilterFactory.isPresent()) {
// Bind in a dynamic tuple filter if necessary
operatorFactories.add(dynamicTupleFilterFactory.get().filterWithTuple(indexKeyTuple));
}
operatorFactories.add(new PageBufferOperatorFactory(outputOperatorId, planNodeId, pageBuffer));
return new DriverFactory(pipelineId, inputDriver, false, operatorFactories.build(), OptionalInt.empty());
}
Aggregations