use of site.ycsb.ByteIterator in project YCSB by brianfrankcooper.
the class VoltDBClientTest method updateTest.
@Test
public void updateTest() {
Assume.assumeTrue(haveDb);
try {
// Create some test data
final String insertKey = UPDATE_TEST_KEY;
// Insert row
// Insert row
HashMap<String, ByteIterator> insertThenUpdateMap = new HashMap<String, ByteIterator>();
for (int i = 0; i < NUM_FIELDS; i++) {
insertThenUpdateMap.put(FIELD_PREFIX + i, new StringByteIterator(buildDeterministicValue(insertKey, FIELD_PREFIX + i)));
}
voltClient.insert(TABLE_NAME, insertKey, insertThenUpdateMap);
// Change the data we inserted...
for (int i = 0; i < NUM_FIELDS; i++) {
insertThenUpdateMap.put(FIELD_PREFIX + i, new StringByteIterator(FIELD_PREFIX + i + " has changed"));
}
// now do an update
voltClient.update(TABLE_NAME, insertKey, insertThenUpdateMap);
// Create a object to put retrieved row in...
final Set<String> columns = getColumnNameMap();
Map<String, ByteIterator> testResult = new HashMap<String, ByteIterator>();
// Read row...
Status s = voltClient.read(TABLE_NAME, insertKey, columns, testResult);
if (!s.equals(Status.OK)) {
fail("Didn't get OK on read.");
}
if (!compareContents(insertThenUpdateMap, testResult)) {
fail("Returned data not the same as inserted data");
}
} catch (Exception e) {
e.printStackTrace();
fail("Failed updateTest");
}
}
use of site.ycsb.ByteIterator in project YCSB by brianfrankcooper.
the class VoltClient4 method packRowData.
private byte[] packRowData(Map<String, ByteIterator> columns) {
mwriteBuf.clear();
mwriteBuf.putInt(columns.size());
for (String key : columns.keySet()) {
byte[] k = key.getBytes(UTF8);
mwriteBuf.putInt(k.length);
mwriteBuf.put(k);
ByteIterator v = columns.get(key);
int len = (int) v.bytesLeft();
mwriteBuf.putInt(len);
v.nextBuf(mworkingData, mwriteBuf.position());
mwriteBuf.position(mwriteBuf.position() + len);
}
byte[] data = new byte[mwriteBuf.position()];
System.arraycopy(mworkingData, 0, data, 0, data.length);
return data;
}
use of site.ycsb.ByteIterator in project YCSB by brianfrankcooper.
the class VoltClient4 method unpackRowDataHashMap.
private HashMap<String, ByteIterator> unpackRowDataHashMap(VoltTable data, Set<String> fields) {
byte[] rowData = data.getVarbinary(0);
ByteBuffer buf = ByteBuffer.wrap(rowData);
int nFields = buf.getInt();
int size = fields != null ? Math.min(fields.size(), nFields) : nFields;
HashMap<String, ByteIterator> res = new HashMap<String, ByteIterator>(size, (float) 1.25);
return unpackRowDataHashMap(rowData, buf, nFields, fields, res);
}
use of site.ycsb.ByteIterator in project YCSB by brianfrankcooper.
the class SolrClientBaseTest method testRead.
@Test
public void testRead() throws Exception {
Set<String> fields = MOCK_DATA.keySet();
HashMap<String, ByteIterator> resultParam = new HashMap<>(NUM_RECORDS);
Status result = instance.read(MOCK_TABLE, MOCK_KEY1, fields, resultParam);
assertEquals(Status.OK, result);
}
use of site.ycsb.ByteIterator in project YCSB by brianfrankcooper.
the class ScyllaCQLClientTest method testReadMissingRow.
@Test
public void testReadMissingRow() {
final HashMap<String, ByteIterator> result = new HashMap<>();
final Status status = client.read(TABLE, "Missing row", null, result);
assertThat(result.size(), is(0));
assertThat(status, is(Status.NOT_FOUND));
}
Aggregations