asyncExist
异步检查数据是否存在。
- public static interface ExistListener extends GenericFutureListener<Future<Boolean>> {
- /**
- * This function will be called when listened asyncExist 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<Boolean> future) throws Exception;
- }
- /**
- * Check value existence for a specific (hashKey, sortKey) pair of current table, async version
- * @param hashKey used to decide which partition the key may exist
- * if null or length == 0, means hash key is "".
- * @param sortKey all keys under the same hashKey will be sorted by sortKey
- * if null or length == 0, means sort key is "".
- * @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 A future for current op.
- *
- * Future return:
- * On success: true if exist, false if not exist
- * On failure: a throwable, which is an instance of PException
- *
- * Thread safety:
- * The api is thread safe.
- * 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<Boolean> asyncExist(byte[] hashKey, byte[] sortKey, int timeout/*ms*/);
注:
- 参数:需传入HashKey、SortKey、timeout。
- timeout单位为毫秒,如果<=0,表示使用配置文件中的默认超时。
- 返回值:Future
。 - 返回结果是个布尔值。如果存在返回true,否则返回false。