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 EventHub by Codecademy.
the class JournalUtil method locationToBytes.
public static byte[] locationToBytes(Location location) throws IOException {
ByteArrayDataOutput dos = ByteStreams.newDataOutput();
location.writeExternal(dos);
return dos.toByteArray();
}
use of com.google.common.io.ByteArrayDataOutput in project oxAuth by GluuFederation.
the class RawAuthenticationService method packBytesToSign.
private byte[] packBytesToSign(byte[] appIdHash, byte userPresence, long counter, byte[] challengeHash) {
ByteArrayDataOutput encoded = ByteStreams.newDataOutput();
encoded.write(appIdHash);
encoded.write(userPresence);
encoded.writeInt((int) counter);
encoded.write(challengeHash);
return encoded.toByteArray();
}
use of com.google.common.io.ByteArrayDataOutput in project oxAuth by GluuFederation.
the class RawRegistrationService method packBytesToSign.
private byte[] packBytesToSign(byte[] appIdHash, byte[] clientDataHash, byte[] keyHandle, byte[] userPublicKey) {
ByteArrayDataOutput encoded = ByteStreams.newDataOutput();
encoded.write(REGISTRATION_SIGNED_RESERVED_BYTE_VALUE);
encoded.write(appIdHash);
encoded.write(clientDataHash);
encoded.write(keyHandle);
encoded.write(userPublicKey);
return encoded.toByteArray();
}
Aggregations