use of com.facebook.presto.spi.plan.PlanNodeId in project presto by prestodb.
the class TestAggregationOperator method testMemoryTracking.
private void testMemoryTracking(boolean useSystemMemory) throws Exception {
Page input = getOnlyElement(rowPagesBuilder(BIGINT).addSequencePage(100, 0).build());
OperatorFactory operatorFactory = new AggregationOperatorFactory(0, new PlanNodeId("test"), Step.SINGLE, ImmutableList.of(LONG_SUM.bind(ImmutableList.of(0), Optional.empty())), useSystemMemory);
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);
if (useSystemMemory) {
assertThat(driverContext.getSystemMemoryUsage()).isGreaterThan(0);
assertEquals(driverContext.getMemoryUsage(), 0);
} else {
assertEquals(driverContext.getSystemMemoryUsage(), 0);
assertThat(driverContext.getMemoryUsage()).isGreaterThan(0);
}
toPages(operator, emptyIterator());
}
assertEquals(driverContext.getSystemMemoryUsage(), 0);
assertEquals(driverContext.getMemoryUsage(), 0);
}
use of com.facebook.presto.spi.plan.PlanNodeId in project presto by prestodb.
the class TestVerifyNoOriginalExpression method validateSpatialJoinWithFilter.
private void validateSpatialJoinWithFilter(RowExpression filter) {
ImmutableList<VariableReferenceExpression> outputVariables = ImmutableList.of(VARIABLE_REFERENCE_EXPRESSION);
Optional<VariableReferenceExpression> leftPartitionVariable = Optional.of(VARIABLE_REFERENCE_EXPRESSION);
Optional<VariableReferenceExpression> rightPartitionVariable = Optional.of(VARIABLE_REFERENCE_EXPRESSION);
Optional<String> kdbTree = Optional.of("");
ImmutableMap<VariableReferenceExpression, RowExpression> map = ImmutableMap.of(VARIABLE_REFERENCE_EXPRESSION, VARIABLE_REFERENCE_EXPRESSION);
ProjectNode projectNode = builder.project(new Assignments(map), valuesNode);
SpatialJoinNode spatialJoinNode = new SpatialJoinNode(Optional.empty(), new PlanNodeId("1"), SpatialJoinNode.Type.INNER, projectNode, projectNode, outputVariables, filter, leftPartitionVariable, rightPartitionVariable, kdbTree);
testValidation(spatialJoinNode);
}
use of com.facebook.presto.spi.plan.PlanNodeId in project presto by prestodb.
the class TestVerifyNoOriginalExpression method testTableFinish.
@Test
public void testTableFinish() {
TableFinishNode tableFinishNode = new TableFinishNode(Optional.empty(), new PlanNodeId("1"), valuesNode, Optional.of(new TestingWriterTarget()), VARIABLE_REFERENCE_EXPRESSION, Optional.empty(), Optional.empty());
testValidation(tableFinishNode);
}
use of com.facebook.presto.spi.plan.PlanNodeId in project presto by prestodb.
the class TestVerifyNoOriginalExpression method testAggregation.
@Test
public void testAggregation() {
ImmutableList<VariableReferenceExpression> groupingKeys = ImmutableList.of(VARIABLE_REFERENCE_EXPRESSION);
int groupingSetCount = 1;
ImmutableMap<VariableReferenceExpression, SortOrder> orderings = ImmutableMap.of(VARIABLE_REFERENCE_EXPRESSION, SortOrder.ASC_NULLS_FIRST);
OrderingScheme orderingScheme = new OrderingScheme(groupingKeys.stream().map(variable -> new Ordering(variable, orderings.get(variable))).collect(toImmutableList()));
ImmutableMap<VariableReferenceExpression, AggregationNode.Aggregation> aggregations = ImmutableMap.of(VARIABLE_REFERENCE_EXPRESSION, new AggregationNode.Aggregation(comparisonCallExpression, Optional.of(comparisonCallExpression), Optional.of(orderingScheme), false, Optional.of(new VariableReferenceExpression(Optional.empty(), "orderkey", BIGINT))));
ImmutableSet<Integer> globalGroupingSets = ImmutableSet.of(1);
AggregationNode.GroupingSetDescriptor groupingSets = new AggregationNode.GroupingSetDescriptor(groupingKeys, groupingSetCount, globalGroupingSets);
ImmutableList<VariableReferenceExpression> preGroupedVariables = ImmutableList.of();
Optional<VariableReferenceExpression> hashVariable = Optional.of(VARIABLE_REFERENCE_EXPRESSION);
Optional<VariableReferenceExpression> groupIdVariable = Optional.of(VARIABLE_REFERENCE_EXPRESSION);
AggregationNode aggregationNode = new AggregationNode(Optional.empty(), new PlanNodeId("1"), valuesNode, aggregations, groupingSets, preGroupedVariables, AggregationNode.Step.SINGLE, hashVariable, groupIdVariable);
testValidation(aggregationNode);
}
use of com.facebook.presto.spi.plan.PlanNodeId 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();
}
Aggregations