Search in sources :

Example 46 with DictionaryBlock

use of com.facebook.presto.common.block.DictionaryBlock in project urban-eureka by errir503.

the class TestDictionaryAwarePageProjection method testDictionaryBlockWithFailure.

@Test(dataProvider = "forceYield")
public void testDictionaryBlockWithFailure(boolean forceYield) {
    DictionaryBlock block = createDictionaryBlockWithFailure(10, 100);
    testProjectFails(block, DictionaryBlock.class, forceYield);
}
Also used : DictionaryBlock(com.facebook.presto.common.block.DictionaryBlock) Test(org.testng.annotations.Test)

Example 47 with DictionaryBlock

use of com.facebook.presto.common.block.DictionaryBlock in project urban-eureka by errir503.

the class TestDictionaryAwarePageProjection 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);
}
Also used : DictionaryBlock(com.facebook.presto.common.block.DictionaryBlock) RunLengthEncodedBlock(com.facebook.presto.common.block.RunLengthEncodedBlock) BlockAssertions.createLongSequenceBlock(com.facebook.presto.block.BlockAssertions.createLongSequenceBlock) LongArrayBlock(com.facebook.presto.common.block.LongArrayBlock) DictionaryBlock(com.facebook.presto.common.block.DictionaryBlock) Block(com.facebook.presto.common.block.Block) LazyBlock(com.facebook.presto.common.block.LazyBlock)

Example 48 with DictionaryBlock

use of com.facebook.presto.common.block.DictionaryBlock in project urban-eureka by errir503.

the class TestDictionaryAwarePageProjection method testDictionaryBlockProcessingWithUnusedFailure.

@Test(dataProvider = "forceYield")
public void testDictionaryBlockProcessingWithUnusedFailure(boolean forceYield) {
    DictionaryBlock block = createDictionaryBlockWithUnusedEntries(10, 100);
    // failures in the dictionary processing will cause a fallback to normal columnar processing
    testProject(block, LongArrayBlock.class, forceYield);
}
Also used : DictionaryBlock(com.facebook.presto.common.block.DictionaryBlock) Test(org.testng.annotations.Test)

Example 49 with DictionaryBlock

use of com.facebook.presto.common.block.DictionaryBlock in project urban-eureka by errir503.

the class TestDictionaryAwarePageProjection method testDictionaryProcessingIgnoreYield.

@Test
public void testDictionaryProcessingIgnoreYield() {
    DictionaryAwarePageProjection projection = createProjection();
    // the same input block will bypass yield with multiple projections
    DictionaryBlock block = createDictionaryBlock(10, 100);
    testProjectRange(block, DictionaryBlock.class, projection, true);
    testProjectFastReturnIgnoreYield(block, projection);
    testProjectFastReturnIgnoreYield(block, projection);
    testProjectFastReturnIgnoreYield(block, projection);
}
Also used : DictionaryBlock(com.facebook.presto.common.block.DictionaryBlock) Test(org.testng.annotations.Test)

Example 50 with DictionaryBlock

use of com.facebook.presto.common.block.DictionaryBlock in project urban-eureka by errir503.

the class TestMinMaxByAggregation method testLongAndBlockPositionValueStateSerialization.

