asyncMultiGetSortKeys
异步获取某个HashKey下SortKey列表。
- public static class MultiGetSortKeysResult {
- /**
- * return value for multiGetSortkeys
- * @param allFetched true if all data on the server are fetched; false if only partial data are fetched.
- * @param keys the got keys.
- * The output keys are in order.
- */
- public boolean allFetched;
- public List<byte[]> keys;
- };
- public static interface MultiGetSortKeysListener extends GenericFutureListener<Future<MultiGetSortKeysResult>> {
- /**
- * This function will be called when listened asyncMultiGetSortKeys future is done.
- * @param future the listened future
- * @throws Exception
- *
- * Notice: User shouldn't do any operations that may block or time-consuming
- */
- @Override
- public void operationComplete(Future<MultiGetSortKeysResult> future) throws Exception;
- }
- /**
- * get all the sortKeys for the same hashKey
- * @param hashKey used to decide which partition the key may exist
- * should not be null or empty.
- * @param maxFetchCount max count of kv pairs to be fetched
- * maxFetchCount <= 0 means no limit. default value is 100
- * @param maxFetchSize max size of kv pairs to be fetched.
- * maxFetchSize <= 0 means no limit. default value is 1000000.
- * @param timeout how long will the operation timeout in milliseconds.
- * if timeout > 0, it is a timeout value for current op,
- * else the timeout value in the configuration file will be used.
- *
- * @return the future for current op
- *
- * Future return:
- * On success: An object of type MultiGetSortKeysResult
- * On failure: a throwable, which is an instance of PException
- *
- * Thread safety:
- * All the listeners for the same table are guaranteed to be dispatched in the same thread, so all the
- * listeners for the same future are guaranteed to be executed as the same order as the listeners added.
- * But listeners for different tables are not guaranteed to be dispatched in the same thread.
- */
- public Future<MultiGetSortKeysResult> asyncMultiGetSortKeys(byte[] hashKey, int maxFetchCount, int maxFetchSize, int timeout/*ms*/);
- 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。