Search in sources :

Example 1 with Status

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

the class ElasticsearchClientTest method testRead.

/**
 * Test of read method, of class ElasticsearchClient.
 */
@Test
public void testRead() {
    Set<String> fields = MOCK_DATA.keySet();
    HashMap<String, ByteIterator> resultParam = new HashMap<>(10);
    Status result = instance.read(MOCK_TABLE, MOCK_KEY1, fields, resultParam);
    assertEquals(Status.OK, result);
}
Also used : Status(site.ycsb.Status) ByteIterator(site.ycsb.ByteIterator) StringByteIterator(site.ycsb.StringByteIterator) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 2 with Status

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

the class ElasticsearchIntegTestBase method testRead.

/**
 * Test of read method, of class ElasticsearchClient.
 */
@Test
public void testRead() {
    final Set<String> fields = MOCK_DATA.keySet();
    final HashMap<String, ByteIterator> resultParam = new HashMap<>(10);
    final Status result = db.read(MOCK_TABLE, "1", fields, resultParam);
    assertEquals(Status.OK, result);
}
Also used : Status(site.ycsb.Status) ByteIterator(site.ycsb.ByteIterator) StringByteIterator(site.ycsb.StringByteIterator) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 3 with Status

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

the class ElasticsearchIntegTestBase method testUpdate.

/**
 * Test of update method, of class ElasticsearchClient.
 */
@Test
public void testUpdate() {
    final HashMap<String, ByteIterator> newValues = new HashMap<>(10);
    for (int i = 1; i <= 10; i++) {
        newValues.put(FIELD_PREFIX + i, new StringByteIterator("newvalue" + i));
    }
    final Status updateResult = db.update(MOCK_TABLE, "1", newValues);
    assertEquals(Status.OK, updateResult);
    // validate that the values changed
    final HashMap<String, ByteIterator> resultParam = new HashMap<>(10);
    final Status readResult = db.read(MOCK_TABLE, "1", MOCK_DATA.keySet(), resultParam);
    assertEquals(Status.OK, readResult);
    for (int i = 1; i <= 10; i++) {
        assertEquals("newvalue" + i, resultParam.get(FIELD_PREFIX + i).toString());
    }
}
Also used : Status(site.ycsb.Status) ByteIterator(site.ycsb.ByteIterator) StringByteIterator(site.ycsb.StringByteIterator) HashMap(java.util.HashMap) StringByteIterator(site.ycsb.StringByteIterator) Test(org.junit.Test)

Example 4 with Status

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

the class ElasticsearchIntegTestBase method testDelete.

/**
 * Test of delete method, of class ElasticsearchClient.
 */
@Test
public void testDelete() {
    final Status result = db.delete(MOCK_TABLE, "1");
    assertEquals(Status.OK, result);
}
Also used : Status(site.ycsb.Status) Test(org.junit.Test)

Example 5 with Status

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

the class CrailClient method read.

@Override
public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) {
    try {
        String path = table + "/" + key;
        CrailKeyValue file = client.lookup(path).get().asKeyValue();
        CrailBufferedInputStream stream = file.getBufferedInputStream(1024);
        while (stream.available() < Integer.BYTES) {
            assert true;
        }
        int fieldKeyLength = stream.readInt();
        while (stream.available() < fieldKeyLength) {
            assert true;
        }
        byte[] fieldKey = new byte[fieldKeyLength];
        int res = stream.read(fieldKey);
        if (res != fieldKey.length) {
            stream.close();
            return Status.ERROR;
        }
        while (stream.available() < Integer.BYTES) {
            assert true;
        }
        int fieldValueLength = stream.readInt();
        while (stream.available() < fieldValueLength) {
            assert true;
        }
        byte[] fieldValue = new byte[fieldValueLength];
        res = stream.read(fieldValue);
        if (res != fieldValue.length) {
            stream.close();
            return Status.ERROR;
        }
        result.put(new String(fieldKey), new ByteArrayByteIterator(fieldValue));
        stream.close();
        return Status.OK;
    } catch (Exception e) {
        LOG.error("Error during read, table " + table + ", key " + key + ", exception " + e.getMessage());
        return new Status("read error", "reading exception");
    }
}
Also used : Status(site.ycsb.Status) ByteArrayByteIterator(site.ycsb.ByteArrayByteIterator) CrailKeyValue(org.apache.crail.CrailKeyValue) CrailBufferedInputStream(org.apache.crail.CrailBufferedInputStream) DBException(site.ycsb.DBException)

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