@Test
public void testLongAndBlockPositionValueStateSerialization() {
    Type mapType = mapType(VARCHAR, BOOLEAN);
    Map<String, Type> fieldMap = ImmutableMap.of("Key", BIGINT, "Value", mapType);
    AccumulatorStateFactory<LongAndBlockPositionValueState> factory = StateCompiler.generateStateFactory(LongAndBlockPositionValueState.class, fieldMap, new DynamicClassLoader(LongAndBlockPositionValueState.class.getClassLoader()));
    KeyAndBlockPositionValueStateSerializer<LongAndBlockPositionValueState> serializer = new LongAndBlockPositionStateSerializer(BIGINT, mapType);
    LongAndBlockPositionValueState singleState = factory.createSingleState();
    LongAndBlockPositionValueState deserializedState = factory.createSingleState();
    singleState.setFirst(2020);
    singleState.setFirstNull(false);
    BlockBuilder builder = RowType.anonymous(ImmutableList.of(BOOLEAN, BOOLEAN, BIGINT, mapType)).createBlockBuilder(null, 1);
    serializer.serialize(singleState, builder);
    Block rowBlock = builder.build();
    DictionaryBlock dictionaryBlock = (DictionaryBlock) rowBlock.getPositions(new int[] { 0 }, 0, 1);
    serializer.deserialize(dictionaryBlock, 0, deserializedState);
    assertEquals(deserializedState.isFirstNull(), singleState.isFirstNull());
    assertEquals(deserializedState.getFirst(), singleState.getFirst());
}
Also used : DynamicClassLoader(com.facebook.presto.bytecode.DynamicClassLoader) ArrayType(com.facebook.presto.common.type.ArrayType) StructuralTestUtil.mapType(com.facebook.presto.util.StructuralTestUtil.mapType) Type(com.facebook.presto.common.type.Type) RowType(com.facebook.presto.common.type.RowType) DecimalType.createDecimalType(com.facebook.presto.common.type.DecimalType.createDecimalType) DictionaryBlock(com.facebook.presto.common.block.DictionaryBlock) BlockAssertions.createLongsBlock(com.facebook.presto.block.BlockAssertions.createLongsBlock) BlockAssertions.createIntsBlock(com.facebook.presto.block.BlockAssertions.createIntsBlock) BlockAssertions.createShortDecimalsBlock(com.facebook.presto.block.BlockAssertions.createShortDecimalsBlock) BlockAssertions.createLongDecimalsBlock(com.facebook.presto.block.BlockAssertions.createLongDecimalsBlock) BlockAssertions.createStringsBlock(com.facebook.presto.block.BlockAssertions.createStringsBlock) DictionaryBlock(com.facebook.presto.common.block.DictionaryBlock) BlockAssertions.createArrayBigintBlock(com.facebook.presto.block.BlockAssertions.createArrayBigintBlock) BlockAssertions.createBooleansBlock(com.facebook.presto.block.BlockAssertions.createBooleansBlock) BlockAssertions.createDoublesBlock(com.facebook.presto.block.BlockAssertions.createDoublesBlock) Block(com.facebook.presto.common.block.Block) BlockBuilder(com.facebook.presto.common.block.BlockBuilder) Test(org.testng.annotations.Test)

Aggregations

DictionaryBlock (com.facebook.presto.common.block.DictionaryBlock)125 Test (org.testng.annotations.Test)66 Block (com.facebook.presto.common.block.Block)65 BlockAssertions.createRandomDictionaryBlock (com.facebook.presto.block.BlockAssertions.createRandomDictionaryBlock)32 RunLengthEncodedBlock (com.facebook.presto.common.block.RunLengthEncodedBlock)28 Slice (io.airlift.slice.Slice)26 Page (com.facebook.presto.common.Page)25 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)22 Slices.utf8Slice (io.airlift.slice.Slices.utf8Slice)22 BlockAssertions.createLongSequenceBlock (com.facebook.presto.block.BlockAssertions.createLongSequenceBlock)14 LongArrayBlock (com.facebook.presto.common.block.LongArrayBlock)14 DictionaryId (com.facebook.presto.common.block.DictionaryId)12 LazyBlock (com.facebook.presto.common.block.LazyBlock)12 BlockAssertions.createLongsBlock (com.facebook.presto.block.BlockAssertions.createLongsBlock)10 BlockAssertions.createRLEBlock (com.facebook.presto.block.BlockAssertions.createRLEBlock)10 BlockAssertions.createRandomLongsBlock (com.facebook.presto.block.BlockAssertions.createRandomLongsBlock)10 BlockAssertions.createSlicesBlock (com.facebook.presto.block.BlockAssertions.createSlicesBlock)10 DictionaryId.randomDictionaryId (com.facebook.presto.common.block.DictionaryId.randomDictionaryId)10 IntArrayBlock (com.facebook.presto.common.block.IntArrayBlock)8 Type (com.facebook.presto.common.type.Type)8