use of com.nearinfinity.honeycomb.mysql.Row in project honeycomb by altamiracorp.
the class RowOperationsIT method testUpdateNullRows.
@Test
public void testUpdateNullRows() {
HandlerProxy proxy = factory.createHandlerProxy();
List<ColumnSchema> columns = Lists.newArrayList();
List<IndexSchema> indices = Lists.newArrayList();
columns.add(ColumnSchema.builder(TestConstants.COLUMN1, ColumnType.LONG).build());
TableSchema schema = new TableSchema(columns, indices);
String tableName = AdapterType.HBASE.getName() + "/t1";
int iterations = 10;
proxy.createTable(tableName, schema.serialize(), 0);
proxy.openTable(tableName);
Row row = new Row(Maps.<String, ByteBuffer>newHashMap(), TestConstants.ZERO_UUID);
List<Row> rows = new ArrayList<Row>();
for (int j = 0; j < 50; j++) {
for (int i = 0; i < iterations; i++) {
proxy.insertRow(row.serialize());
}
proxy.flush();
proxy.startTableScan();
for (int i = 0; i < iterations; i++) {
Row deserialized = Row.deserialize(proxy.getNextRow());
deserialized.getRecords().put(TestConstants.COLUMN1, ITUtils.encodeValue(0));
rows.add(deserialized);
}
proxy.endScan();
for (Row r : rows) {
proxy.updateRow(r.serialize(), r.serialize());
}
proxy.flush();
rows.clear();
proxy.startTableScan();
for (int i = 0; i < iterations; i++) {
byte[] bytes = proxy.getNextRow();
assertNotNull(bytes);
assertThat(Row.deserialize(bytes).getRecords().get(TestConstants.COLUMN1), equalTo(ITUtils.encodeValue(0)));
}
assertNull(proxy.getNextRow());
proxy.endScan();
proxy.truncateTable();
}
proxy.closeTable();
proxy.dropTable(tableName);
}
use of com.nearinfinity.honeycomb.mysql.Row in project honeycomb by altamiracorp.
the class RowOperationsIT method testDeleteRow.
@Test
public void testDeleteRow() {
final Map<String, ByteBuffer> map = Maps.newHashMap();
map.put(TestConstants.COLUMN1, ITUtils.encodeValue(INDEX_COL_VALUE));
map.put(TestConstants.COLUMN2, ITUtils.encodeValue(6));
final Row row = new Row(map, UUID.randomUUID());
proxy.insertRow(row.serialize());
proxy.flush();
final QueryKey key = ITUtils.createKey(INDEX_COL_VALUE, QueryType.EXACT_KEY);
proxy.startIndexScan(key.serialize());
proxy.deleteRow(proxy.getNextRow());
proxy.flush();
}
Aggregations