コード例 #1
0
  public List<KeyValue> stream(Entity<?> entity) {
    List<KeyValue> streamed = new ArrayList<KeyValue>();

    byte[] keyBytes = Serialization.serialize(entity.getKey());
    byte[] qualifierBytes = new byte[0];

    long ts = System.currentTimeMillis();
    for (FieldKey<?> key : this.keys) {
      String name = key.getName();

      if (entity.isDirty(key)) {
        if (entity.getDirty(key) != null) {
          byte[] familyBytes = Serialization.serialize(key.getName());
          byte[] valueBytes =
              this.streamers.get(name).write(entity.get(key), Serialization.serialize(name), ts);
          KeyValue kv = new KeyValue(keyBytes, familyBytes, qualifierBytes, valueBytes);
          streamed.add(kv);
        } else {
          ErrorControl.fatal("Caught unsupported null dirty value for key: " + name);
        }
      }
    }

    return streamed;
  }
コード例 #2
0
  public Map<String, Object> parse(Result result) {
    Map<String, Object> parsed = new HashMap<String, Object>();

    byte[] qualifierBytes = new byte[0];
    for (Entry<byte[], NavigableMap<byte[], byte[]>> e : result.getNoVersionMap().entrySet()) {
      String name = Serialization.deserializeString(e.getKey());
      parsed.put(name, this.streamers.get(name).read(e.getValue().get(qualifierBytes)));
    }

    return parsed;
  }