Search in sources :

Example 1 with TrinoThriftBlock

use of io.trino.plugin.thrift.api.TrinoThriftBlock in project trino by trinodb.

the class ThriftIndexedTpchService method thriftPageToList.

private static List<List<String>> thriftPageToList(TrinoThriftPageResult page, int begin, int end) {
    checkArgument(begin <= end, "invalid interval");
    if (begin == end) {
        // empty interval
        return ImmutableList.of();
    }
    List<TrinoThriftBlock> blocks = page.getColumnBlocks();
    List<List<String>> result = new ArrayList<>(blocks.size());
    for (TrinoThriftBlock block : blocks) {
        result.add(blockAsList(block, begin, end));
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) TrinoThriftBlock(io.trino.plugin.thrift.api.TrinoThriftBlock)

Example 2 with TrinoThriftBlock

use of io.trino.plugin.thrift.api.TrinoThriftBlock in project trino by trinodb.

the class TestTrinoThriftBigint method testWriteBlockEmpty.

@Test
public void testWriteBlockEmpty() {
    TrinoThriftBlock column = fromBlock(longBlock());
    assertNotNull(column.getBigintData());
    assertNull(column.getBigintData().getNulls());
    assertNull(column.getBigintData().getLongs());
}
Also used : TrinoThriftBlock(io.trino.plugin.thrift.api.TrinoThriftBlock) Test(org.testng.annotations.Test)

Example 3 with TrinoThriftBlock

use of io.trino.plugin.thrift.api.TrinoThriftBlock in project trino by trinodb.

the class TestTrinoThriftBigint method testReadBlockWrongActualType.

@Test
public void testReadBlockWrongActualType() {
    TrinoThriftBlock columnsData = integerData(new TrinoThriftInteger(null, null));
    assertThatThrownBy(() -> columnsData.toBlock(BIGINT)).isInstanceOf(IllegalArgumentException.class).hasMessageMatching("type doesn't match:.*");
}
Also used : TrinoThriftBlock(io.trino.plugin.thrift.api.TrinoThriftBlock) Test(org.testng.annotations.Test)

Example 4 with TrinoThriftBlock

use of io.trino.plugin.thrift.api.TrinoThriftBlock in project trino by trinodb.

the class TestTrinoThriftBigint method testReadBlockAllNullsOption2.

@Test
public void testReadBlockAllNullsOption2() {
    TrinoThriftBlock columnsData = longColumn(new boolean[] { true, true, true, true, true, true, true }, new long[] { 0, 0, 0, 0, 0, 0, 0 });
    Block actual = columnsData.toBlock(BIGINT);
    assertBlockEquals(actual, list(null, null, null, null, null, null, null));
}
Also used : TrinoThriftBlock(io.trino.plugin.thrift.api.TrinoThriftBlock) Block(io.trino.spi.block.Block) TrinoThriftBigint.fromBlock(io.trino.plugin.thrift.api.datatypes.TrinoThriftBigint.fromBlock) TrinoThriftBlock(io.trino.plugin.thrift.api.TrinoThriftBlock) Test(org.testng.annotations.Test)

Example 5 with TrinoThriftBlock

use of io.trino.plugin.thrift.api.TrinoThriftBlock in project trino by trinodb.

the class TestTrinoThriftBigint method testReadBlockAllNonNullOption1.

@Test
public void testReadBlockAllNonNullOption1() {
    TrinoThriftBlock columnsData = longColumn(null, new long[] { 2, 7, 1, 3, 8, 4, 5 });
    Block actual = columnsData.toBlock(BIGINT);
    assertBlockEquals(actual, list(2L, 7L, 1L, 3L, 8L, 4L, 5L));
}
Also used : TrinoThriftBlock(io.trino.plugin.thrift.api.TrinoThriftBlock) Block(io.trino.spi.block.Block) TrinoThriftBigint.fromBlock(io.trino.plugin.thrift.api.datatypes.TrinoThriftBigint.fromBlock) TrinoThriftBlock(io.trino.plugin.thrift.api.TrinoThriftBlock) Test(org.testng.annotations.Test)

Aggregations

TrinoThriftBlock (io.trino.plugin.thrift.api.TrinoThriftBlock)15 Test (org.testng.annotations.Test)12 Block (io.trino.spi.block.Block)9 TrinoThriftBigint.fromBlock (io.trino.plugin.thrift.api.datatypes.TrinoThriftBigint.fromBlock)8 Type (io.trino.spi.type.Type)2 ArrayList (java.util.ArrayList)2 MoreObjects.toStringHelper (com.google.common.base.MoreObjects.toStringHelper)1 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 ImmutableList (com.google.common.collect.ImmutableList)1 ThriftConstructor (io.airlift.drift.annotations.ThriftConstructor)1 ThriftField (io.airlift.drift.annotations.ThriftField)1 OPTIONAL (io.airlift.drift.annotations.ThriftField.Requiredness.OPTIONAL)1 ThriftStruct (io.airlift.drift.annotations.ThriftStruct)1 TrinoThriftBlock.bigintArrayData (io.trino.plugin.thrift.api.TrinoThriftBlock.bigintArrayData)1 TrinoThriftTypeUtils.calculateOffsets (io.trino.plugin.thrift.api.datatypes.TrinoThriftTypeUtils.calculateOffsets)1 TrinoThriftTypeUtils.sameSizeIfPresent (io.trino.plugin.thrift.api.datatypes.TrinoThriftTypeUtils.sameSizeIfPresent)1 TrinoThriftTypeUtils.totalSize (io.trino.plugin.thrift.api.datatypes.TrinoThriftTypeUtils.totalSize)1 AbstractArrayBlock (io.trino.spi.block.AbstractArrayBlock)1 ArrayBlock (io.trino.spi.block.ArrayBlock)1