コード例 #1
0
    @Override
    public boolean next(Text key, MapWritable value) throws IOException {
      if (result == null) {
        result = client.query(query);
      }

      boolean hasNext = result.hasNext();

      if (!hasNext) {
        return false;
      }

      Map<String, Object> next = result.next();
      // we save the key as is since under the old API, we don't have to create a new Text() object
      currentKey = next.get("_id").toString();
      currentValue = (MapWritable) WritableUtils.toWritable(next.get("_source"));

      if (key != null) {
        key.set(currentKey);
      }
      if (value != null) {
        value.clear();
        value.putAll(currentValue);
      }

      // keep on counting
      read++;
      return true;
    }
コード例 #2
0
 @Override
 public void close() throws IOException {
   client.close();
 }