@Test public void testUpdate() { HashMap<String, ByteIterator> result = new HashMap<String, ByteIterator>(); HashMap<String, ByteIterator> values = new HashMap<String, ByteIterator>(); insertToDatabase(); String keyForUpdate = "field2"; Set<String> fields = Collections.singleton(keyForUpdate); String strValueToUpdate = "new_value_2"; ByteIterator valForUpdate = new StringByteIterator(strValueToUpdate); values.put(keyForUpdate, valForUpdate); Status updateStatus = myClient.update(TEST_TABLE, DEFAULT_ROW_KEY, values); assertEquals(updateStatus, Status.OK); myClient.read(TEST_TABLE, DEFAULT_ROW_KEY, fields, result); assertNotEquals(result.entrySet(), 0); boolean found = false; for (int i = 0; i < FIELD_COUNT; i++) { ByteIterator iter = result.get("field" + i); byte[] byteArray1 = iter.toArray(); String value = new String(byteArray1); if (value.equals(strValueToUpdate)) { found = true; } } assertEquals(found, true); }
public Status update(String table, String key, Map<String, ByteIterator> values) { try { Object rowKey = makeRowKey(key); String containerKey = makeContainerKey(key); final Container<Object, Row> container = store.getContainer(containerKey); if(container == null) { LOGGER.severe("[ERROR]getCollection " + containerKey + " in update()"); return Status.ERROR; } Row targetRow = container.get(rowKey); if (targetRow == null) { LOGGER.severe("[ERROR]get(rowKey) in update()"); return Status.ERROR; } int setCount = 0; for (int i = 1; i < containerInfo.getColumnCount() && setCount < values.size(); i++) { containerInfo.getColumnInfo(i).getName(); ByteIterator byteIterator = values.get(containerInfo.getColumnInfo(i).getName()); if (byteIterator != null) { Object value = makeValue(byteIterator); targetRow.setValue(i, value); setCount++; } } if (setCount != values.size()) { LOGGER.severe("Error setCount = " + setCount); return Status.ERROR; } container.put(targetRow); return Status.OK; } catch (GSException e) { LOGGER.severe("Exception: " + e.getMessage()); return Status.ERROR; } }
GridDBClient extends site.ycsb.DB { public Status update(String table, String key, Map<String, ByteIterator> values) { try { Object rowKey = makeRowKey(key); String containerKey = makeContainerKey(key); final Container<Object, Row> container = store.getContainer(containerKey); if(container == null) { LOGGER.severe("[ERROR]getCollection " + containerKey + " in update()"); return Status.ERROR; } Row targetRow = container.get(rowKey); if (targetRow == null) { LOGGER.severe("[ERROR]get(rowKey) in update()"); return Status.ERROR; } int setCount = 0; for (int i = 1; i < containerInfo.getColumnCount() && setCount < values.size(); i++) { containerInfo.getColumnInfo(i).getName(); ByteIterator byteIterator = values.get(containerInfo.getColumnInfo(i).getName()); if (byteIterator != null) { Object value = makeValue(byteIterator); targetRow.setValue(i, value); setCount++; } } if (setCount != values.size()) { LOGGER.severe("Error setCount = " + setCount); return Status.ERROR; } container.put(targetRow); return Status.OK; } catch (GSException e) { LOGGER.severe("Exception: " + e.getMessage()); return Status.ERROR; } } }
GridDBClient extends site.ycsb.DB { public Status update(String table, String key, Map<String, ByteIterator> values) { try { Object rowKey = makeRowKey(key); String containerKey = makeContainerKey(key); final Container<Object, Row> container = store.getContainer(containerKey); if(container == null) { LOGGER.severe("[ERROR]getCollection " + containerKey + " in update()"); return Status.ERROR; } Row targetRow = container.get(rowKey); if (targetRow == null) { LOGGER.severe("[ERROR]get(rowKey) in update()"); return Status.ERROR; } int setCount = 0; for (int i = 1; i < containerInfo.getColumnCount() && setCount < values.size(); i++) { containerInfo.getColumnInfo(i).getName(); ByteIterator byteIterator = values.get(containerInfo.getColumnInfo(i).getName()); if (byteIterator != null) { Object value = makeValue(byteIterator); targetRow.setValue(i, value); setCount++; } } if (setCount != values.size()) { LOGGER.severe("Error setCount = " + setCount); return Status.ERROR; } container.put(targetRow); return Status.OK; } catch (GSException e) { LOGGER.severe("Exception: " + e.getMessage()); return Status.ERROR; } }  }
GridDBClient extends site.ycsb.DB { public Status update(String table, String key, Map<String, ByteIterator> values) { try { Object rowKey = makeRowKey(key); String containerKey = makeContainerKey(key); final Container<Object, Row> container = store.getContainer(containerKey); if(container == null) { LOGGER.severe("[ERROR]getCollection " + containerKey + " in update()"); return Status.ERROR; } Row targetRow = container.get(rowKey); if (targetRow == null) { LOGGER.severe("[ERROR]get(rowKey) in update()"); return Status.ERROR; } int setCount = 0; for (int i = 1; i < containerInfo.getColumnCount() && setCount < values.size(); i++) { containerInfo.getColumnInfo(i).getName(); ByteIterator byteIterator = values.get(containerInfo.getColumnInfo(i).getName()); if (byteIterator != null) { Object value = makeValue(byteIterator); targetRow.setValue(i, value); setCount++; } } if (setCount != values.size()) { LOGGER.severe("Error setCount = " + setCount); return Status.ERROR; } container.put(targetRow); return Status.OK; } catch (GSException e) { LOGGER.severe("Exception: " + e.getMessage()); return Status.ERROR; } }  void init(); void cleanup(); Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result); Status scan(String table, String startkey, int recordcount, Set<String> fields,
          Vector<HashMap<String, ByteIterator>> result); Status update(String table, String key, Map<String, ByteIterator> values); Status insert(String table, String key, Map<String, ByteIterator> values); Status delete(String table, String key); }
