use of io.trino.operator.AggregationOperator.AggregationOperatorFactory in project trino by trinodb.
the class TestAggregationOperator method testMaskWithDirtyNulls.
@Test
public void testMaskWithDirtyNulls() {
List<Page> input = ImmutableList.of(new Page(4, createLongsBlock(1, 2, 3, 4), new ByteArrayBlock(4, Optional.of(new boolean[] { true, true, false, false }), new byte[] { 0, 27, /* dirty null */
0, 75 /* non-zero value is true */
})));
OperatorFactory operatorFactory = new AggregationOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(COUNT.createAggregatorFactory(SINGLE, ImmutableList.of(0), OptionalInt.of(1))));
DriverContext driverContext = createTaskContext(executor, scheduledExecutor, TEST_SESSION).addPipelineContext(0, true, true, false).addDriverContext();
MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT).row(1L).build();
assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
use of io.trino.operator.AggregationOperator.AggregationOperatorFactory in project trino by trinodb.
the class HandTpchQuery6 method createOperatorFactories.
@Override
protected List<? extends OperatorFactory> createOperatorFactories() {
// select sum(extendedprice * discount) as revenue
// from lineitem
// where shipdate >= '1994-01-01'
// and shipdate < '1995-01-01'
// and discount >= 0.05
// and discount <= 0.07
// and quantity < 24;
OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "lineitem", "extendedprice", "discount", "shipdate", "quantity");
Supplier<PageProjection> projection = new PageFunctionCompiler(localQueryRunner.getFunctionManager(), 0).compileProjection(field(0, BIGINT), Optional.empty());
OperatorFactory tpchQuery6Operator = FilterAndProjectOperator.createOperatorFactory(1, new PlanNodeId("test"), () -> new PageProcessor(Optional.of(new TpchQuery6Filter()), ImmutableList.of(projection.get())), ImmutableList.of(DOUBLE), DataSize.ofBytes(0), 0);
AggregationOperatorFactory aggregationOperator = new AggregationOperatorFactory(2, new PlanNodeId("test"), ImmutableList.of(doubleSum.bind(ImmutableList.of(0))));
return ImmutableList.of(tableScanOperator, tpchQuery6Operator, aggregationOperator);
}
use of io.trino.operator.AggregationOperator.AggregationOperatorFactory in project trino by trinodb.
the class CountAggregationBenchmark method createOperatorFactories.
@Override
protected List<? extends OperatorFactory> createOperatorFactories() {
OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "orderkey");
AggregationOperatorFactory aggregationOperator = new AggregationOperatorFactory(1, new PlanNodeId("test"), ImmutableList.of(countFunction.bind(ImmutableList.of(0))));
return ImmutableList.of(tableScanOperator, aggregationOperator);
}
use of io.trino.operator.AggregationOperator.AggregationOperatorFactory in project trino by trinodb.
the class TestAggregationOperator method testMemoryTracking.
@Test
public void testMemoryTracking() throws Exception {
Page input = getOnlyElement(rowPagesBuilder(BIGINT).addSequencePage(100, 0).build());
OperatorFactory operatorFactory = new AggregationOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(LONG_SUM.createAggregatorFactory(SINGLE, ImmutableList.of(0), OptionalInt.empty())));
DriverContext driverContext = createTaskContext(executor, scheduledExecutor, TEST_SESSION).addPipelineContext(0, true, true, false).addDriverContext();
try (Operator operator = operatorFactory.createOperator(driverContext)) {
assertTrue(operator.needsInput());
operator.addInput(input);
assertThat(driverContext.getMemoryUsage()).isGreaterThan(0);
toPages(operator, emptyIterator());
}
assertEquals(driverContext.getMemoryUsage(), 0);
}
use of io.trino.operator.AggregationOperator.AggregationOperatorFactory in project trino by trinodb.
the class TestAggregationOperator method testDistinctMaskWithNulls.
@Test
public void testDistinctMaskWithNulls() {
AggregatorFactory distinctFactory = LONG_SUM.createDistinctAggregatorFactory(SINGLE, ImmutableList.of(0), OptionalInt.of(1));
DriverContext driverContext = createTaskContext(executor, scheduledExecutor, TEST_SESSION).addPipelineContext(0, true, true, false).addDriverContext();
OperatorFactory operatorFactory = new AggregationOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(distinctFactory));
ByteArrayBlock trueMaskAllNull = new ByteArrayBlock(4, Optional.of(new boolean[] { true, true, true, true }), /* all positions are null */
new byte[] { 1, 1, 1, 1 });
/* non-zero value is true, all masks are true */
Block trueNullRleMask = new RunLengthEncodedBlock(trueMaskAllNull.getSingleValueBlock(0), 4);
List<Page> nullTrueMaskInput = ImmutableList.of(new Page(4, createLongsBlock(1, 2, 3, 4), trueMaskAllNull), new Page(4, createLongsBlock(10, 11, 10, 11), createBooleansBlock(true, true, true, true)), new Page(4, createLongsBlock(5, 6, 7, 8), trueNullRleMask));
MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT).row(21L).build();
assertOperatorEquals(operatorFactory, driverContext, nullTrueMaskInput, expected);
}
Aggregations