Search in sources :

Example 16 with DictionaryBlock

use of io.trino.spi.block.DictionaryBlock in project trino by trinodb.

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);
}
Also used : DictionaryBlock(io.trino.spi.block.DictionaryBlock) RunLengthEncodedBlock(io.trino.spi.block.RunLengthEncodedBlock) BlockAssertions.createLongSequenceBlock(io.trino.block.BlockAssertions.createLongSequenceBlock) DictionaryBlock(io.trino.spi.block.DictionaryBlock) LazyBlock(io.trino.spi.block.LazyBlock) Block(io.trino.spi.block.Block) BlockAssertions.createLongsBlock(io.trino.block.BlockAssertions.createLongsBlock) LongArrayBlock(io.trino.spi.block.LongArrayBlock)

Example 17 with DictionaryBlock

use of io.trino.spi.block.DictionaryBlock in project trino by trinodb.

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);
}
Also used : DictionaryBlock(io.trino.spi.block.DictionaryBlock) Test(org.testng.annotations.Test)

Example 18 with DictionaryBlock

use of io.trino.spi.block.DictionaryBlock in project trino by trinodb.

the class TestDictionaryAwarePageProjection method testDictionaryProcessingEnableDisable.

@Test(dataProvider = "forceYield")
public void testDictionaryProcessingEnableDisable(boolean forceYield, boolean produceLazyBlock) {
    DictionaryAwarePageProjection projection = createProjection(produceLazyBlock);
    // function will always processes the first dictionary
    DictionaryBlock ineffectiveBlock = createDictionaryBlock(100, 20);
    testProjectRange(ineffectiveBlock, DictionaryBlock.class, projection, forceYield, produceLazyBlock);
    testProjectFastReturnIgnoreYield(ineffectiveBlock, projection, produceLazyBlock);
    // dictionary processing can reuse the last dictionary
    // in this case, we don't even check yield signal; make yieldForce to false
    testProjectList(ineffectiveBlock, DictionaryBlock.class, projection, false, produceLazyBlock);
    // last dictionary not effective, so dictionary processing is disabled
    DictionaryBlock effectiveBlock = createDictionaryBlock(10, 100);
    testProjectRange(effectiveBlock, LongArrayBlock.class, projection, forceYield, produceLazyBlock);
    testProjectList(effectiveBlock, LongArrayBlock.class, projection, forceYield, produceLazyBlock);
    // last dictionary effective, so dictionary processing is enabled again
    testProjectRange(ineffectiveBlock, DictionaryBlock.class, projection, forceYield, produceLazyBlock);
    testProjectFastReturnIgnoreYield(ineffectiveBlock, projection, produceLazyBlock);
    // dictionary processing can reuse the last dictionary
    // in this case, we don't even check yield signal; make yieldForce to false
    testProjectList(ineffectiveBlock, DictionaryBlock.class, projection, false, produceLazyBlock);
    // last dictionary not effective, so dictionary processing is disabled again
    testProjectRange(effectiveBlock, LongArrayBlock.class, projection, forceYield, produceLazyBlock);
    testProjectList(effectiveBlock, LongArrayBlock.class, projection, forceYield, produceLazyBlock);
}
Also used : DictionaryBlock(io.trino.spi.block.DictionaryBlock) Test(org.testng.annotations.Test)

Example 19 with DictionaryBlock

use of io.trino.spi.block.DictionaryBlock in project trino by trinodb.

the class TestDictionaryAwarePageProjection method testDictionaryBlockWithFailure.

@Test(dataProvider = "forceYield")
public void testDictionaryBlockWithFailure(boolean forceYield, boolean produceLazyBlock) {
    DictionaryBlock block = createDictionaryBlockWithFailure(10, 100);
    testProjectFails(block, DictionaryBlock.class, forceYield, produceLazyBlock);
}
Also used : DictionaryBlock(io.trino.spi.block.DictionaryBlock) Test(org.testng.annotations.Test)

Example 20 with DictionaryBlock

use of io.trino.spi.block.DictionaryBlock in project trino by trinodb.

the class TestDictionaryAwarePageProjection 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);
}
Also used : DictionaryBlock(io.trino.spi.block.DictionaryBlock) BlockAssertions.createLongSequenceBlock(io.trino.block.BlockAssertions.createLongSequenceBlock) DictionaryBlock(io.trino.spi.block.DictionaryBlock) LazyBlock(io.trino.spi.block.LazyBlock) Block(io.trino.spi.block.Block) LongArrayBlock(io.trino.spi.block.LongArrayBlock) RunLengthEncodedBlock(io.trino.spi.block.RunLengthEncodedBlock) BlockAssertions.createLongsBlock(io.trino.block.BlockAssertions.createLongsBlock)

Aggregations

DictionaryBlock (io.trino.spi.block.DictionaryBlock)71 Block (io.trino.spi.block.Block)39 Test (org.testng.annotations.Test)38 Slice (io.airlift.slice.Slice)21 RunLengthEncodedBlock (io.trino.spi.block.RunLengthEncodedBlock)16 Page (io.trino.spi.Page)15 LazyBlock (io.trino.spi.block.LazyBlock)10 BlockAssertions.createLongSequenceBlock (io.trino.block.BlockAssertions.createLongSequenceBlock)9 BlockAssertions.createLongsBlock (io.trino.block.BlockAssertions.createLongsBlock)9 LongArrayBlock (io.trino.spi.block.LongArrayBlock)9 ColumnarTestUtils.assertBlock (io.trino.block.ColumnarTestUtils.assertBlock)8 PageBuilderStatus (io.trino.spi.block.PageBuilderStatus)8 VariableWidthBlock (io.trino.spi.block.VariableWidthBlock)7 DictionaryId (io.trino.spi.block.DictionaryId)6 BlockAssertions.createLongDictionaryBlock (io.trino.block.BlockAssertions.createLongDictionaryBlock)5 BlockAssertions.createSlicesBlock (io.trino.block.BlockAssertions.createSlicesBlock)5 TestingUnnesterUtil.createSimpleBlock (io.trino.operator.unnest.TestingUnnesterUtil.createSimpleBlock)5 BlockBuilder (io.trino.spi.block.BlockBuilder)5 DictionaryId.randomDictionaryId (io.trino.spi.block.DictionaryId.randomDictionaryId)5 IntArrayBlock (io.trino.spi.block.IntArrayBlock)5