use of site.ycsb.ByteIterator in project YCSB by brianfrankcooper.
the class GridDBClientTest method testReadAll.
@Test
public void testReadAll() {
HashMap<String, ByteIterator> result = new HashMap<String, ByteIterator>();
insertToDatabase();
Status readStatus = myClient.read(TEST_TABLE, DEFAULT_ROW_KEY, null, result);
assertEquals(readStatus, Status.OK);
assertEquals(result.size(), FIELD_COUNT);
for (int i = 0; i < FIELD_COUNT; i++) {
ByteIterator iter = result.get("field" + i);
byte[] byteArray1 = iter.toArray();
String value = new String(byteArray1);
assertEquals(value, "value" + i);
}
}
use of site.ycsb.ByteIterator in project YCSB by brianfrankcooper.
the class GridDBClientTest method testDelete.
@Test
public void testDelete() {
HashMap<String, ByteIterator> result = new HashMap<String, ByteIterator>();
insertToDatabase();
Status deleteStatus = myClient.delete(TEST_TABLE, DEFAULT_ROW_KEY);
assertEquals(deleteStatus, Status.OK);
Status readStatus = myClient.read(TEST_TABLE, DEFAULT_ROW_KEY, null, result);
assertEquals(readStatus, Status.ERROR);
assertEquals(result.size(), 0);
}
use of site.ycsb.ByteIterator in project YCSB by brianfrankcooper.
the class HBaseClient1Test method testRead.
@Test
public void testRead() throws Exception {
final String rowKey = "row1";
final Put p = new Put(Bytes.toBytes(rowKey));
p.addColumn(Bytes.toBytes(COLUMN_FAMILY), Bytes.toBytes("column1"), Bytes.toBytes("value1"));
p.addColumn(Bytes.toBytes(COLUMN_FAMILY), Bytes.toBytes("column2"), Bytes.toBytes("value2"));
table.put(p);
final HashMap<String, ByteIterator> result = new HashMap<String, ByteIterator>();
final Status status = client.read(tableName, rowKey, null, result);
assertEquals(Status.OK, status);
assertEquals(2, result.size());
assertEquals("value1", result.get("column1").toString());
assertEquals("value2", result.get("column2").toString());
}
use of site.ycsb.ByteIterator in project YCSB by brianfrankcooper.
the class TimeSeriesWorkload method doTransactionRead.
protected void doTransactionRead(final DB db, Object threadstate) {
final ThreadState state = (ThreadState) threadstate;
final String keyname = keys[keychooser.nextValue().intValue()];
final Random random = ThreadLocalRandom.current();
int offsets = state.queryOffsetGenerator.nextValue().intValue();
// int offsets = random.nextInt(maxOffsets - 1);
final long startTimestamp;
if (offsets > 0) {
startTimestamp = state.startTimestamp + state.timestampGenerator.getOffset(offsets);
} else {
startTimestamp = state.startTimestamp;
}
// rando tags
Set<String> fields = new HashSet<String>();
for (int i = 0; i < tagPairs; ++i) {
if (groupBy && groupBys[i]) {
fields.add(tagKeys[i]);
} else {
fields.add(tagKeys[i] + tagPairDelimiter + tagValues[random.nextInt(tagCardinality[i])]);
}
}
if (queryTimeSpan > 0) {
final long endTimestamp;
if (queryRandomTimeSpan) {
endTimestamp = startTimestamp + (timestampInterval * random.nextInt(queryTimeSpan / timestampInterval));
} else {
endTimestamp = startTimestamp + queryTimeSpan;
}
fields.add(timestampKey + tagPairDelimiter + startTimestamp + queryTimeSpanDelimiter + endTimestamp);
} else {
fields.add(timestampKey + tagPairDelimiter + startTimestamp);
}
if (groupBy) {
fields.add(groupByKey + tagPairDelimiter + groupByFunction);
}
if (downsample) {
fields.add(downsampleKey + tagPairDelimiter + downsampleFunction + downsampleInterval);
}
final Map<String, ByteIterator> cells = new HashMap<String, ByteIterator>();
final Status status = db.read(table, keyname, fields, cells);
if (dataintegrity && status == Status.OK) {
verifyRow(keyname, cells);
}
}
use of site.ycsb.ByteIterator in project YCSB by brianfrankcooper.
the class TimeSeriesWorkload method doTransactionScan.
protected void doTransactionScan(final DB db, Object threadstate) {
final ThreadState state = (ThreadState) threadstate;
final Random random = ThreadLocalRandom.current();
final String keyname = keys[random.nextInt(keys.length)];
// choose a random scan length
int len = scanlength.nextValue().intValue();
int offsets = random.nextInt(maxOffsets - 1);
final long startTimestamp;
if (offsets > 0) {
startTimestamp = state.startTimestamp + state.timestampGenerator.getOffset(offsets);
} else {
startTimestamp = state.startTimestamp;
}
// rando tags
Set<String> fields = new HashSet<String>();
for (int i = 0; i < tagPairs; ++i) {
if (groupBy && groupBys[i]) {
fields.add(tagKeys[i]);
} else {
fields.add(tagKeys[i] + tagPairDelimiter + tagValues[random.nextInt(tagCardinality[i])]);
}
}
if (queryTimeSpan > 0) {
final long endTimestamp;
if (queryRandomTimeSpan) {
endTimestamp = startTimestamp + (timestampInterval * random.nextInt(queryTimeSpan / timestampInterval));
} else {
endTimestamp = startTimestamp + queryTimeSpan;
}
fields.add(timestampKey + tagPairDelimiter + startTimestamp + queryTimeSpanDelimiter + endTimestamp);
} else {
fields.add(timestampKey + tagPairDelimiter + startTimestamp);
}
if (groupBy) {
fields.add(groupByKey + tagPairDelimiter + groupByFunction);
}
if (downsample) {
fields.add(downsampleKey + tagPairDelimiter + downsampleFunction + tagPairDelimiter + downsampleInterval);
}
final Vector<HashMap<String, ByteIterator>> results = new Vector<HashMap<String, ByteIterator>>();
db.scan(table, keyname, len, fields, results);
}
Aggregations