use of io.prestosql.spi.block.DictionaryBlock in project boostkit-bigdata by kunpengcompute.
the class BlockUtil method createIntegerDictionaryBlock.
public static Block createIntegerDictionaryBlock(int start, int length) {
checkArgument(length > 5, "block must have more than 5 entries");
int dictionarySize = length / 5;
BlockBuilder builder = INTEGER.createBlockBuilder(null, dictionarySize);
for (int i = start; i < start + dictionarySize; i++) {
INTEGER.writeLong(builder, i);
}
int[] ids = new int[length];
for (int i = 0; i < length; i++) {
ids[i] = i % dictionarySize;
}
return new DictionaryBlock(builder.build(), ids);
}
use of io.prestosql.spi.block.DictionaryBlock in project hetu-core by openlookeng.
the class TestDictionaryBlock method testEstimatedDataSizeForStats.
@Test
public void testEstimatedDataSizeForStats() {
int positionCount = 10;
int dictionaryPositionCount = 100;
Slice[] expectedValues = createExpectedValues(positionCount);
DictionaryBlock dictionaryBlock = createDictionaryBlock(expectedValues, dictionaryPositionCount);
for (int position = 0; position < dictionaryPositionCount; position++) {
assertEquals(dictionaryBlock.getEstimatedDataSizeForStats(position), expectedValues[position % positionCount].length());
}
}
use of io.prestosql.spi.block.DictionaryBlock in project hetu-core by openlookeng.
the class TestDictionaryBlock method testCompactAllKeysReferenced.
@Test
public void testCompactAllKeysReferenced() {
Slice[] expectedValues = createExpectedValues(5);
DictionaryBlock dictionaryBlock = createDictionaryBlock(expectedValues, 10);
DictionaryBlock compactBlock = dictionaryBlock.compact();
// When there is nothing to compact, we return the same block
assertEquals(compactBlock.getDictionary(), dictionaryBlock.getDictionary());
assertEquals(compactBlock.getPositionCount(), dictionaryBlock.getPositionCount());
for (int position = 0; position < compactBlock.getPositionCount(); position++) {
assertEquals(compactBlock.getId(position), dictionaryBlock.getId(position));
}
assertEquals(compactBlock.isCompact(), true);
}
use of io.prestosql.spi.block.DictionaryBlock in project hetu-core by openlookeng.
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 io.prestosql.spi.block.DictionaryBlock in project hetu-core by openlookeng.
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