asyncGet

异步读单行数据。

  1. public static interface GetListener extends GenericFutureListener<Future<byte[]>> {
  2. /**
  3. * This function will be called when listened asyncGet future is done.
  4. * @param future the listened future
  5. * @throws Exception
  6. *
  7. * Notice: User shouldn't do any operations that may block or time-consuming
  8. */
  9. @Override
  10. public void operationComplete(Future<byte[]> future) throws Exception;
  11. }
  12.  
  13. /**
  14. * Get value for a specific (hashKey, sortKey) pair, async version
  15. * @param hashKey used to decide which partition the key may exist
  16. * if null or empty, means hash key is "".
  17. * @param sortKey all keys under the same hashKey will be sorted by sortKey
  18. * if null or empty, means sort key is "".
  19. * @param timeout how long will the operation timeout in milliseconds.
  20. * if timeout > 0, it is a timeout value for current op,
  21. * else the timeout value in the configuration file will be used.
  22. *
  23. * @return the future for current op
  24. *
  25. * Future return:
  26. * On success: the got value
  27. * On failure: a throwable, which is an instance of PException
  28. *
  29. * Thread safety:
  30. * The api is thread safe.
  31. * All the listeners for the same table are guaranteed to be dispatched in the same thread, so all the
  32. * listeners for the same future are guaranteed to be executed as the same order as the listeners added.
  33. * But listeners for different tables are not guaranteed to be dispatched in the same thread.
  34. */
  35. public Future<byte[]> asyncGet(byte[] hashKey, byte[] sortKey, int timeout/*ms*/);

注:

  • 参数:需传入HashKey、SortKey、timeout。
    • timeout单位为毫秒,如果<=0,表示使用配置文件中的默认超时。
  • 返回值:Future