Search in sources :

Example 21 with ByteIterator

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

the class RestClientTest method read_404.

// Not found error.
@Test
public void read_404() {
    HashMap<String, ByteIterator> result = new HashMap<String, ByteIterator>();
    Status status = rc.read(null, ABSENT_RESOURCE, null, result);
    assertEquals(Status.NOT_FOUND, status);
}
Also used : Status(site.ycsb.Status) ByteIterator(site.ycsb.ByteIterator) StringByteIterator(site.ycsb.StringByteIterator) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 22 with ByteIterator

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

the class RestClientTest method read_403.

// Unauthorized request error.
@Test
public void read_403() {
    HashMap<String, ByteIterator> result = new HashMap<String, ByteIterator>();
    Status status = rc.read(null, UNAUTHORIZED_RESOURCE, null, result);
    assertEquals(Status.FORBIDDEN, status);
}
Also used : Status(site.ycsb.Status) ByteIterator(site.ycsb.ByteIterator) StringByteIterator(site.ycsb.StringByteIterator) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 23 with ByteIterator

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

the class RestClientTest method update_500.

@Test
public void update_500() {
    HashMap<String, ByteIterator> data = new HashMap<String, ByteIterator>();
    data.put(DATA_TAG, new StringByteIterator(INPUT_DATA));
    Status status = rc.update(null, INVALID_RESOURCE, data);
    assertEquals(Status.ERROR, status);
}
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 24 with ByteIterator

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

the class RadosClientTest method compareMap.

private void compareMap(HashMap<String, ByteIterator> src, HashMap<String, ByteIterator> dest) {
    assertEquals(src.size(), dest.size());
    Set setSrc = src.entrySet();
    Iterator<Map.Entry> itSrc = setSrc.iterator();
    for (int i = 0; i < 10; i++) {
        Map.Entry<String, ByteIterator> entrySrc = itSrc.next();
        assertEquals(entrySrc.getValue().toString(), dest.get(entrySrc.getKey()).toString());
    }
}
Also used : Set(java.util.Set) ByteIterator(site.ycsb.ByteIterator) StringByteIterator(site.ycsb.StringByteIterator) HashMap(java.util.HashMap) Map(java.util.Map)

Example 25 with ByteIterator

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

the class HBaseClient1Test method testScan.

@Test
public void testScan() throws Exception {
    // Fill with data
    final String colStr = "row_number";
    final byte[] col = Bytes.toBytes(colStr);
    final int n = 10;
    final List<Put> puts = new ArrayList<Put>(n);
    for (int i = 0; i < n; i++) {
        final byte[] key = Bytes.toBytes(String.format("%05d", i));
        final byte[] value = java.nio.ByteBuffer.allocate(4).putInt(i).array();
        final Put p = new Put(key);
        p.addColumn(Bytes.toBytes(COLUMN_FAMILY), col, value);
        puts.add(p);
    }
    table.put(puts);
    // Test
    final Vector<HashMap<String, ByteIterator>> result = new Vector<HashMap<String, ByteIterator>>();
    // Scan 5 records, skipping the first
    client.scan(tableName, "00001", 5, null, result);
    assertEquals(5, result.size());
    for (int i = 0; i < 5; i++) {
        final HashMap<String, ByteIterator> row = result.get(i);
        assertEquals(1, row.size());
        assertTrue(row.containsKey(colStr));
        final byte[] bytes = row.get(colStr).toArray();
        final ByteBuffer buf = ByteBuffer.wrap(bytes);
        final int rowNum = buf.getInt();
        assertEquals(i + 1, rowNum);
    }
}
Also used : ByteIterator(site.ycsb.ByteIterator) StringByteIterator(site.ycsb.StringByteIterator) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Vector(java.util.Vector) ByteBuffer(java.nio.ByteBuffer) Put(org.apache.hadoop.hbase.client.Put) 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