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:21:27 UTC
[couchdb-erlfdb] branch cancel-fold-info-futures created (now
2f032f3)
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a change to branch cancel-fold-info-futures
in repository https://gitbox.apache.org/repos/asf/couchdb-erlfdb.git.
at 2f032f3 Cancel fold range futures
This branch includes the following new commits:
new 2f032f3 Cancel fold range futures
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[couchdb-erlfdb] 01/01: Cancel fold range futures
Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch cancel-fold-info-futures
in repository https://gitbox.apache.org/repos/asf/couchdb-erlfdb.git
commit 2f032f350ad56ee25180acd82fe0ac38c7806f2b
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 | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/erlfdb.erl b/src/erlfdb.erl
index b50f843..d7858f7 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,6 +191,9 @@ 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);
@@ -197,6 +201,10 @@ 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,