batchMultiGet

对multiGet函数的批量封装。该函数并发地向server发送异步请求,并等待结果。如果有任意一个请求失败,就提前终止并抛出异常。如果抛出了异常,则values中的结果是未定义的。

  1. /**
  2. * Batch get multiple values under the same hash key.
  3. * Will terminate immediately if any error occurs.
  4. * @param tableName table name
  5. * @param keys List{hashKey,List{sortKey}}; if List{sortKey} is null or empty, means fetch all
  6. * sortKeys under the hashKey.
  7. * @param values output values; should be created by caller; if succeed, the size of values will
  8. * be same with keys; the data for keys[i] is stored in values[i].
  9. * @throws PException throws exception if any error occurs.
  10. *
  11. * Notice: the method is not atomic, that means, maybe some keys succeed but some keys failed.
  12. */
  13. public void batchMultiGet(String tableName, List<Pair<byte[], List<byte[]>>> keys, List<HashKeyData> values) throws PException;

注:

  • 参数:
    • 传入参数:TableName、Keys。Keys是一个Pair列表,Pair的左值是hashKey,右值是sortKey列表;如果Pair的右值为null或者空列表,则获取该hashKey下的所有数据。
    • 传出参数:Values。该List需由调用者创建;如果读取成功,Values[i]中存放Keys[i]对应的结果。
  • 返回值:无。
  • 异常:如果出现异常,譬如网络错误、超时错误、服务端错误等,会抛出 PException。
  • 注意:该方法不是原子的,有可能出现部分成功部分失败的情况,只要任意一个失败都会抛出异常。