use of com.facebook.presto.common.block.DictionaryBlock in project urban-eureka by errir503.
the class TestPageProcessorCompiler method testNonDeterministicProject.
@Test
public void testNonDeterministicProject() {
FunctionAndTypeManager functionAndTypeManager = createTestMetadataManager().getFunctionAndTypeManager();
FunctionHandle lessThan = functionAndTypeManager.resolveOperator(LESS_THAN, fromTypes(BIGINT, BIGINT));
CallExpression random = new CallExpression("random", functionAndTypeManager.lookupFunction("random", fromTypes(BIGINT)), BIGINT, singletonList(constant(10L, BIGINT)));
InputReferenceExpression col0 = field(0, BIGINT);
CallExpression lessThanRandomExpression = new CallExpression(LESS_THAN.name(), lessThan, BOOLEAN, ImmutableList.of(col0, random));
PageProcessor processor = compiler.compilePageProcessor(TEST_SESSION.getSqlFunctionProperties(), Optional.empty(), ImmutableList.of(lessThanRandomExpression), false, MAX_BATCH_SIZE).get();
assertFalse(new RowExpressionDeterminismEvaluator(metadataManager.getFunctionAndTypeManager()).isDeterministic(lessThanRandomExpression));
Page page = new Page(createLongDictionaryBlock(1, 100));
Page outputPage = getOnlyElement(processor.process(null, new DriverYieldSignal(), newSimpleAggregatedMemoryContext().newLocalMemoryContext(PageProcessor.class.getSimpleName()), page)).orElseThrow(() -> new AssertionError("page is not present"));
assertFalse(outputPage.getBlock(0) instanceof DictionaryBlock);
}
use of com.facebook.presto.common.block.DictionaryBlock in project urban-eureka by errir503.
the class TestDictionaryAwarePageFilter method createDictionaryBlockWithFailure.
private static DictionaryBlock createDictionaryBlockWithFailure(int dictionarySize, int blockSize) {
Block dictionary = createLongSequenceBlock(-10, dictionarySize - 10);
int[] ids = new int[blockSize];
Arrays.setAll(ids, index -> index % dictionarySize);
return new DictionaryBlock(dictionary, ids);
}
use of com.facebook.presto.common.block.DictionaryBlock in project urban-eureka by errir503.
the class TestDictionaryAwarePageFilter method createDictionaryBlockWithUnusedEntries.
private static DictionaryBlock createDictionaryBlockWithUnusedEntries(int dictionarySize, int blockSize) {
Block dictionary = createLongSequenceBlock(-10, dictionarySize);
int[] ids = new int[blockSize];
Arrays.setAll(ids, index -> (index % dictionarySize) + 10);
return new DictionaryBlock(dictionary, ids);
}
use of com.facebook.presto.common.block.DictionaryBlock in project urban-eureka by errir503.
the class TestDictionaryAwarePageFilter method testDictionaryBlock.
@Test
public void testDictionaryBlock() {
// match some
testFilter(createDictionaryBlock(20, 100), LongArrayBlock.class);
// match none
testFilter(createDictionaryBlock(20, 0), LongArrayBlock.class);
// match all
testFilter(new DictionaryBlock(createLongSequenceBlock(4, 5), new int[100]), LongArrayBlock.class);
}
use of com.facebook.presto.common.block.DictionaryBlock in project urban-eureka by errir503.
the class TestDictionaryAwarePageFilter method testDictionaryProcessingEnableDisable.
@Test
public void testDictionaryProcessingEnableDisable() {
TestDictionaryFilter nestedFilter = new TestDictionaryFilter(true);
DictionaryAwarePageFilter filter = new DictionaryAwarePageFilter(nestedFilter);
DictionaryBlock ineffectiveBlock = createDictionaryBlock(100, 20);
DictionaryBlock effectiveBlock = createDictionaryBlock(10, 100);
// function will always processes the first dictionary
nestedFilter.setExpectedType(LongArrayBlock.class);
testFilter(filter, ineffectiveBlock, true);
// last dictionary not effective, so dictionary processing is disabled
nestedFilter.setExpectedType(DictionaryBlock.class);
testFilter(filter, effectiveBlock, true);
// last dictionary not effective, so dictionary processing is enabled again
nestedFilter.setExpectedType(LongArrayBlock.class);
testFilter(filter, ineffectiveBlock, true);
// last dictionary not effective, so dictionary processing is disabled again
nestedFilter.setExpectedType(DictionaryBlock.class);
testFilter(filter, effectiveBlock, true);
}
Aggregations