Search in sources :

Example 91 with Status

use of site.ycsb.Status in project YCSB by brianfrankcooper.

the class RadosClient method read.

@Override
public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) {
    byte[] buffer;
    try {
        RadosObjectInfo info = ioctx.stat(key);
        buffer = new byte[(int) info.getSize()];
        ReadOp rop = ioctx.readOpCreate();
        ReadResult readResult = rop.queueRead(0, info.getSize());
        // TODO: more size than byte length possible;
        // rop.operate(key, Rados.OPERATION_NOFLAG); // for rados-java 0.3.0
        rop.operate(key, 0);
        // readResult.raiseExceptionOnError("Error ReadOP(%d)", readResult.getRVal()); // for rados-java 0.3.0
        if (readResult.getRVal() < 0) {
            throw new RadosException("Error ReadOP", readResult.getRVal());
        }
        if (info.getSize() != readResult.getBytesRead()) {
            return new Status("ERROR", "Error the object size read");
        }
        readResult.getBuffer().get(buffer);
    } catch (RadosException e) {
        return new Status("ERROR-" + e.getReturnValue(), e.getMessage());
    }
    JSONObject json = new JSONObject(new String(buffer, java.nio.charset.StandardCharsets.UTF_8));
    Set<String> fieldsToReturn = (fields == null ? json.keySet() : fields);
    for (String name : fieldsToReturn) {
        result.put(name, new StringByteIterator(json.getString(name)));
    }
    return result.isEmpty() ? Status.ERROR : Status.OK;
}
Also used : RadosObjectInfo(com.ceph.rados.jna.RadosObjectInfo) Status(site.ycsb.Status) JSONObject(org.json.JSONObject) StringByteIterator(site.ycsb.StringByteIterator) ReadResult(com.ceph.rados.ReadOp.ReadResult) RadosException(com.ceph.rados.exceptions.RadosException) ReadOp(com.ceph.rados.ReadOp)

Example 92 with Status

use of site.ycsb.Status in project YCSB by brianfrankcooper.

the class RadosClientTest method updateTest.

@Test
public void updateTest() {
    radosclient.insert(TABLE_NAME, KEY2, DATA);
    Status result = radosclient.update(TABLE_NAME, KEY2, DATA_UPDATED);
    assertEquals(Status.OK, result);
    HashMap<String, ByteIterator> ret = new HashMap<String, ByteIterator>(10);
    radosclient.read(TABLE_NAME, KEY2, DATA.keySet(), ret);
    compareMap(DATA_UPDATED, ret);
    radosclient.delete(TABLE_NAME, KEY2);
}
Also used : Status(site.ycsb.Status) ByteIterator(site.ycsb.ByteIterator) StringByteIterator(site.ycsb.StringByteIterator) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 93 with Status

use of site.ycsb.Status in project YCSB by brianfrankcooper.

the class RadosClientTest method deleteTest.

@Test
public void deleteTest() {
    Status result = radosclient.delete(TABLE_NAME, KEY0);
    assertEquals(Status.OK, result);
}
Also used : Status(site.ycsb.Status) Test(org.junit.Test)

Example 94 with Status

use of site.ycsb.Status in project YCSB by brianfrankcooper.

the class RadosClientTest method readTest.

@Test
public void readTest() {
    HashMap<String, ByteIterator> ret = new HashMap<String, ByteIterator>(10);
    Status result = radosclient.read(TABLE_NAME, KEY0, DATA.keySet(), ret);
    assertEquals(Status.OK, result);
    compareMap(DATA, ret);
}
Also used : Status(site.ycsb.Status) ByteIterator(site.ycsb.ByteIterator) StringByteIterator(site.ycsb.StringByteIterator) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 95 with Status

use of site.ycsb.Status in project YCSB by brianfrankcooper.

the class IgniteSqlClientTest method testInsert.

@Test
public void testInsert() 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", "value2");
    final Status status = client.insert(TABLE_NAME, key, StringByteIterator.getByteIteratorMap(input));
    assertThat(status, is(Status.OK));
    assertThat(cluster.cache(DEFAULT_CACHE_NAME).size(), is(1));
}
Also used : Status(site.ycsb.Status) Test(org.junit.Test)

Aggregations

Status (site.ycsb.Status)101 Test (org.junit.Test)80 ByteIterator (site.ycsb.ByteIterator)62 HashMap (java.util.HashMap)60 StringByteIterator (site.ycsb.StringByteIterator)60 ResultSet (com.datastax.driver.core.ResultSet)6 Row (com.datastax.driver.core.Row)6 Select (com.datastax.driver.core.querybuilder.Select)6 Vector (java.util.Vector)6 ByteArrayByteIterator (site.ycsb.ByteArrayByteIterator)5 DBException (site.ycsb.DBException)5 Assume.assumeNoException (org.junit.Assume.assumeNoException)4 DB (site.ycsb.DB)4 Get (org.apache.hadoop.hbase.client.Get)3 Put (org.apache.hadoop.hbase.client.Put)3 Result (org.apache.hadoop.hbase.client.Result)3 DatastoreException (com.google.datastore.v1.client.DatastoreException)2 Map (java.util.Map)2 User (org.apache.gora.benchmark.generated.User)2 NumericByteIterator (site.ycsb.NumericByteIterator)2