You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2018/07/10 10:50:47 UTC

[couchdb] branch user-partitioned-dbs-wip updated (28e0dfa -> 03f2cc3)

This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a change to branch user-partitioned-dbs-wip
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


    from 28e0dfa  WIP plumbing
     new 03956d7  ?partition=foo
     new 03f2cc3  unpartition key in view responses

The 2 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.


Summary of changes:
 src/couch_mrview/include/couch_mrview.hrl  |  2 +-
 src/couch_mrview/src/couch_mrview_http.erl |  4 ++--
 src/couch_mrview/src/couch_mrview_util.erl | 32 +++++++++++++++---------------
 src/fabric/include/fabric.hrl              |  3 ++-
 src/fabric/src/fabric_view.erl             | 12 +++++++++--
 src/fabric/src/fabric_view_map.erl         |  3 ++-
 src/fabric/src/fabric_view_reduce.erl      |  3 ++-
 7 files changed, 35 insertions(+), 24 deletions(-)


[couchdb] 02/02: unpartition key in view responses

Posted by rn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a commit to branch user-partitioned-dbs-wip
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 03f2cc3382f1f819b2a615c9123cb126ee618713
Author: Robert Newson <rn...@apache.org>
AuthorDate: Tue Jul 10 11:50:37 2018 +0100

    unpartition key in view responses
---
 src/fabric/include/fabric.hrl         |  3 ++-
 src/fabric/src/fabric_view.erl        | 12 ++++++++++--
 src/fabric/src/fabric_view_map.erl    |  3 ++-
 src/fabric/src/fabric_view_reduce.erl |  3 ++-
 4 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/fabric/include/fabric.hrl b/src/fabric/include/fabric.hrl
index be1d639..8ceab22 100644
--- a/src/fabric/include/fabric.hrl
+++ b/src/fabric/include/fabric.hrl
@@ -31,7 +31,8 @@
     lang,
     sorted,
     user_acc,
