You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2020/05/19 19:28:06 UTC
[couchdb-erlfdb] branch master updated: Cancel fold range futures
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb-erlfdb.git
The following commit(s) were added to refs/heads/master by this push:
new 84db41c Cancel fold range futures
84db41c is described below
commit 84db41c0d88cb3e6fac8561ee3010177cffdebc0
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Tue May 19 15:13:49 2020 -0400
Cancel fold range futures
Previously we had functions to create and wait on fold range futures, but no way
to cancel them. This commit add clauses to `cancel/1,2` to do just that.
Also, once the `?IS_FOLD_FUTURE` macro is defined, use it in a few function
heads instead of the previously used `{fold_info, _, _}` tuple.
---
src/erlfdb.erl | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/erlfdb.erl b/src/erlfdb.erl
index b50f843..5bb61e9 100644
--- a/src/erlfdb.erl
+++ b/src/erlfdb.erl
@@ -124,6 +124,7 @@
-define(IS_FUTURE, {erlfdb_future, _, _}).
+-define(IS_FOLD_FUTURE, {fold_info, _, _}).
-define(IS_DB, {erlfdb_database, _}).
-define(IS_TX, {erlfdb_transaction, _}).
-define(IS_SS, {erlfdb_snapshot, _}).
@@ -190,13 +191,20 @@ reset(?IS_TX = Tx) ->
ok = erlfdb_nif:transaction_reset(Tx).
+cancel(?IS_FOLD_FUTURE = FoldInfo) ->
+ cancel(FoldInfo, []);
+
cancel(?IS_FUTURE = Future) ->
- ok = erlfdb_nif:future_cancel(Future);
+ cancel(Future, []);
cancel(?IS_TX = Tx) ->
ok = erlfdb_nif:transaction_cancel(Tx).
+cancel(?IS_FOLD_FUTURE = FoldInfo, Options) ->
+ {fold_info, _St, Future} = FoldInfo,
+ cancel(Future, Options);
+
cancel(?IS_FUTURE = Future, Options) ->
ok = erlfdb_nif:future_cancel(Future),
case erlfdb_util:get(Options, flush, false) of
@@ -382,7 +390,7 @@ fold_range_future(?IS_SS = SS, StartKey, EndKey, Options) ->
fold_range_future(?GET_TX(SS), StartKey, EndKey, SSOptions).
-fold_range_wait(?IS_TX = Tx, {fold_info, _, _} = FI, Fun, Acc) ->
+fold_range_wait(?IS_TX = Tx, ?IS_FOLD_FUTURE = FI, Fun, Acc) ->
fold_range_int(Tx, FI, fun(Rows, InnerAcc) ->
lists:foldl(Fun, InnerAcc, Rows)
end, Acc).
@@ -674,7 +682,8 @@ fold_range_int(Tx, #fold_st{} = St, Fun, Acc) ->
RangeFuture = fold_range_future_int(Tx, St),
fold_range_int(Tx, RangeFuture, Fun, Acc);
-fold_range_int(Tx, {fold_info, St, Future}, Fun, Acc) ->
+fold_range_int(Tx, ?IS_FOLD_FUTURE = FI, Fun, Acc) ->
+ {fold_info, St, Future} = FI,
#fold_st{
start_key = StartKey,
end_key = EndKey,