@Test public void testUpdate() { int i; HashMap<String, ByteIterator> newValues = new HashMap<>(10); for (i = 1; i <= 10; i++) { newValues.put(FIELD_PREFIX + i, new StringByteIterator("newvalue" + i)); } Status result = instance.update(MOCK_TABLE, MOCK_KEY1, newValues); assertEquals(Status.OK, result); HashMap<String, ByteIterator> resultParam = new HashMap<>(10); instance.read(MOCK_TABLE, MOCK_KEY1, MOCK_DATA.keySet(), resultParam); for (i = 1; i <= 10; i++) { assertEquals("newvalue" + i, resultParam.get(FIELD_PREFIX + i).toString()); } }
@Override public Status update(String table, String key, Map<String, ByteIterator> values) { try { final GetResponse response = client.prepareGet(indexKey, table, key).execute().actionGet(); if (response.isExists()) { for (Entry<String, String> entry : StringByteIterator.getStringMap(values).entrySet()) { response.getSource().put(entry.getKey(), entry.getValue()); } client.prepareIndex(indexKey, table, key).setSource(response.getSource()).execute().actionGet(); return Status.OK; } else { return Status.NOT_FOUND; } } catch (Exception e) { e.printStackTrace(); return Status.ERROR; } }
ElasticsearchClient extends DB { @Override public Status update(String table, String key, Map<String, ByteIterator> values) { try { final GetResponse response = client.prepareGet(indexKey, table, key).execute().actionGet(); if (response.isExists()) { for (Entry<String, String> entry : StringByteIterator.getStringMap(values).entrySet()) { response.getSource().put(entry.getKey(), entry.getValue()); } client.prepareIndex(indexKey, table, key).setSource(response.getSource()).execute().actionGet(); return Status.OK; } else { return Status.NOT_FOUND; } } catch (Exception e) { e.printStackTrace(); return Status.ERROR; } } }
ElasticsearchClient extends DB { @Override public Status update(String table, String key, Map<String, ByteIterator> values) { try { final GetResponse response = client.prepareGet(indexKey, table, key).execute().actionGet(); if (response.isExists()) { for (Entry<String, String> entry : StringByteIterator.getStringMap(values).entrySet()) { response.getSource().put(entry.getKey(), entry.getValue()); } client.prepareIndex(indexKey, table, key).setSource(response.getSource()).execute().actionGet(); return Status.OK; } else { return Status.NOT_FOUND; } } catch (Exception e) { e.printStackTrace(); return Status.ERROR; } }  }
ElasticsearchClient extends DB { @Override public Status update(String table, String key, Map<String, ByteIterator> values) { try { final GetResponse response = client.prepareGet(indexKey, table, key).execute().actionGet(); if (response.isExists()) { for (Entry<String, String> entry : StringByteIterator.getStringMap(values).entrySet()) { response.getSource().put(entry.getKey(), entry.getValue()); } client.prepareIndex(indexKey, table, key).setSource(response.getSource()).execute().actionGet(); return Status.OK; } else { return Status.NOT_FOUND; } } catch (Exception e) { e.printStackTrace(); return Status.ERROR; } }  @Override void init(); @Override void cleanup(); @Override Status insert(String table, String key, Map<String, ByteIterator> values); @Override Status delete(String table, String key); @Override Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result); @Override Status update(String table, String key, Map<String, ByteIterator> values); @Override Status scan(
          String table,
          String startkey,
          int recordcount,
          Set<String> fields,
          Vector<HashMap<String, ByteIterator>> result); }
ElasticsearchClient extends DB { @Override public Status update(String table, String key, Map<String, ByteIterator> values) { try { final GetResponse response = client.prepareGet(indexKey, table, key).execute().actionGet(); if (response.isExists()) { for (Entry<String, String> entry : StringByteIterator.getStringMap(values).entrySet()) { response.getSource().put(entry.getKey(), entry.getValue()); } client.prepareIndex(indexKey, table, key).setSource(response.getSource()).execute().actionGet(); return Status.OK; } else { return Status.NOT_FOUND; } } catch (Exception e) { e.printStackTrace(); return Status.ERROR; } }  @Override void init(); @Override void cleanup(); @Override Status insert(String table, String key, Map<String, ByteIterator> values); @Override Status delete(String table, String key); @Override Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result); @Override Status update(String table, String key, Map<String, ByteIterator> values); @Override Status scan(
          String table,
          String startkey,
          int recordcount,
          Set<String> fields,
          Vector<HashMap<String, ByteIterator>> result);  }