use of com.facebook.presto.memory.context.MemoryTrackingContext in project presto by prestodb.
the class TestingOperatorContext method create.
public static OperatorContext create(ScheduledExecutorService scheduledExecutor) {
Executor executor = MoreExecutors.directExecutor();
TaskContext taskContext = TestingTaskContext.createTaskContext(executor, scheduledExecutor, TestingSession.testSessionBuilder().build());
MemoryTrackingContext pipelineMemoryContext = new MemoryTrackingContext(newSimpleAggregatedMemoryContext(), newSimpleAggregatedMemoryContext(), newSimpleAggregatedMemoryContext());
PipelineContext pipelineContext = new PipelineContext(1, taskContext, executor, scheduledExecutor, pipelineMemoryContext, false, false, false);
DriverContext driverContext = new DriverContext(pipelineContext, executor, scheduledExecutor, pipelineMemoryContext, Lifespan.taskWide(), Optional.empty(), 0L);
OperatorContext operatorContext = driverContext.addOperatorContext(1, new PlanNodeId("test"), "operator type");
return operatorContext;
}
use of com.facebook.presto.memory.context.MemoryTrackingContext in project presto by prestodb.
the class TestTableWriterOperator method assertMemoryIsReleased.
private void assertMemoryIsReleased(TableWriterOperator tableWriterOperator) {
OperatorContext tableWriterOperatorOperatorContext = tableWriterOperator.getOperatorContext();
MemoryTrackingContext tableWriterMemoryContext = tableWriterOperatorOperatorContext.getOperatorMemoryContext();
assertEquals(tableWriterMemoryContext.getSystemMemory(), 0);
assertEquals(tableWriterMemoryContext.getUserMemory(), 0);
assertEquals(tableWriterMemoryContext.getRevocableMemory(), 0);
Operator statisticAggregationOperator = tableWriterOperator.getStatisticAggregationOperator();
assertTrue(statisticAggregationOperator instanceof AggregationOperator);
AggregationOperator aggregationOperator = (AggregationOperator) statisticAggregationOperator;
OperatorContext aggregationOperatorOperatorContext = aggregationOperator.getOperatorContext();
MemoryTrackingContext aggregationOperatorMemoryContext = aggregationOperatorOperatorContext.getOperatorMemoryContext();
assertEquals(aggregationOperatorMemoryContext.getSystemMemory(), 0);
assertEquals(aggregationOperatorMemoryContext.getUserMemory(), 0);
assertEquals(aggregationOperatorMemoryContext.getRevocableMemory(), 0);
}
use of com.facebook.presto.memory.context.MemoryTrackingContext in project presto by prestodb.
the class TestMemoryTracking method testOperatorAllocations.
@Test
public void testOperatorAllocations() {
MemoryTrackingContext operatorMemoryContext = operatorContext.getOperatorMemoryContext();
LocalMemoryContext systemMemory = operatorContext.newLocalSystemMemoryContext("test");
LocalMemoryContext userMemory = operatorContext.localUserMemoryContext();
LocalMemoryContext revocableMemory = operatorContext.localRevocableMemoryContext();
userMemory.setBytes(100);
assertOperatorMemoryAllocations(operatorMemoryContext, 100, 0, 0);
systemMemory.setBytes(1_000_000);
assertOperatorMemoryAllocations(operatorMemoryContext, 100, 1_000_000, 0);
systemMemory.setBytes(2_000_000);
assertOperatorMemoryAllocations(operatorMemoryContext, 100, 2_000_000, 0);
userMemory.setBytes(500);
assertOperatorMemoryAllocations(operatorMemoryContext, 500, 2_000_000, 0);
userMemory.setBytes(userMemory.getBytes() - 500);
assertOperatorMemoryAllocations(operatorMemoryContext, 0, 2_000_000, 0);
revocableMemory.setBytes(300);
assertOperatorMemoryAllocations(operatorMemoryContext, 0, 2_000_000, 300);
assertAllocationFails((ignored) -> userMemory.setBytes(userMemory.getBytes() - 500), "bytes cannot be negative");
operatorContext.destroy();
assertOperatorMemoryAllocations(operatorMemoryContext, 0, 0, 0);
}
Aggregations