GridDBClient extends site.ycsb.DB { public Status update(String table, String key, Map<String, ByteIterator> values) { try { Object rowKey = makeRowKey(key); String containerKey = makeContainerKey(key); final Container<Object, Row> container = store.getContainer(containerKey); if(container == null) { LOGGER.severe("[ERROR]getCollection " + containerKey + " in update()"); return Status.ERROR; } Row targetRow = container.get(rowKey); if (targetRow == null) { LOGGER.severe("[ERROR]get(rowKey) in update()"); return Status.ERROR; } int setCount = 0; for (int i = 1; i < containerInfo.getColumnCount() && setCount < values.size(); i++) { containerInfo.getColumnInfo(i).getName(); ByteIterator byteIterator = values.get(containerInfo.getColumnInfo(i).getName()); if (byteIterator != null) { Object value = makeValue(byteIterator); targetRow.setValue(i, value); setCount++; } } if (setCount != values.size()) { LOGGER.severe("Error setCount = " + setCount); return Status.ERROR; } container.put(targetRow); return Status.OK; } catch (GSException e) { LOGGER.severe("Exception: " + e.getMessage()); return Status.ERROR; } }  void init(); void cleanup(); Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result); Status scan(String table, String startkey, int recordcount, Set<String> fields,
          Vector<HashMap<String, ByteIterator>> result); Status update(String table, String key, Map<String, ByteIterator> values); Status insert(String table, String key, Map<String, ByteIterator> values); Status delete(String table, String key); static final String VALUE_COLUMN_NAME_PREFIX; static final int ROW_KEY_COLUMN_POS; static final int DEFAULT_CACHE_CONTAINER_NUM; static final int FIELD_NUM; static final GSType SCHEMA_TYPE; }