Search in sources :

Example 1 with ColumnIdentity

use of com.facebook.presto.spi.ColumnIdentity in project presto by prestodb.

the class TestRaptorMetadata method testColumnIdentity.

@Test
public void testColumnIdentity() throws Exception {
    // Test ColumnIdentity round trip.
    metadata.createTable(SESSION, getOrdersTable());
    ConnectorTableHandle connectorTableHandle = metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS);
    Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(SESSION, connectorTableHandle);
    ColumnIdentity orderKeyColumnIdentity = metadata.getColumnIdentity(columnHandles.get("orderkey"));
    byte[] bytes = orderKeyColumnIdentity.serialize();
    assertEquals(orderKeyColumnIdentity, metadata.deserializeColumnIdentity(bytes));
    // Test one hard coded serialized data for each version.
    byte version = 1;
    long columnId = 123456789012L;
    ByteArrayDataOutput dataOutput = newDataOutput();
    dataOutput.writeByte(version);
    dataOutput.writeLong(columnId);
    byte[] testBytes = dataOutput.toByteArray();
    ColumnIdentity testColumnIdentity = metadata.deserializeColumnIdentity(testBytes);
    assertEquals(testColumnIdentity, new RaptorColumnIdentity(columnId));
}
Also used : RaptorColumnHandle(com.facebook.presto.raptor.RaptorColumnHandle) ColumnHandle(com.facebook.presto.spi.ColumnHandle) RaptorColumnIdentity(com.facebook.presto.raptor.RaptorColumnIdentity) RaptorColumnIdentity(com.facebook.presto.raptor.RaptorColumnIdentity) ColumnIdentity(com.facebook.presto.spi.ColumnIdentity) ByteArrayDataOutput(com.google.common.io.ByteArrayDataOutput) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) Test(org.testng.annotations.Test)

Aggregations

RaptorColumnHandle (com.facebook.presto.raptor.RaptorColumnHandle)1 RaptorColumnIdentity (com.facebook.presto.raptor.RaptorColumnIdentity)1 ColumnHandle (com.facebook.presto.spi.ColumnHandle)1 ColumnIdentity (com.facebook.presto.spi.ColumnIdentity)1 ConnectorTableHandle (com.facebook.presto.spi.ConnectorTableHandle)1 ByteArrayDataOutput (com.google.common.io.ByteArrayDataOutput)1 Test (org.testng.annotations.Test)1