asyncMultiGetSortKeys

异步获取某个HashKey下SortKey列表。

  1. public static class MultiGetSortKeysResult {
  2. /**
  3. * return value for multiGetSortkeys
  4. * @param allFetched true if all data on the server are fetched; false if only partial data are fetched.
  5. * @param keys the got keys.
  6. * The output keys are in order.
  7. */
  8. public boolean allFetched;
  9. public List<byte[]> keys;
  10. };
  11.  
  12. public static interface MultiGetSortKeysListener extends GenericFutureListener<Future<MultiGetSortKeysResult>> {
  13. /**
  14. * This function will be called when listened asyncMultiGetSortKeys future is done.
  15. * @param future the listened future
  16. * @throws Exception
  17. *
  18. * Notice: User shouldn't do any operations that may block or time-consuming
  19. */
  20. @Override
  21. public void operationComplete(Future<MultiGetSortKeysResult> future) throws Exception;
  22. }
  23.  
  24. /**
  25. * get all the sortKeys for the same hashKey
  26. * @param hashKey used to decide which partition the key may exist
  27. * should not be null or empty.
  28. * @param maxFetchCount max count of kv pairs to be fetched
  29. * maxFetchCount <= 0 means no limit. default value is 100
  30. * @param maxFetchSize max size of kv pairs to be fetched.
  31. * maxFetchSize <= 0 means no limit. default value is 1000000.
  32. * @param timeout how long will the operation timeout in milliseconds.
  33. * if timeout > 0, it is a timeout value for current op,
  34. * else the timeout value in the configuration file will be used.
  35. *
  36. * @return the future for current op
  37. *
  38. * Future return:
  39. * On success: An object of type MultiGetSortKeysResult
  40. * On failure: a throwable, which is an instance of PException
  41. *
  42. * Thread safety:
  43. * All the listeners for the same table are guaranteed to be dispatched in the same thread, so all the
  44. * listeners for the same future are guaranteed to be executed as the same order as the listeners added.
  45. * But listeners for different tables are not guaranteed to be dispatched in the same thread.
  46. */
  47. public Future<MultiGetSortKeysResult> asyncMultiGetSortKeys(byte[] hashKey, int maxFetchCount, int maxFetchSize, int timeout/*ms*/);
  48. public Future<MultiGetSortKeysResult> asyncMultiGetSortKeys(byte[] hashKey, int timeout/*ms*/);

注:

  • 提供了两个版本的接口,其中第一个接口可以指定maxFetchCount和maxFetchSize。
  • 参数:需传入HashKey、timeout;选择性传入maxFetchCount、maxFetchSize。
    • timeout单位为毫秒,如果<=0,表示使用配置文件中的默认超时。
    • maxFetchCount和maxFetchSize用于限制读取的数据量,maxFetchCount表示最多读取的数据条数,maxFetchSize表示最多读取的数据字节数,两者任一达到限制就停止读取。
  • 返回值:Future
    • allFetched:如果用户指定了maxFetchCount或者maxFetchSize,单次查询可能只获取到部分结果。如果所有满足条件的数据都已经获取到,则设置为true;否则设置为false。