Search in sources :

Example 41 with ByteIterator

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"));
}
Also used : Status(site.ycsb.Status) ByteIterator(site.ycsb.ByteIterator) StringByteIterator(site.ycsb.StringByteIterator) Test(org.junit.Test)

Example 42 with ByteIterator

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));
}
Also used : Status(site.ycsb.Status) ByteIterator(site.ycsb.ByteIterator) StringByteIterator(site.ycsb.StringByteIterator) Test(org.junit.Test)

Example 43 with ByteIterator

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"));
}
Also used : Status(site.ycsb.Status) ByteIterator(site.ycsb.ByteIterator) StringByteIterator(site.ycsb.StringByteIterator) Test(org.junit.Test)

Example 44 with ByteIterator

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());
}
Also used : Status(site.ycsb.Status) ByteIterator(site.ycsb.ByteIterator) StringByteIterator(site.ycsb.StringByteIterator) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 45 with ByteIterator

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());
    }
}
Also used : ByteIterator(site.ycsb.ByteIterator) StringByteIterator(site.ycsb.StringByteIterator) HashMap(java.util.HashMap) Properties(java.util.Properties) Vector(java.util.Vector)

Aggregations

ByteIterator (site.ycsb.ByteIterator)131 HashMap (java.util.HashMap)98 StringByteIterator (site.ycsb.StringByteIterator)92 Status (site.ycsb.Status)62 Test (org.junit.Test)53 ByteArrayByteIterator (site.ycsb.ByteArrayByteIterator)34 DBException (site.ycsb.DBException)30 Map (java.util.Map)20 IOException (java.io.IOException)10 Put (org.apache.hadoop.hbase.client.Put)8 ArrayList (java.util.ArrayList)7 Vector (java.util.Vector)7 ByteBuffer (java.nio.ByteBuffer)6 HashSet (java.util.HashSet)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)6 NumericByteIterator (site.ycsb.NumericByteIterator)5 EntityProperty (com.microsoft.azure.storage.table.EntityProperty)4 Properties (java.util.Properties)4 Assume.assumeNoException (org.junit.Assume.assumeNoException)4 DB (site.ycsb.DB)4