use of com.facebook.presto.sql.planner.plan.PlanNodeId in project presto by prestodb.
the class PredicateFilterBenchmark method createOperatorFactories.
@Override
protected List<? extends OperatorFactory> createOperatorFactories() {
OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "totalprice");
FilterAndProjectOperator.FilterAndProjectOperatorFactory filterAndProjectOperator = new FilterAndProjectOperator.FilterAndProjectOperatorFactory(1, new PlanNodeId("test"), () -> new GenericPageProcessor(new DoubleFilter(50000.00), ImmutableList.of(singleColumn(DOUBLE, 0))), ImmutableList.of(DOUBLE));
return ImmutableList.of(tableScanOperator, filterAndProjectOperator);
}
use of com.facebook.presto.sql.planner.plan.PlanNodeId in project presto by prestodb.
the class Top100Benchmark method createOperatorFactories.
@Override
protected List<? extends OperatorFactory> createOperatorFactories() {
OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "totalprice");
TopNOperatorFactory topNOperator = new TopNOperatorFactory(1, new PlanNodeId("test"), tableScanOperator.getTypes(), 100, ImmutableList.of(0), ImmutableList.of(ASC_NULLS_LAST), false, new DataSize(16, MEGABYTE));
return ImmutableList.of(tableScanOperator, topNOperator);
}
use of com.facebook.presto.sql.planner.plan.PlanNodeId in project presto by prestodb.
the class CountAggregationBenchmark method createOperatorFactories.
@Override
protected List<? extends OperatorFactory> createOperatorFactories() {
OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "orderkey");
InternalAggregationFunction countFunction = localQueryRunner.getMetadata().getFunctionRegistry().getAggregateFunctionImplementation(new Signature("count", AGGREGATE, BIGINT.getTypeSignature()));
AggregationOperatorFactory aggregationOperator = new AggregationOperatorFactory(1, new PlanNodeId("test"), Step.SINGLE, ImmutableList.of(countFunction.bind(ImmutableList.of(0), Optional.empty())));
return ImmutableList.of(tableScanOperator, aggregationOperator);
}
use of com.facebook.presto.sql.planner.plan.PlanNodeId in project presto by prestodb.
the class TestHashJoinOperator method testProbeOuterJoin.
@Test(dataProvider = "hashEnabledValues")
public void testProbeOuterJoin(boolean parallelBuild, boolean probeHashEnabled, boolean buildHashEnabled) throws Exception {
TaskContext taskContext = createTaskContext();
// build
List<Type> buildTypes = ImmutableList.of(VARCHAR, BIGINT, BIGINT);
RowPagesBuilder buildPages = rowPagesBuilder(buildHashEnabled, Ints.asList(0), ImmutableList.of(VARCHAR, BIGINT, BIGINT)).addSequencePage(10, 20, 30, 40);
LookupSourceFactory lookupSourceFactory = buildHash(parallelBuild, taskContext, Ints.asList(0), buildPages, Optional.empty());
// probe
List<Type> probeTypes = ImmutableList.of(VARCHAR, BIGINT, BIGINT);
RowPagesBuilder probePages = rowPagesBuilder(probeHashEnabled, Ints.asList(0), probeTypes);
List<Page> probeInput = probePages.addSequencePage(15, 20, 1020, 2020).build();
OperatorFactory joinOperatorFactory = LOOKUP_JOIN_OPERATORS.probeOuterJoin(0, new PlanNodeId("test"), lookupSourceFactory, probePages.getTypes(), Ints.asList(0), probePages.getHashChannel(), Optional.empty());
// expected
// expected
MaterializedResult expected = MaterializedResult.resultBuilder(taskContext.getSession(), concat(probeTypes, buildTypes)).row("20", 1020L, 2020L, "20", 30L, 40L).row("21", 1021L, 2021L, "21", 31L, 41L).row("22", 1022L, 2022L, "22", 32L, 42L).row("23", 1023L, 2023L, "23", 33L, 43L).row("24", 1024L, 2024L, "24", 34L, 44L).row("25", 1025L, 2025L, "25", 35L, 45L).row("26", 1026L, 2026L, "26", 36L, 46L).row("27", 1027L, 2027L, "27", 37L, 47L).row("28", 1028L, 2028L, "28", 38L, 48L).row("29", 1029L, 2029L, "29", 39L, 49L).row("30", 1030L, 2030L, null, null, null).row("31", 1031L, 2031L, null, null, null).row("32", 1032L, 2032L, null, null, null).row("33", 1033L, 2033L, null, null, null).row("34", 1034L, 2034L, null, null, null).build();
assertOperatorEquals(joinOperatorFactory, taskContext.addPipelineContext(0, true, true).addDriverContext(), probeInput, expected, true, getHashChannels(probePages, buildPages));
}
use of com.facebook.presto.sql.planner.plan.PlanNodeId in project presto by prestodb.
the class TestHashPartitionMaskOperator method testHashPartitionMaskWithMask.
@Test(dataProvider = "hashEnabledValues")
public void testHashPartitionMaskWithMask(boolean hashEnabled) throws Exception {
RowPagesBuilder rowPagesBuilder = rowPagesBuilder(hashEnabled, Ints.asList(0), BIGINT, BOOLEAN, BOOLEAN);
List<Page> input = rowPagesBuilder.addSequencePage(ROW_COUNT, 0, 0, 1).build();
OperatorFactory operatorFactory = new HashPartitionMaskOperatorFactory(0, new PlanNodeId("test"), PARTITION_COUNT, rowPagesBuilder.getTypes(), ImmutableList.of(1, 2), ImmutableList.of(0), rowPagesBuilder.getHashChannel());
int[] rowPartition = new int[ROW_COUNT];
Arrays.fill(rowPartition, -1);
for (int partition = 0; partition < PARTITION_COUNT; partition++) {
MaterializedResult.Builder expected = resultBuilder(TEST_SESSION, BIGINT, BOOLEAN, BOOLEAN, BOOLEAN);
for (int i = 0; i < ROW_COUNT; i++) {
long rawHash = BigintOperators.hashCode(i);
// mix the bits so we don't use the same hash used to distribute between stages
rawHash = XxHash64.hash(Long.reverse(rawHash));
rawHash &= Long.MAX_VALUE;
boolean active = (rawHash % PARTITION_COUNT == partition);
boolean maskValue = i % 2 == 0;
expected.row((long) i, active && maskValue, active && !maskValue, active);
if (active) {
assertEquals(rowPartition[i], -1);
rowPartition[i] = partition;
}
}
OperatorAssertion.assertOperatorEqualsIgnoreOrder(operatorFactory, createDriverContext(), input, expected.build(), hashEnabled, Optional.of(3));
}
assertTrue(IntStream.of(rowPartition).noneMatch(partition -> partition == -1));
}
Aggregations