@Test public void testInsert() { HashMap<String, ByteIterator> values = new HashMap<String, ByteIterator>(); HashMap<String, ByteIterator> result = new HashMap<String, ByteIterator>(); for (int i = 0; i < FIELD_COUNT; i++) { values.put("field" + i, new StringByteIterator("value" + i)); } Status insertStatus = myClient.insert(TEST_TABLE, DEFAULT_ROW_KEY, values); assertEquals(insertStatus, Status.OK); myClient.read(TEST_TABLE, DEFAULT_ROW_KEY, null, result); assertEquals(result.size(), FIELD_COUNT); for (int i = 0; i < FIELD_COUNT; i++) { ByteIterator iter = result.get("field" + i); byte[] byteArray1 = iter.toArray(); String value = new String(byteArray1); assertEquals(value, "value" + i); } }
public Status insert(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 insert()"); } Row row = container.createRow(); row.setValue(ROW_KEY_COLUMN_POS, rowKey); for (int i = 1; i < containerInfo.getColumnCount(); i++) { ByteIterator byteIterator = values.get(containerInfo.getColumnInfo(i).getName()); Object value = makeValue(byteIterator); row.setValue(i, value); } container.put(row); } catch (GSException e) { LOGGER.severe("Exception: " + e.getMessage()); return Status.ERROR; } return Status.OK; }
GridDBClient extends com.yahoo.ycsb.DB { public Status insert(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 insert()"); } Row row = container.createRow(); row.setValue(ROW_KEY_COLUMN_POS, rowKey); for (int i = 1; i < containerInfo.getColumnCount(); i++) { ByteIterator byteIterator = values.get(containerInfo.getColumnInfo(i).getName()); Object value = makeValue(byteIterator); row.setValue(i, value); } container.put(row); } catch (GSException e) { LOGGER.severe("Exception: " + e.getMessage()); return Status.ERROR; } return Status.OK; } }
GridDBClient extends com.yahoo.ycsb.DB { public Status insert(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 insert()"); } Row row = container.createRow(); row.setValue(ROW_KEY_COLUMN_POS, rowKey); for (int i = 1; i < containerInfo.getColumnCount(); i++) { ByteIterator byteIterator = values.get(containerInfo.getColumnInfo(i).getName()); Object value = makeValue(byteIterator); row.setValue(i, value); } container.put(row); } catch (GSException e) { LOGGER.severe("Exception: " + e.getMessage()); return Status.ERROR; } return Status.OK; }  }
GridDBClient extends com.yahoo.ycsb.DB { public Status insert(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 insert()"); } Row row = container.createRow(); row.setValue(ROW_KEY_COLUMN_POS, rowKey); for (int i = 1; i < containerInfo.getColumnCount(); i++) { ByteIterator byteIterator = values.get(containerInfo.getColumnInfo(i).getName()); Object value = makeValue(byteIterator); row.setValue(i, value); } container.put(row); } catch (GSException e) { LOGGER.severe("Exception: " + e.getMessage()); return Status.ERROR; } return Status.OK; }  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 com.yahoo.ycsb.DB { public Status insert(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 insert()"); } Row row = container.createRow(); row.setValue(ROW_KEY_COLUMN_POS, rowKey); for (int i = 1; i < containerInfo.getColumnCount(); i++) { ByteIterator byteIterator = values.get(containerInfo.getColumnInfo(i).getName()); Object value = makeValue(byteIterator); row.setValue(i, value); } container.put(row); } catch (GSException e) { LOGGER.severe("Exception: " + e.getMessage()); return Status.ERROR; } return Status.OK; }  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; }