Search in sources :

Example 1 with SliceArrayBlock

use of com.facebook.presto.spi.block.SliceArrayBlock in project presto by prestodb.

the class TestSliceArrayBlock method testCopyPositions.

@Test
public void testCopyPositions() throws Exception {
    Slice[] expectedValues = (Slice[]) alternatingNullValues(createExpectedValues(100));
    SliceArrayBlock block = new SliceArrayBlock(expectedValues.length, expectedValues);
    assertBlockFilteredPositions(expectedValues, block, Ints.asList(0, 2, 4, 6, 7, 9, 10, 16));
}
Also used : Slice(io.airlift.slice.Slice) SliceArrayBlock(com.facebook.presto.spi.block.SliceArrayBlock) Test(org.testng.annotations.Test)

Example 2 with SliceArrayBlock

use of com.facebook.presto.spi.block.SliceArrayBlock in project presto by prestodb.

the class TestSliceArrayBlock method assertVariableWithValues.

private void assertVariableWithValues(Slice[] expectedValues) {
    SliceArrayBlock block = new SliceArrayBlock(expectedValues.length, expectedValues);
    assertBlock(block, expectedValues);
}
Also used : SliceArrayBlock(com.facebook.presto.spi.block.SliceArrayBlock)

Example 3 with SliceArrayBlock

use of com.facebook.presto.spi.block.SliceArrayBlock in project presto by prestodb.

the class TestDictionaryBlock method createDictionaryBlock.

private static DictionaryBlock createDictionaryBlock(Slice[] expectedValues, int positionCount) {
    int dictionarySize = expectedValues.length;
    int[] ids = new int[positionCount];
    for (int i = 0; i < positionCount; i++) {
        ids[i] = i % dictionarySize;
    }
    return new DictionaryBlock(positionCount, new SliceArrayBlock(dictionarySize, expectedValues), ids);
}
Also used : SliceArrayBlock(com.facebook.presto.spi.block.SliceArrayBlock) DictionaryBlock(com.facebook.presto.spi.block.DictionaryBlock)

Example 4 with SliceArrayBlock

use of com.facebook.presto.spi.block.SliceArrayBlock in project presto by prestodb.

the class TestDictionaryBlock method createDictionaryBlockWithUnreferencedKeys.

private static DictionaryBlock createDictionaryBlockWithUnreferencedKeys(Slice[] expectedValues, int positionCount) {
    // adds references to 0 and all odd indexes
    int dictionarySize = expectedValues.length;
    int[] ids = new int[positionCount];
    for (int i = 0; i < positionCount; i++) {
        int index = i % dictionarySize;
        if (index % 2 == 0 && index != 0) {
            index--;
        }
        ids[i] = index;
    }
    return new DictionaryBlock(positionCount, new SliceArrayBlock(dictionarySize, expectedValues), ids);
}
Also used : SliceArrayBlock(com.facebook.presto.spi.block.SliceArrayBlock) DictionaryBlock(com.facebook.presto.spi.block.DictionaryBlock)

Example 5 with SliceArrayBlock

use of com.facebook.presto.spi.block.SliceArrayBlock in project presto by prestodb.

the class TestPageProcessorCompiler method createDictionaryBlock.

private static DictionaryBlock createDictionaryBlock(Slice[] expectedValues, int positionCount) {
    int dictionarySize = expectedValues.length;
    int[] ids = new int[positionCount];
    for (int i = 0; i < positionCount; i++) {
        ids[i] = i % dictionarySize;
    }
    return new DictionaryBlock(positionCount, new SliceArrayBlock(dictionarySize, expectedValues), ids);
}
Also used : SliceArrayBlock(com.facebook.presto.spi.block.SliceArrayBlock) DictionaryBlock(com.facebook.presto.spi.block.DictionaryBlock) BlockAssertions.createLongDictionaryBlock(com.facebook.presto.block.BlockAssertions.createLongDictionaryBlock)

Aggregations

SliceArrayBlock (com.facebook.presto.spi.block.SliceArrayBlock)7 DictionaryBlock (com.facebook.presto.spi.block.DictionaryBlock)4 Slice (io.airlift.slice.Slice)3 Test (org.testng.annotations.Test)2 BlockAssertions.createLongDictionaryBlock (com.facebook.presto.block.BlockAssertions.createLongDictionaryBlock)1 OrcCorruptionException (com.facebook.presto.orc.OrcCorruptionException)1 BlockBuilder (com.facebook.presto.spi.block.BlockBuilder)1 BlockBuilderStatus (com.facebook.presto.spi.block.BlockBuilderStatus)1 DictionaryId (com.facebook.presto.spi.block.DictionaryId)1 DictionaryId.randomDictionaryId (com.facebook.presto.spi.block.DictionaryId.randomDictionaryId)1