Search in sources :

Example 6 with TrinoThriftBlock

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

the class TestTrinoThriftBigint method testWriteBlockAlternating.

@Test
public void testWriteBlockAlternating() {
    Block source = longBlock(1, null, 2, null, 3, null, 4, null, 5, null, 6, null, 7, null);
    TrinoThriftBlock column = fromBlock(source);
    assertNotNull(column.getBigintData());
    assertEquals(column.getBigintData().getNulls(), new boolean[] { false, true, false, true, false, true, false, true, false, true, false, true, false, true });
    assertEquals(column.getBigintData().getLongs(), new long[] { 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0 });
}
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 7 with TrinoThriftBlock

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

the class TestTrinoThriftBigint method testWriteBlockSingleValue.

@Test
public void testWriteBlockSingleValue() {
    TrinoThriftBlock column = fromBlock(longBlock(1));
    assertNotNull(column.getBigintData());
    assertNull(column.getBigintData().getNulls());
    assertEquals(column.getBigintData().getLongs(), new long[] { 1 });
}
Also used : TrinoThriftBlock(io.trino.plugin.thrift.api.TrinoThriftBlock) Test(org.testng.annotations.Test)

Example 8 with TrinoThriftBlock

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

the class TestTrinoThriftBigint method testWriteBlockAllNonNull.

@Test
public void testWriteBlockAllNonNull() {
    Block source = longBlock(1, 2, 3, 4, 5);
    TrinoThriftBlock column = fromBlock(source);
    assertNotNull(column.getBigintData());
    assertNull(column.getBigintData().getNulls());
    assertEquals(column.getBigintData().getLongs(), new long[] { 1, 2, 3, 4, 5 });
}
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 9 with TrinoThriftBlock

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

the class TrinoThriftEquatableValueSet method fromEquatableValueSet.

public static TrinoThriftEquatableValueSet fromEquatableValueSet(EquatableValueSet valueSet) {
    Type type = valueSet.getType();
    Set<ValueEntry> values = valueSet.getEntries();
    List<TrinoThriftBlock> thriftValues = new ArrayList<>(values.size());
    for (ValueEntry value : values) {
        checkState(type.equals(value.getType()), "ValueEntrySet has elements of different types: %s vs %s", type, value.getType());
        thriftValues.add(fromBlock(value.getBlock(), type));
    }
    return new TrinoThriftEquatableValueSet(valueSet.inclusive(), thriftValues);
}
Also used : Type(io.trino.spi.type.Type) ArrayList(java.util.ArrayList) ValueEntry(io.trino.spi.predicate.EquatableValueSet.ValueEntry) TrinoThriftBlock(io.trino.plugin.thrift.api.TrinoThriftBlock)

Example 10 with TrinoThriftBlock

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

the class TestTrinoThriftBigint method testReadBlockAllNonNullOption2.

@Test
public void testReadBlockAllNonNullOption2() {
    TrinoThriftBlock columnsData = longColumn(new boolean[] { false, false, false, false, false, false, false }, 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