@Test public void testUpdate() throws Exception { cluster.cache(DEFAULT_CACHE_NAME).clear(); final String key = "key"; final Map<String, String> input = new HashMap<>(); input.put("field0", "value1"); input.put("field1", "value2A"); input.put("field3", null); client.insert(TABLE_NAME, key, StringByteIterator.getByteIteratorMap(input)); input.put("field1", "value2B"); input.put("field4", "value4A"); final Status sUpd = client.update(TABLE_NAME, key, StringByteIterator.getByteIteratorMap(input)); assertThat(sUpd, is(Status.OK)); final Set<String> fld = new TreeSet<>(); fld.add("field0"); fld.add("field1"); fld.add("field3"); fld.add("field4"); final HashMap<String, ByteIterator> result = new HashMap<>(); final Status sGet = client.read(TABLE_NAME, key, fld, result); assertThat(sGet, is(Status.OK)); final HashMap<String, String> strResult = new HashMap<String, String>(); for (final Map.Entry<String, ByteIterator> e : result.entrySet()) { if (e.getValue() != null) { strResult.put(e.getKey(), e.getValue().toString()); } } assertThat(strResult, hasEntry("field0", "value1")); assertThat(strResult, hasEntry("field1", "value2B")); assertThat(strResult, hasEntry("field4", "value4A")); }
@Override public Status update(String table, String key, Map<String, ByteIterator> values) { while (true) { try { UpdateData updData = new UpdateData(key, values); StringBuilder sb = new StringBuilder("UPDATE ").append(table).append(" SET "); for (int i = 0; i < updData.getFields().length; ++i) { sb.append(updData.getFields()[i]).append("=?"); if (i < updData.getFields().length - 1) { sb.append(", "); } } sb.append(" WHERE ").append(PRIMARY_KEY).append("=?"); SqlFieldsQuery qry = new SqlFieldsQuery(sb.toString()); qry.setArgs(updData.getArgs()); cache.query(qry).getAll(); return Status.OK; } catch (CacheException e) { if (!e.getMessage().contains("Failed to update some keys because they had been modified concurrently")) { log.error(String.format("Error in processing update table: %s", table), e); return Status.ERROR; } } catch (Exception e) { log.error(String.format("Error in processing update table: %s", table), e); return Status.ERROR; } } }
IgniteSqlClient extends IgniteAbstractClient { @Override public Status update(String table, String key, Map<String, ByteIterator> values) { while (true) { try { UpdateData updData = new UpdateData(key, values); StringBuilder sb = new StringBuilder("UPDATE ").append(table).append(" SET "); for (int i = 0; i < updData.getFields().length; ++i) { sb.append(updData.getFields()[i]).append("=?"); if (i < updData.getFields().length - 1) { sb.append(", "); } } sb.append(" WHERE ").append(PRIMARY_KEY).append("=?"); SqlFieldsQuery qry = new SqlFieldsQuery(sb.toString()); qry.setArgs(updData.getArgs()); cache.query(qry).getAll(); return Status.OK; } catch (CacheException e) { if (!e.getMessage().contains("Failed to update some keys because they had been modified concurrently")) { log.error(String.format("Error in processing update table: %s", table), e); return Status.ERROR; } } catch (Exception e) { log.error(String.format("Error in processing update table: %s", table), e); return Status.ERROR; } } } }
IgniteSqlClient extends IgniteAbstractClient { @Override public Status update(String table, String key, Map<String, ByteIterator> values) { while (true) { try { UpdateData updData = new UpdateData(key, values); StringBuilder sb = new StringBuilder("UPDATE ").append(table).append(" SET "); for (int i = 0; i < updData.getFields().length; ++i) { sb.append(updData.getFields()[i]).append("=?"); if (i < updData.getFields().length - 1) { sb.append(", "); } } sb.append(" WHERE ").append(PRIMARY_KEY).append("=?"); SqlFieldsQuery qry = new SqlFieldsQuery(sb.toString()); qry.setArgs(updData.getArgs()); cache.query(qry).getAll(); return Status.OK; } catch (CacheException e) { if (!e.getMessage().contains("Failed to update some keys because they had been modified concurrently")) { log.error(String.format("Error in processing update table: %s", table), e); return Status.ERROR; } } catch (Exception e) { log.error(String.format("Error in processing update table: %s", table), e); return Status.ERROR; } } }  }
IgniteSqlClient extends IgniteAbstractClient { @Override public Status update(String table, String key, Map<String, ByteIterator> values) { while (true) { try { UpdateData updData = new UpdateData(key, values); StringBuilder sb = new StringBuilder("UPDATE ").append(table).append(" SET "); for (int i = 0; i < updData.getFields().length; ++i) { sb.append(updData.getFields()[i]).append("=?"); if (i < updData.getFields().length - 1) { sb.append(", "); } } sb.append(" WHERE ").append(PRIMARY_KEY).append("=?"); SqlFieldsQuery qry = new SqlFieldsQuery(sb.toString()); qry.setArgs(updData.getArgs()); cache.query(qry).getAll(); return Status.OK; } catch (CacheException e) { if (!e.getMessage().contains("Failed to update some keys because they had been modified concurrently")) { log.error(String.format("Error in processing update table: %s", table), e); return Status.ERROR; } } catch (Exception e) { log.error(String.format("Error in processing update table: %s", table), e); return Status.ERROR; } } }  @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 insert(String table, String key, Map<String, ByteIterator> values); @Override Status delete(String table, String key); }
IgniteSqlClient extends IgniteAbstractClient { @Override public Status update(String table, String key, Map<String, ByteIterator> values) { while (true) { try { UpdateData updData = new UpdateData(key, values); StringBuilder sb = new StringBuilder("UPDATE ").append(table).append(" SET "); for (int i = 0; i < updData.getFields().length; ++i) { sb.append(updData.getFields()[i]).append("=?"); if (i < updData.getFields().length - 1) { sb.append(", "); } } sb.append(" WHERE ").append(PRIMARY_KEY).append("=?"); SqlFieldsQuery qry = new SqlFieldsQuery(sb.toString()); qry.setArgs(updData.getArgs()); cache.query(qry).getAll(); return Status.OK; } catch (CacheException e) { if (!e.getMessage().contains("Failed to update some keys because they had been modified concurrently")) { log.error(String.format("Error in processing update table: %s", table), e); return Status.ERROR; } } catch (Exception e) { log.error(String.format("Error in processing update table: %s", table), e); return Status.ERROR; } } }  @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 insert(String table, String key, Map<String, ByteIterator> values); @Override Status delete(String table, String key);  }