You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2017/03/01 16:38:09 UTC

[11/50] fabric commit: updated refs/heads/2971-count-distinct to 5d18415

Implement clustered compaction functions

COUCHDB-3099


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/commit/cb85279e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/tree/cb85279e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/diff/cb85279e

Branch: refs/heads/2971-count-distinct
Commit: cb85279e00f2e96b65e9605a82653558accc8e03
Parents: 48d32e4
Author: Robert Newson <rn...@apache.org>
Authored: Thu Aug 11 10:49:26 2016 +0100
Committer: Robert Newson <rn...@apache.org>
Committed: Thu Aug 11 10:49:50 2016 +0100

----------------------------------------------------------------------
 src/fabric.erl     | 13 ++++++++++++-
 src/fabric_rpc.erl | 10 ++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/cb85279e/src/fabric.erl
----------------------------------------------------------------------
diff --git a/src/fabric.erl b/src/fabric.erl
index fe663be..f2a1ad0 100644
--- a/src/fabric.erl
+++ b/src/fabric.erl
@@ -20,7 +20,8 @@
 -export([all_dbs/0, all_dbs/1, create_db/1, create_db/2, delete_db/1,
     delete_db/2, get_db_info/1, get_doc_count/1, set_revs_limit/3,
     set_security/2, set_security/3, get_revs_limit/1, get_security/1,
-    get_security/2, get_all_security/1, get_all_security/2]).
+    get_security/2, get_all_security/1, get_all_security/2,
+    compact/1, compact/2]).
 
 % Documents
 -export([open_doc/3, open_revs/4, get_doc_info/3, get_full_doc_info/3,
@@ -161,6 +162,16 @@ get_all_security(DbName) ->
 get_all_security(DbName, Options) ->
     fabric_db_meta:get_all_security(dbname(DbName), opts(Options)).
 
+compact(DbName) ->
+    [rexi:cast(Node, {fabric_rpc, compact, [Name]}) ||
+        #shard{node=Node, name=Name} <- mem3:shards(dbname(DbName))],
+    ok.
+
+compact(DbName, DesignName) ->
+    [rexi:cast(Node, {fabric_rpc, compact, [Name, DesignName]}) ||
+        #shard{node=Node, name=Name} <- mem3:shards(dbname(DbName))],
+    ok.
+
 % doc operations
 
 %% @doc retrieve the doc with a given id

http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/cb85279e/src/fabric_rpc.erl
----------------------------------------------------------------------
diff --git a/src/fabric_rpc.erl b/src/fabric_rpc.erl
index cc242b9..b7f4fec 100644
--- a/src/fabric_rpc.erl
+++ b/src/fabric_rpc.erl
@@ -19,6 +19,7 @@
 -export([create_db/1, delete_db/1, reset_validation_funs/1, set_security/3,
     set_revs_limit/3, create_shard_db_doc/2, delete_shard_db_doc/2]).
 -export([get_all_security/2, open_shard/2]).
+-export([compact/1, compact/2]).
 
 -export([get_db_info/2, get_doc_count/2, get_update_seq/2,
          changes/4, map_view/5, reduce_view/5, group_info/3]).
@@ -246,6 +247,15 @@ open_shard(Name, Opts) ->
     set_io_priority(Name, Opts),
     rexi:reply(couch_db:open(Name, Opts)).
 
+compact(DbName) ->
+    with_db(DbName, [], {couch_db, start_compact, []}).
+
+compact(ShardName, DesignName) ->
+    {ok, Pid} = couch_index_server:get_index(
+        couch_mrview_index, ShardName, <<"_design/", DesignName/binary>>),
+    Ref = erlang:make_ref(),
+    Pid ! {'$gen_call', {self(), Ref}, compact}.
+
 %%
 %% internal
 %%