@Test public void testRead() 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); final Status sPut = client.insert(DEFAULT_CACHE_NAME, key, StringByteIterator.getByteIteratorMap(input)); assertThat(sPut, is(Status.OK)); assertThat(cluster.cache(DEFAULT_CACHE_NAME).size(), is(1)); final Set<String> fld = new TreeSet<>(); fld.add("field0"); fld.add("field1"); fld.add("field3"); final HashMap<String, ByteIterator> result = new HashMap<>(); final Status sGet = client.read(DEFAULT_CACHE_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", "value2A")); }
@Override public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) { try { BinaryObject po = cache.get(key); if (po == null) { return Status.NOT_FOUND; } if (binType == null) { binType = po.type(); } for (String s : F.isEmpty(fields) ? binType.fieldNames() : fields) { BinaryField bfld = fieldsCache.get(s); if (bfld == null) { bfld = binType.field(s); fieldsCache.put(s, bfld); } String val = bfld.value(po); if (val != null) { result.put(s, new StringByteIterator(val)); } if (debug) { log.info("table:{" + table + "}, key:{" + key + "}" + ", fields:{" + fields + "}"); log.info("fields in po{" + binType.fieldNames() + "}"); log.info("result {" + result + "}"); } } return Status.OK; } catch (Exception e) { log.error(String.format("Error reading key: %s", key), e); return Status.ERROR; } }
IgniteClient extends IgniteAbstractClient { @Override public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) { try { BinaryObject po = cache.get(key); if (po == null) { return Status.NOT_FOUND; } if (binType == null) { binType = po.type(); } for (String s : F.isEmpty(fields) ? binType.fieldNames() : fields) { BinaryField bfld = fieldsCache.get(s); if (bfld == null) { bfld = binType.field(s); fieldsCache.put(s, bfld); } String val = bfld.value(po); if (val != null) { result.put(s, new StringByteIterator(val)); } if (debug) { log.info("table:{" + table + "}, key:{" + key + "}" + ", fields:{" + fields + "}"); log.info("fields in po{" + binType.fieldNames() + "}"); log.info("result {" + result + "}"); } } return Status.OK; } catch (Exception e) { log.error(String.format("Error reading key: %s", key), e); return Status.ERROR; } } }
IgniteClient extends IgniteAbstractClient { @Override public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) { try { BinaryObject po = cache.get(key); if (po == null) { return Status.NOT_FOUND; } if (binType == null) { binType = po.type(); } for (String s : F.isEmpty(fields) ? binType.fieldNames() : fields) { BinaryField bfld = fieldsCache.get(s); if (bfld == null) { bfld = binType.field(s); fieldsCache.put(s, bfld); } String val = bfld.value(po); if (val != null) { result.put(s, new StringByteIterator(val)); } if (debug) { log.info("table:{" + table + "}, key:{" + key + "}" + ", fields:{" + fields + "}"); log.info("fields in po{" + binType.fieldNames() + "}"); log.info("result {" + result + "}"); } } return Status.OK; } catch (Exception e) { log.error(String.format("Error reading key: %s", key), e); return Status.ERROR; } }  }
IgniteClient extends IgniteAbstractClient { @Override public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) { try { BinaryObject po = cache.get(key); if (po == null) { return Status.NOT_FOUND; } if (binType == null) { binType = po.type(); } for (String s : F.isEmpty(fields) ? binType.fieldNames() : fields) { BinaryField bfld = fieldsCache.get(s); if (bfld == null) { bfld = binType.field(s); fieldsCache.put(s, bfld); } String val = bfld.value(po); if (val != null) { result.put(s, new StringByteIterator(val)); } if (debug) { log.info("table:{" + table + "}, key:{" + key + "}" + ", fields:{" + fields + "}"); log.info("fields in po{" + binType.fieldNames() + "}"); log.info("result {" + result + "}"); } } return Status.OK; } catch (Exception e) { log.error(String.format("Error reading key: %s", key), 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); }
IgniteClient extends IgniteAbstractClient { @Override public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) { try { BinaryObject po = cache.get(key); if (po == null) { return Status.NOT_FOUND; } if (binType == null) { binType = po.type(); } for (String s : F.isEmpty(fields) ? binType.fieldNames() : fields) { BinaryField bfld = fieldsCache.get(s); if (bfld == null) { bfld = binType.field(s); fieldsCache.put(s, bfld); } String val = bfld.value(po); if (val != null) { result.put(s, new StringByteIterator(val)); } if (debug) { log.info("table:{" + table + "}, key:{" + key + "}" + ", fields:{" + fields + "}"); log.info("fields in po{" + binType.fieldNames() + "}"); log.info("result {" + result + "}"); } } return Status.OK; } catch (Exception e) { log.error(String.format("Error reading key: %s", key), 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);  }