use of site.ycsb.ByteIterator in project YCSB by brianfrankcooper.
the class IgniteSqlClientTest method testRead.
@Test
public void testRead() throws Exception {
cluster.cache(DEFAULT_CACHE_NAME).clear();
final String key = "key";
final Map<String, String> input = new HashMap<>();
input.put("field0", "value1");
input.put("field1", "value2A");
input.put("field3", null);
final Status sPut = client.insert(TABLE_NAME, key, StringByteIterator.getByteIteratorMap(input));
assertThat(sPut, is(Status.OK));
assertThat(cluster.cache(DEFAULT_CACHE_NAME).size(), is(1));
final Set<String> fld = new TreeSet<>();
fld.add("field0");
fld.add("field1");
fld.add("field3");
final HashMap<String, ByteIterator> result = new HashMap<>();
final Status sGet = client.read(TABLE_NAME, key, fld, result);
assertThat(sGet, is(Status.OK));
final HashMap<String, String> strResult = new HashMap<String, String>();
for (final Map.Entry<String, ByteIterator> e : result.entrySet()) {
if (e.getValue() != null) {
strResult.put(e.getKey(), e.getValue().toString());
}
}
assertThat(strResult, hasEntry("field0", "value1"));
assertThat(strResult, hasEntry("field1", "value2A"));
}
use of site.ycsb.ByteIterator in project YCSB by brianfrankcooper.
the class IgniteSqlClientTest method testReadNotPresent.
@Test
public void testReadNotPresent() throws Exception {
cluster.cache(DEFAULT_CACHE_NAME).clear();
final String key = "key";
final Map<String, String> input = new HashMap<>();
input.put("field0", "value1");
input.put("field1", "value2A");
input.put("field3", null);
final Status sPut = client.insert(TABLE_NAME, key, StringByteIterator.getByteIteratorMap(input));
assertThat(sPut, is(Status.OK));
assertThat(cluster.cache(DEFAULT_CACHE_NAME).size(), is(1));
final Set<String> fld = new TreeSet<>();
final String newKey = "newKey";
final HashMap<String, ByteIterator> result1 = new HashMap<>();
final Status sGet = client.read(TABLE_NAME, newKey, fld, result1);
assertThat(sGet, is(Status.NOT_FOUND));
}
use of site.ycsb.ByteIterator in project YCSB by brianfrankcooper.
the class IgniteSqlClientTest method testReadAllFields.
@Test
public void testReadAllFields() throws Exception {
cluster.cache(DEFAULT_CACHE_NAME).clear();
final String key = "key";
final Map<String, String> input = new HashMap<>();
input.put("field0", "value1");
input.put("field1", "value2A");
input.put("field3", null);
final Status sPut = client.insert(DEFAULT_CACHE_NAME, key, StringByteIterator.getByteIteratorMap(input));
assertThat(sPut, is(Status.OK));
assertThat(cluster.cache(DEFAULT_CACHE_NAME).size(), is(1));
final Set<String> fld = new TreeSet<>();
final HashMap<String, ByteIterator> result1 = new HashMap<>();
final Status sGet = client.read(TABLE_NAME, key, fld, result1);
assertThat(sGet, is(Status.OK));
final HashMap<String, String> strResult = new HashMap<String, String>();
for (final Map.Entry<String, ByteIterator> e : result1.entrySet()) {
if (e.getValue() != null) {
strResult.put(e.getKey(), e.getValue().toString());
}
}
assertThat(strResult, hasEntry("field0", "value1"));
assertThat(strResult, hasEntry("field1", "value2A"));
}
use of site.ycsb.ByteIterator in project YCSB by brianfrankcooper.
the class HBaseClient2Test method testReadMissingRow.
@Test
public void testReadMissingRow() throws Exception {
setUp();
final HashMap<String, ByteIterator> result = new HashMap<String, ByteIterator>();
final Status status = client.read(tableName, "Missing row", null, result);
assertEquals(Status.NOT_FOUND, status);
assertEquals(0, result.size());
}
use of site.ycsb.ByteIterator in project YCSB by brianfrankcooper.
the class HBaseClient2Test method testScanWithValueFiltering.
private void testScanWithValueFiltering(String operation, String filterValue, int scanRowLimit, byte[][] expectedValuesReturned) throws Exception {
Properties properties = new Properties();
properties.setProperty("hbase.usescanvaluefiltering", String.valueOf(true));
if (operation != null) {
properties.setProperty("hbase.scanfilteroperator", operation);
}
if (filterValue != null) {
properties.setProperty("hbase.scanfiltervalue", filterValue);
}
// setup the client and fill two columns with data
setUp(properties);
setupTableColumnWithHexValues("col_1");
setupTableColumnWithHexValues("col_2");
Vector<HashMap<String, ByteIterator>> result = new Vector<>();
// first scan the whole table (both columns)
client.scan(tableName, "00000", scanRowLimit, null, result);
assertEquals(expectedValuesReturned.length, result.size());
for (int i = 0; i < expectedValuesReturned.length; i++) {
final HashMap<String, ByteIterator> row = result.get(i);
assertEquals(2, row.size());
assertTrue(row.containsKey("col_1") && row.containsKey("col_2"));
assertArrayEquals(expectedValuesReturned[i], row.get("col_1").toArray());
assertArrayEquals(expectedValuesReturned[i], row.get("col_2").toArray());
}
// now scan only a single column (the filter should work here too)
result = new Vector<>();
client.scan(tableName, "00000", scanRowLimit, Collections.singleton("col_1"), result);
assertEquals(expectedValuesReturned.length, result.size());
for (int i = 0; i < expectedValuesReturned.length; i++) {
final HashMap<String, ByteIterator> row = result.get(i);
assertEquals(1, row.size());
assertTrue(row.containsKey("col_1"));
assertArrayEquals(expectedValuesReturned[i], row.get("col_1").toArray());
}
}
Aggregations