-    update_seq
+    update_seq,
+    partitioned=false
 }).
 
 -record(stream_acc, {
diff --git a/src/fabric/src/fabric_view.erl b/src/fabric/src/fabric_view.erl
index 69f4290..bf4d64e 100644
--- a/src/fabric/src/fabric_view.erl
+++ b/src/fabric/src/fabric_view.erl
@@ -128,8 +128,11 @@ maybe_send_row(State) ->
         try get_next_row(State) of
         {_, NewState} when Skip > 0 ->
             maybe_send_row(NewState#collector{skip=Skip-1});
-        {Row, NewState} ->
-            case Callback(transform_row(possibly_embed_doc(NewState,Row)), AccIn) of
+        {Row0, NewState} ->
+            Row1 = possibly_embed_doc(NewState, Row0),
+            Row2 = unpartition_row(NewState, Row1),
+            Row3 = transform_row(Row2),
+            case Callback(Row3, AccIn) of
             {stop, Acc} ->
                 {stop, NewState#collector{user_acc=Acc, limit=Limit-1}};
             {ok, Acc} ->
@@ -272,6 +275,11 @@ transform_row(#view_row{key=Key, id=_Id, value=_Value, doc={error,Reason}}) ->
 transform_row(#view_row{key=Key, id=Id, value=Value, doc=Doc}) ->
     {row, [{id,Id}, {key,Key}, {value,Value}, {doc,Doc}]}.
 
+unpartition_row(#collector{partitioned=true}, #view_row{key=[_Partition, Key]} = Row) ->
+    Row#view_row{key = Key};
+unpartition_row(#collector{partitioned=false}, Row) ->
+    Row.
+
 compare(_, _, A, A) -> true;
 compare(fwd, <<"raw">>, A, B) -> A < B;
 compare(rev, <<"raw">>, A, B) -> B < A;
diff --git a/src/fabric/src/fabric_view_map.erl b/src/fabric/src/fabric_view_map.erl
index b6a3d6f..75b71f1 100644
--- a/src/fabric/src/fabric_view_map.erl
+++ b/src/fabric/src/fabric_view_map.erl
@@ -76,7 +76,8 @@ go(DbName, Workers, {map, View, _}, Args, Callback, Acc0) ->
         sorted = Args#mrargs.sorted,
         collation = Collation,
         user_acc = Acc0,
-        update_seq = case UpdateSeq of true -> []; false -> nil end
+        update_seq = case UpdateSeq of true -> []; false -> nil end,
+        partitioned = Args#mrargs.partitioned
     },
     case rexi_utils:recv(Workers, #shard.ref, fun handle_message/3,
         State, infinity, 1000 * 60 * 60) of
diff --git a/src/fabric/src/fabric_view_reduce.erl b/src/fabric/src/fabric_view_reduce.erl
index a74be10..c58d3aa 100644
--- a/src/fabric/src/fabric_view_reduce.erl
+++ b/src/fabric/src/fabric_view_reduce.erl
@@ -82,7 +82,8 @@ go2(DbName, Workers, {red, {_, Lang, View}, _}=VInfo, Args, Callback, Acc0) ->
         collation = couch_util:get_value(<<"collation">>, View#mrview.options),
         rows = dict:new(),
         user_acc = Acc0,
-        update_seq = case UpdateSeq of true -> []; false -> nil end
+        update_seq = case UpdateSeq of true -> []; false -> nil end,
+        partitioned = Args#mrargs.partitioned
     },
     try rexi_utils:recv(Workers, #shard.ref, fun handle_message/3,
         State, infinity, 1000 * 60 * 60) of


[couchdb] 01/02: ?partition=foo

Posted by rn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a commit to branch user-partitioned-dbs-wip
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 03956d789bc641a4c59dccd9bd36cd8b37f02d89
Author: Robert Newson <rn...@apache.org>
AuthorDate: Mon Jul 9 23:16:45 2018 +0100

    ?partition=foo
---
 src/couch_mrview/include/couch_mrview.hrl  |  2 +-
 src/couch_mrview/src/couch_mrview_http.erl |  4 ++--
 src/couch_mrview/src/couch_mrview_util.erl | 32 +++++++++++++++---------------
 3 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/couch_mrview/include/couch_mrview.hrl b/src/couch_mrview/include/couch_mrview.hrl
index 09faf51..094b1d5 100644
--- a/src/couch_mrview/include/couch_mrview.hrl
+++ b/src/couch_mrview/include/couch_mrview.hrl
@@ -89,7 +89,7 @@
     callback,
     sorted = true,
     partitioned,
-    partition_key,
+    partition,
     extra = []
 }).
 
diff --git a/src/couch_mrview/src/couch_mrview_http.erl b/src/couch_mrview/src/couch_mrview_http.erl
index 5ff7285..fac1d42 100644
--- a/src/couch_mrview/src/couch_mrview_http.erl
+++ b/src/couch_mrview/src/couch_mrview_http.erl
@@ -582,8 +582,8 @@ parse_param(Key, Val, Args, IsDecoded) ->
             Args#mrargs{callback=couch_util:to_binary(Val)};
         "sorted" ->
             Args#mrargs{sorted=parse_boolean(Val)};
-        "partition_key" ->
-            Args#mrargs{partition_key=couch_util:to_binary(Val)};
+        "partition" ->
+            Args#mrargs{partition=couch_util:to_binary(Val)};
         _ ->
             BKey = couch_util:to_binary(Key),
             BVal = couch_util:to_binary(Val),
diff --git a/src/couch_mrview/src/couch_mrview_util.erl b/src/couch_mrview/src/couch_mrview_util.erl
index aa67c88..a5e3840 100644
--- a/src/couch_mrview/src/couch_mrview_util.erl
+++ b/src/couch_mrview/src/couch_mrview_util.erl
@@ -560,15 +560,15 @@ validate_args(Args) ->
         _ -> mrverror(<<"Invalid value for `sorted`.">>)
     end,
 
-    case {Args#mrargs.partitioned, Args#mrargs.partition_key} of
+    case {Args#mrargs.partitioned, Args#mrargs.partition} of
         {true, undefined} ->
-            mrverror(<<"`partition_key` parameter is mandatory for queries to this database.">>);
-        {true, _PartitionKey} ->
+            mrverror(<<"`partition` parameter is mandatory for queries to this database.">>);
+        {true, _Partition} ->
             ok;
         {undefined, undefined} ->
             ok;
-        {undefined, _PartitionKey} ->
-            mrverror(<<"`partition_key` parameter is not supported in this database.">>)
+        {undefined, _Partition} ->
+            mrverror(<<"`partition` parameter is not supported in this database.">>)
     end,
     Args.
 
@@ -592,23 +592,23 @@ update_args(#mrargs{} = Args) ->
     HighestKey = {[{<<239, 191, 176>>, null}]}, % \ufff0
 
     {StartKey, EndKey} = case Args of
-        #mrargs{partition_key=undefined} ->
+        #mrargs{partition=undefined} ->
             {Args#mrargs.start_key, Args#mrargs.end_key};
 
-        #mrargs{partition_key=PKey0} when not is_binary(PKey0) ->
-            mrverror(<<"`partition_key` must be a string.">>);
+        #mrargs{partition=P0} when not is_binary(P0) ->
+            mrverror(<<"`partition` must be a string.">>);
 
-        #mrargs{partition_key=PKey0, start_key=undefined, end_key=undefined} ->
-            {[PKey0, LowestKey], [PKey0, HighestKey]};
+        #mrargs{partition=P0, start_key=undefined, end_key=undefined} ->
+            {[P0, LowestKey], [P0, HighestKey]};
 
-        #mrargs{partition_key=PKey0, start_key=SK0, end_key=undefined} ->
-            {[PKey0, SK0], [PKey0, HighestKey]};
+        #mrargs{partition=P0, start_key=SK0, end_key=undefined} ->
+            {[P0, SK0], [P0, HighestKey]};
 
-        #mrargs{partition_key=PKey0, start_key=undefined, end_key=EK0} ->
-            {[PKey0, LowestKey], [PKey0, EK0]};
+        #mrargs{partition=P0, start_key=undefined, end_key=EK0} ->
+            {[P0, LowestKey], [P0, EK0]};
 
-        #mrargs{partition_key=PKey0, start_key=SK0, end_key=EK0} ->
-            {[PKey0, SK0], [PKey0, EK0]}
+        #mrargs{partition=P0, start_key=SK0, end_key=EK0} ->
+            {[P0, SK0], [P0, EK0]}
     end,
 
     Args#mrargs{