Search in sources :

Example 41 with ByteIterator

use of com.yahoo.ycsb.ByteIterator in project YCSB by brianfrankcooper.

the class RestClientTest method update_403.

@Test
public void update_403() {
    HashMap<String, ByteIterator> data = new HashMap<String, ByteIterator>();
    data.put(DATA_TAG, new StringByteIterator(INPUT_DATA));
    Status status = rc.update(null, UNAUTHORIZED_RESOURCE, data);
    assertEquals(Status.FORBIDDEN, status);
}
Also used : Status(com.yahoo.ycsb.Status) StringByteIterator(com.yahoo.ycsb.StringByteIterator) ByteIterator(com.yahoo.ycsb.ByteIterator) HashMap(java.util.HashMap) StringByteIterator(com.yahoo.ycsb.StringByteIterator) Test(org.junit.Test)

Example 42 with ByteIterator

use of com.yahoo.ycsb.ByteIterator in project YCSB by brianfrankcooper.

the class RestClientTest method insert_403.

@Test
public void insert_403() {
    HashMap<String, ByteIterator> data = new HashMap<String, ByteIterator>();
    data.put(DATA_TAG, new StringByteIterator(INPUT_DATA));
    Status status = rc.insert(null, UNAUTHORIZED_RESOURCE, data);
    assertEquals(Status.FORBIDDEN, status);
}
Also used : Status(com.yahoo.ycsb.Status) StringByteIterator(com.yahoo.ycsb.StringByteIterator) ByteIterator(com.yahoo.ycsb.ByteIterator) HashMap(java.util.HashMap) StringByteIterator(com.yahoo.ycsb.StringByteIterator) Test(org.junit.Test)

Example 43 with ByteIterator

use of com.yahoo.ycsb.ByteIterator in project YCSB by brianfrankcooper.

the class RestClientTest method insert_500.

@Test
public void insert_500() {
    HashMap<String, ByteIterator> data = new HashMap<String, ByteIterator>();
    data.put(DATA_TAG, new StringByteIterator(INPUT_DATA));
    Status status = rc.insert(null, INVALID_RESOURCE, data);
    assertEquals(Status.ERROR, status);
}
Also used : Status(com.yahoo.ycsb.Status) StringByteIterator(com.yahoo.ycsb.StringByteIterator) ByteIterator(com.yahoo.ycsb.ByteIterator) HashMap(java.util.HashMap) StringByteIterator(com.yahoo.ycsb.StringByteIterator) Test(org.junit.Test)

Example 44 with ByteIterator

use of com.yahoo.ycsb.ByteIterator in project YCSB by brianfrankcooper.

the class NoSqlDbClient method update.

@Override
public Status update(String table, String key, HashMap<String, ByteIterator> values) {
    for (Map.Entry<String, ByteIterator> entry : values.entrySet()) {
        Key kvKey = createKey(table, key, entry.getKey());
        Value kvValue = Value.createValue(entry.getValue().toArray());
        try {
            store.put(kvKey, kvValue);
        } catch (FaultException e) {
            System.err.println(e);
            return Status.ERROR;
        }
    }
    return Status.OK;
}
Also used : FaultException(oracle.kv.FaultException) ByteArrayByteIterator(com.yahoo.ycsb.ByteArrayByteIterator) ByteIterator(com.yahoo.ycsb.ByteIterator) Value(oracle.kv.Value) HashMap(java.util.HashMap) Map(java.util.Map) SortedMap(java.util.SortedMap) Key(oracle.kv.Key)

Example 45 with ByteIterator

use of com.yahoo.ycsb.ByteIterator in project YCSB by brianfrankcooper.

the class OrientDBClientTest method updateTest.

@Test
public void updateTest() {
    String preupdateString = "preupdate";
    String user0 = "user0";
    String user1 = "user1";
    String user2 = "user2";
    OPartitionedDatabasePool pool = orientDBClient.getDatabasePool();
    try (ODatabaseDocumentTx db = pool.acquire()) {
        // Manually insert three documents
        for (String key : Arrays.asList(user0, user1, user2)) {
            ODocument doc = new ODocument(CLASS);
            for (int i = 0; i < NUM_FIELDS; i++) {
                doc.field(FIELD_PREFIX + i, preupdateString);
            }
            doc.save();
            ODictionary<ORecord> dictionary = db.getDictionary();
            dictionary.put(key, doc);
        }
    }
    HashMap<String, ByteIterator> updateMap = new HashMap<>();
    for (int i = 0; i < NUM_FIELDS; i++) {
        updateMap.put(FIELD_PREFIX + i, new StringByteIterator(buildDeterministicValue(user1, FIELD_PREFIX + i)));
    }
    orientDBClient.update(CLASS, user1, updateMap);
    try (ODatabaseDocumentTx db = pool.acquire()) {
        ODictionary<ORecord> dictionary = db.getDictionary();
        // Ensure that user0 record was not changed
        ODocument result = dictionary.get(user0);
        for (int i = 0; i < NUM_FIELDS; i++) {
            assertEquals("Assert first row fields contain preupdateString", result.field(FIELD_PREFIX + i), preupdateString);
        }
        // Check that all the columns have expected values for user1 record
        result = dictionary.get(user1);
        for (int i = 0; i < NUM_FIELDS; i++) {
            assertEquals("Assert updated row fields are correct", result.field(FIELD_PREFIX + i), updateMap.get(FIELD_PREFIX + i).toString());
        }
        // Ensure that user2 record was not changed
        result = dictionary.get(user2);
        for (int i = 0; i < NUM_FIELDS; i++) {
            assertEquals("Assert third row fields contain preupdateString", result.field(FIELD_PREFIX + i), preupdateString);
        }
    }
}
Also used : StringByteIterator(com.yahoo.ycsb.StringByteIterator) ByteIterator(com.yahoo.ycsb.ByteIterator) OPartitionedDatabasePool(com.orientechnologies.orient.core.db.OPartitionedDatabasePool) ORecord(com.orientechnologies.orient.core.record.ORecord) StringByteIterator(com.yahoo.ycsb.StringByteIterator) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Aggregations

ByteIterator (com.yahoo.ycsb.ByteIterator)87 HashMap (java.util.HashMap)70 StringByteIterator (com.yahoo.ycsb.StringByteIterator)52 Status (com.yahoo.ycsb.Status)33 ByteArrayByteIterator (com.yahoo.ycsb.ByteArrayByteIterator)30 Test (org.junit.Test)30 DBException (com.yahoo.ycsb.DBException)20 Map (java.util.Map)14 IOException (java.io.IOException)8 EntityProperty (com.microsoft.azure.storage.table.EntityProperty)5 Vector (java.util.Vector)5 BaseDocument (com.arangodb.entity.BaseDocument)4 DynamicTableEntity (com.microsoft.azure.storage.table.DynamicTableEntity)4 DB (com.yahoo.ycsb.DB)4 ByteBuffer (java.nio.ByteBuffer)4 ArrayList (java.util.ArrayList)4 Put (org.apache.hadoop.hbase.client.Put)4 MongoCollection (com.allanbank.mongodb.MongoCollection)3 DocumentBuilder (com.allanbank.mongodb.bson.builder.DocumentBuilder)3 ArangoDBException (com.arangodb.ArangoDBException)3