use of com.nearinfinity.honeycomb.hbase.rowkey.RowKey in project honeycomb by altamiracorp.
the class RowKeyTest method testRowKeyEncSort.
@Test
public void testRowKeyEncSort() {
List<RowKey> rowKeys = new ArrayList<RowKey>();
List<byte[]> encodedRowKeys = new ArrayList<byte[]>();
for (RowKey rowKey : Iterables.toIterable(rowKeyGen)) {
rowKeys.add(rowKey);
encodedRowKeys.add(rowKey.encode());
}
Collections.sort(rowKeys);
Collections.sort(encodedRowKeys, UnsignedBytes.lexicographicalComparator());
for (int i = 0; i < rowKeys.size(); i++) {
RowKey rowKey = rowKeys.get(i);
byte[] encodedRowKey = encodedRowKeys.get(i);
Assert.assertArrayEquals(encodedRowKey, rowKey.encode());
}
}
use of com.nearinfinity.honeycomb.hbase.rowkey.RowKey in project honeycomb by altamiracorp.
the class RowKeyTest method testIndexRowKeyStrings.
@Test
public void testIndexRowKeyStrings() {
String columnName = "c1";
String indexName = "i1";
ColumnSchema columnSchema = ColumnSchema.builder("default", ColumnType.DATETIME).build();
IndexSchema indexSchema = new IndexSchema(indexName, ImmutableList.of(columnName), false);
TableSchema tableSchema = new TableSchema(ImmutableList.of(columnSchema), ImmutableList.of(indexSchema));
Generator<RowKey> rowkeysGen = RowKeyGenerator.getAscIndexRowKeyGenerator(tableSchema);
List<RowKey> rowkeys = Lists.newArrayList(Iterables.toIterable(rowkeysGen));
Collections.sort(rowkeys);
List<byte[]> encodedRowkeys = Lists.newArrayList();
for (RowKey rowkey : rowkeys) {
encodedRowkeys.add(rowkey.encode());
}
Collections.sort(encodedRowkeys, new Bytes.ByteArrayComparator());
for (int i = 0; i < rowkeys.size(); i++) {
RowKey rowKey = rowkeys.get(i);
byte[] encodedRowKey = encodedRowkeys.get(i);
Assert.assertArrayEquals(encodedRowKey, rowKey.encode());
}
}
Aggregations