use of com.google.common.io.ByteArrayDataOutput in project druid by druid-io.
the class DatasourceInputSplitTest method testSerde.
@Test
public void testSerde() throws Exception {
Interval interval = Interval.parse("2000/3000");
DatasourceInputSplit expected = new DatasourceInputSplit(Lists.newArrayList(new WindowedDataSegment(new DataSegment("test", Interval.parse("2000/3000"), "ver", ImmutableMap.<String, Object>of("type", "local", "path", "/tmp/index.zip"), ImmutableList.of("host"), ImmutableList.of("visited_sum", "unique_hosts"), NoneShardSpec.instance(), 9, 12334), interval)), new String[] { "server1", "server2", "server3" });
ByteArrayDataOutput out = ByteStreams.newDataOutput();
expected.write(out);
DataInput in = ByteStreams.newDataInput(out.toByteArray());
DatasourceInputSplit actual = new DatasourceInputSplit();
actual.readFields(in);
Assert.assertEquals(expected.getSegments(), actual.getSegments());
Assert.assertArrayEquals(expected.getLocations(), actual.getLocations());
Assert.assertEquals(12334, actual.getLength());
}
use of com.google.common.io.ByteArrayDataOutput in project presto by prestodb.
the class RaptorTableIdentity method serialize.
@Override
public byte[] serialize() {
ByteArrayDataOutput output = newDataOutput(SERIALIZED_SIZE);
output.write(CURRENT_VERSION);
output.writeLong(tableId);
return output.toByteArray();
}
use of com.google.common.io.ByteArrayDataOutput 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));
}
use of com.google.common.io.ByteArrayDataOutput in project presto by prestodb.
the class TestRaptorMetadata method testTableIdentity.
@Test
public void testTableIdentity() throws Exception {
// Test TableIdentity round trip.
metadata.createTable(SESSION, getOrdersTable());
ConnectorTableHandle connectorTableHandle = metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS);
TableIdentity tableIdentity = metadata.getTableIdentity(connectorTableHandle);
byte[] bytes = tableIdentity.serialize();
assertEquals(tableIdentity, metadata.deserializeTableIdentity(bytes));
// Test one hard coded serialized data for each version.
byte version = 1;
long tableId = 12345678L;
ByteArrayDataOutput dataOutput = newDataOutput();
dataOutput.writeByte(version);
dataOutput.writeLong(tableId);
byte[] testBytes = dataOutput.toByteArray();
TableIdentity testTableIdentity = metadata.deserializeTableIdentity(testBytes);
assertEquals(testTableIdentity, new RaptorTableIdentity(tableId));
}
use of com.google.common.io.ByteArrayDataOutput in project presto by prestodb.
the class WrappedRange method toBytes.
@JsonValue
public byte[] toBytes() throws IOException {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
range.write(out);
return out.toByteArray();
}
Aggregations