use of io.trino.memory.context.LocalMemoryContext in project trino by trinodb.
the class TestPageProcessor method testProjectEmptyPage.
@Test
public void testProjectEmptyPage() {
PageProcessor pageProcessor = new PageProcessor(Optional.of(new SelectAllFilter()), ImmutableList.of(new InputPageProjection(0, BIGINT)));
Page inputPage = new Page(createLongSequenceBlock(0, 0));
LocalMemoryContext memoryContext = newSimpleAggregatedMemoryContext().newLocalMemoryContext(PageProcessor.class.getSimpleName());
Iterator<Optional<Page>> output = pageProcessor.process(SESSION, new DriverYieldSignal(), memoryContext, inputPage);
assertEquals(memoryContext.getBytes(), 0);
// output should be one page containing no columns (only a count)
List<Optional<Page>> outputPages = ImmutableList.copyOf(output);
assertEquals(outputPages.size(), 0);
}
use of io.trino.memory.context.LocalMemoryContext in project trino by trinodb.
the class TestPageProcessor method testSelectNoneFilter.
@Test
public void testSelectNoneFilter() {
PageProcessor pageProcessor = new PageProcessor(Optional.of(new SelectNoneFilter()), ImmutableList.of(new InputPageProjection(0, BIGINT)));
Page inputPage = new Page(createLongSequenceBlock(0, 100));
LocalMemoryContext memoryContext = newSimpleAggregatedMemoryContext().newLocalMemoryContext(PageProcessor.class.getSimpleName());
Iterator<Optional<Page>> output = pageProcessor.process(SESSION, new DriverYieldSignal(), memoryContext, inputPage);
assertEquals(memoryContext.getBytes(), 0);
List<Optional<Page>> outputPages = ImmutableList.copyOf(output);
assertEquals(outputPages.size(), 0);
}
use of io.trino.memory.context.LocalMemoryContext in project trino by trinodb.
the class TestOperatorMemoryRevocation method testOperatorMemoryRevocation.
@Test
public void testOperatorMemoryRevocation() {
AtomicInteger counter = new AtomicInteger();
OperatorContext operatorContext = TestingOperatorContext.create(scheduledExecutor);
LocalMemoryContext revocableMemoryContext = operatorContext.localRevocableMemoryContext();
revocableMemoryContext.setBytes(1000);
operatorContext.setMemoryRevocationRequestListener(counter::incrementAndGet);
operatorContext.requestMemoryRevoking();
assertTrue(operatorContext.isMemoryRevokingRequested());
assertEquals(counter.get(), 1);
// calling resetMemoryRevokingRequested() should clear the memory revoking requested flag
operatorContext.resetMemoryRevokingRequested();
assertFalse(operatorContext.isMemoryRevokingRequested());
operatorContext.requestMemoryRevoking();
assertEquals(counter.get(), 2);
assertTrue(operatorContext.isMemoryRevokingRequested());
}
use of io.trino.memory.context.LocalMemoryContext in project trino by trinodb.
the class TestOperatorMemoryRevocation method testRevocationAlreadyRequested.
@Test
public void testRevocationAlreadyRequested() {
AtomicInteger counter = new AtomicInteger();
OperatorContext operatorContext = TestingOperatorContext.create(scheduledExecutor);
LocalMemoryContext revocableMemoryContext = operatorContext.localRevocableMemoryContext();
revocableMemoryContext.setBytes(1000);
// when memory revocation is already requested setting a listener should immediately execute it
operatorContext.requestMemoryRevoking();
operatorContext.setMemoryRevocationRequestListener(counter::incrementAndGet);
assertTrue(operatorContext.isMemoryRevokingRequested());
assertEquals(counter.get(), 1);
}
Aggregations