use of com.palantir.atlasdb.protos.generated.TableMetadataPersistence.ValueByteOrder in project atlasdb by palantir.
the class EncodingUtilsTest method testMulti.
@Test
public void testMulti() {
List<ValueType> valueTypes = ImmutableList.of(ValueType.FIXED_LONG, ValueType.FIXED_LONG_LITTLE_ENDIAN, ValueType.SHA256HASH, ValueType.VAR_LONG, ValueType.VAR_SIGNED_LONG, ValueType.VAR_STRING);
Random random = new Random();
for (int j = 0; j < 50; j++) {
byte[] bytesToHash = new byte[256];
rand.nextBytes(bytesToHash);
List<Object> defaultComponents = ImmutableList.<Object>of(rand.nextLong(), rand.nextLong(), Sha256Hash.computeHash(bytesToHash), rand.nextLong() & Long.MAX_VALUE, rand.nextLong(), new BigInteger(100, random).toString(32));
List<EncodingType> types = Lists.newArrayList();
List<Object> components = Lists.newArrayList();
for (int i = 0; i < 50; i++) {
int index = rand.nextInt(valueTypes.size());
ValueType type = valueTypes.get(index);
ValueByteOrder order = rand.nextBoolean() ? ValueByteOrder.ASCENDING : ValueByteOrder.DESCENDING;
types.add(new EncodingType(type, order));
components.add(defaultComponents.get(index));
}
byte[] b = EncodingUtils.toBytes(types, components);
List<Object> result = EncodingUtils.fromBytes(b, types);
assertEquals(components, result);
}
}
use of com.palantir.atlasdb.protos.generated.TableMetadataPersistence.ValueByteOrder in project atlasdb by palantir.
the class TableMetadataDeserializer method deserializeRowish.
private NameMetadataDescription deserializeRowish(JsonNode node) {
List<NameComponentDescription> rowComponents = Lists.newArrayList();
for (JsonNode rowNode : node.get("row")) {
String name = rowNode.get("name").asText();
ValueType type = ValueType.valueOf(rowNode.get("type").asText());
ValueByteOrder order = ValueByteOrder.valueOf(rowNode.get("order").asText());
rowComponents.add(new NameComponentDescription.Builder().componentName(name).type(type).byteOrder(order).build());
}
return NameMetadataDescription.create(rowComponents);
}
Aggregations