Search in sources :

Example 91 with ByteIterator

use of site.ycsb.ByteIterator 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 92 with ByteIterator

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

the class VoltClient4 method packRowData.

private byte[] packRowData(Map<String, ByteIterator> columns) {
    mwriteBuf.clear();
    mwriteBuf.putInt(columns.size());
    for (String key : columns.keySet()) {
        byte[] k = key.getBytes(UTF8);
        mwriteBuf.putInt(k.length);
        mwriteBuf.put(k);
        ByteIterator v = columns.get(key);
        int len = (int) v.bytesLeft();
        mwriteBuf.putInt(len);
        v.nextBuf(mworkingData, mwriteBuf.position());
        mwriteBuf.position(mwriteBuf.position() + len);
    }
    byte[] data = new byte[mwriteBuf.position()];
    System.arraycopy(mworkingData, 0, data, 0, data.length);
    return data;
}
Also used : ByteIterator(site.ycsb.ByteIterator) ByteArrayByteIterator(site.ycsb.ByteArrayByteIterator)

Example 93 with ByteIterator

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

the class VoltClient4 method unpackRowDataHashMap.

private HashMap<String, ByteIterator> unpackRowDataHashMap(VoltTable data, Set<String> fields) {
    byte[] rowData = data.getVarbinary(0);
    ByteBuffer buf = ByteBuffer.wrap(rowData);
    int nFields = buf.getInt();
    int size = fields != null ? Math.min(fields.size(), nFields) : nFields;
    HashMap<String, ByteIterator> res = new HashMap<String, ByteIterator>(size, (float) 1.25);
    return unpackRowDataHashMap(rowData, buf, nFields, fields, res);
}
Also used : ByteIterator(site.ycsb.ByteIterator) ByteArrayByteIterator(site.ycsb.ByteArrayByteIterator) HashMap(java.util.HashMap) ByteBuffer(java.nio.ByteBuffer)

Example 94 with ByteIterator

use of site.ycsb.ByteIterator 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 95 with ByteIterator

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

the class ScyllaCQLClientTest method testReadMissingRow.

@Test
public void testReadMissingRow() {
    final HashMap<String, ByteIterator> result = new HashMap<>();
    final Status status = client.read(TABLE, "Missing row", null, result);
    assertThat(result.size(), is(0));
    assertThat(status, is(Status.NOT_FOUND));
}
Also used : Status(site.ycsb.Status) ByteIterator(site.ycsb.ByteIterator) StringByteIterator(site.ycsb.StringByteIterator) HashMap(java.util.HashMap) Test(org.junit.Test)

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