Search in sources :

Example 71 with Status

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

the class VoltDBClientTest method insertDeleteAndReadTest.

@Test
public void insertDeleteAndReadTest() {
    Assume.assumeTrue(haveDb);
    try {
        // Create some test data
        final String insertKey = INSERT_DELETE_AND_READ_TEST_KEY;
        final Set<String> columns = getColumnNameMap();
        // Insert row
        HashMap<String, ByteIterator> insertMap = new HashMap<String, ByteIterator>();
        for (int i = 0; i < NUM_FIELDS; i++) {
            insertMap.put(FIELD_PREFIX + i, new StringByteIterator(buildDeterministicValue(insertKey, FIELD_PREFIX + i)));
        }
        voltClient.insert(TABLE_NAME, insertKey, insertMap);
        // Create a object to put retrieved row in...
        Map<String, ByteIterator> testResult = new HashMap<String, ByteIterator>();
        // Read row...
        Status s = voltClient.read(TABLE_NAME, insertKey, columns, testResult);
        if (!s.equals(Status.OK)) {
            fail("Didn't get OK on read.");
        }
        if (!compareContents(insertMap, testResult)) {
            fail("Returned data not the same as inserted data");
        }
        voltClient.delete(TABLE_NAME, insertKey);
        // Create another object to put retrieved row in...
        Map<String, ByteIterator> testResultAfterDelete = new HashMap<String, ByteIterator>();
        // Read row...
        voltClient.read(TABLE_NAME, insertKey, columns, testResultAfterDelete);
        if (testResultAfterDelete.size() > 0) {
            fail("testResultAfterDelete has value.");
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail("Failed insertDeleteAndReadTest");
    }
}
Also used : Status(site.ycsb.Status) ByteIterator(site.ycsb.ByteIterator) StringByteIterator(site.ycsb.StringByteIterator) HashMap(java.util.HashMap) StringByteIterator(site.ycsb.StringByteIterator) Assume.assumeNoException(org.junit.Assume.assumeNoException) DBException(site.ycsb.DBException)

Example 72 with Status

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

the class VoltDBClientTest method singleScanReadTest.

private void singleScanReadTest(String startKey, int requestedCount, int expectedCount, String lastKey) {
    Assume.assumeTrue(haveDb);
    try {
        final Set<String> columns = getColumnNameMap();
        // Create a object to put retrieved row in...
        Vector<HashMap<String, ByteIterator>> testResult = new Vector<HashMap<String, ByteIterator>>();
        // Read row...
        Status s = voltClient.scan(TABLE_NAME, startKey, expectedCount, columns, testResult);
        if (!s.equals(Status.OK)) {
            fail("Didn't get OK on read.");
        }
        if (testResult.size() != expectedCount) {
            fail("Failed singleScanReadTest " + startKey + " " + expectedCount + " " + lastKey);
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail("Failed singleScanReadTest " + startKey + ". Asked for " + requestedCount + ", expected " + expectedCount + " lastkey=" + lastKey);
    }
}
Also used : Status(site.ycsb.Status) ByteIterator(site.ycsb.ByteIterator) StringByteIterator(site.ycsb.StringByteIterator) HashMap(java.util.HashMap) Vector(java.util.Vector) Assume.assumeNoException(org.junit.Assume.assumeNoException) DBException(site.ycsb.DBException)

Example 73 with Status

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

the class VoltDBClientTest method updateTest.

@Test
public void updateTest() {
    Assume.assumeTrue(haveDb);
    try {
        // Create some test data
        final String insertKey = UPDATE_TEST_KEY;
        // Insert row
        // Insert row
        HashMap<String, ByteIterator> insertThenUpdateMap = new HashMap<String, ByteIterator>();
        for (int i = 0; i < NUM_FIELDS; i++) {
            insertThenUpdateMap.put(FIELD_PREFIX + i, new StringByteIterator(buildDeterministicValue(insertKey, FIELD_PREFIX + i)));
        }
        voltClient.insert(TABLE_NAME, insertKey, insertThenUpdateMap);
        // Change the data we inserted...
        for (int i = 0; i < NUM_FIELDS; i++) {
            insertThenUpdateMap.put(FIELD_PREFIX + i, new StringByteIterator(FIELD_PREFIX + i + " has changed"));
        }
        // now do an update
        voltClient.update(TABLE_NAME, insertKey, insertThenUpdateMap);
        // Create a object to put retrieved row in...
        final Set<String> columns = getColumnNameMap();
        Map<String, ByteIterator> testResult = new HashMap<String, ByteIterator>();
        // Read row...
        Status s = voltClient.read(TABLE_NAME, insertKey, columns, testResult);
        if (!s.equals(Status.OK)) {
            fail("Didn't get OK on read.");
        }
        if (!compareContents(insertThenUpdateMap, testResult)) {
            fail("Returned data not the same as inserted data");
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail("Failed updateTest");
    }
}
Also used : Status(site.ycsb.Status) ByteIterator(site.ycsb.ByteIterator) StringByteIterator(site.ycsb.StringByteIterator) HashMap(java.util.HashMap) StringByteIterator(site.ycsb.StringByteIterator) Assume.assumeNoException(org.junit.Assume.assumeNoException) DBException(site.ycsb.DBException)

Example 74 with Status

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

the class SolrClientBaseTest method testRead.

@Test
public void testRead() throws Exception {
    Set<String> fields = MOCK_DATA.keySet();
    HashMap<String, ByteIterator> resultParam = new HashMap<>(NUM_RECORDS);
    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)

Example 75 with Status

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

the class ScyllaCQLClientTest method testUpdate.

@Test
public void testUpdate() {
    insertRow();
    final Map<String, String> input = new HashMap<>();
    input.put("field0", "new-value1");
    input.put("field1", "new-value2");
    final Status status = client.update(TABLE, DEFAULT_ROW_KEY, StringByteIterator.getByteIteratorMap(input));
    assertThat(status, is(Status.OK));
    // Verify result
    final Select selectStmt = QueryBuilder.select("field0", "field1").from(TABLE).where(QueryBuilder.eq(ScyllaCQLClient.YCSB_KEY, DEFAULT_ROW_KEY)).limit(1);
    final ResultSet rs = session.execute(selectStmt);
    final Row row = rs.one();
    assertThat(row, notNullValue());
    assertThat(rs.isExhausted(), is(true));
    assertThat(row.getString("field0"), is("new-value1"));
    assertThat(row.getString("field1"), is("new-value2"));
}
Also used : Status(site.ycsb.Status) HashMap(java.util.HashMap) Select(com.datastax.driver.core.querybuilder.Select) ResultSet(com.datastax.driver.core.ResultSet) Row(com.datastax.driver.core.Row) 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