couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [1/2] couch-mrview commit: updated refs/heads/windsor-merge to 258abc4
Date Wed, 06 Aug 2014 10:38:52 GMT
Repository: couchdb-couch-mrview
Updated Branches:
  refs/heads/windsor-merge [created] 258abc4a1


Implement JSON normalization with ucol:strip/1

This is the simple recursive function needed to apply the ucol:strip/1
function to any arbitrary JSON structure.

BugzId: 20223


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/commit/5942d537
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/5942d537
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/5942d537

Branch: refs/heads/windsor-merge
Commit: 5942d5372a538d9062739d0ed206b36c572ed454
Parents: 60eb161
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Fri Jun 7 13:54:44 2013 -0500
Committer: Robert Newson <rnewson@apache.org>
Committed: Thu Jul 31 10:16:59 2014 +0100

----------------------------------------------------------------------
 src/couch_mrview.app.src |  2 +-
 src/couch_mrview.erl     | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/5942d537/src/couch_mrview.app.src
----------------------------------------------------------------------
diff --git a/src/couch_mrview.app.src b/src/couch_mrview.app.src
index 99c52f0..166d474 100644
--- a/src/couch_mrview.app.src
+++ b/src/couch_mrview.app.src
@@ -24,5 +24,5 @@
         couch_mrview_util
     ]},
     {registered, []},
-    {applications, [kernel, stdlib, couch_index]}
+    {applications, [kernel, stdlib, couch_index, ucol]}
 ]}.

http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/5942d537/src/couch_mrview.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview.erl b/src/couch_mrview.erl
index d5faca3..4c2de5f 100644
--- a/src/couch_mrview.erl
+++ b/src/couch_mrview.erl
@@ -19,6 +19,7 @@
 -export([trigger_update/2, trigger_update/3]).
 -export([compact/2, compact/3, cancel_compaction/2]).
 -export([cleanup/1]).
+-export([norm_json/1]).
 
 -include_lib("couch/include/couch_db.hrl").
 -include_lib("couch_mrview/include/couch_mrview.hrl").
@@ -169,6 +170,26 @@ cleanup(Db) ->
     couch_mrview_cleanup:run(Db).
 
 
+norm_json({Props}) when is_list(Props) ->
+    {norm_json_props(Props)};
+norm_json(Vals) when is_list(Vals) ->
+    norm_json_vals(Vals);
+norm_json(Val) when is_binary(Val) ->
+    ucol:strip(Val);
+norm_json(Val) ->
+    Val.
+
+norm_json_props([]) ->
+    [];
+norm_json_props([{Key, Val} | Rest]) ->
+    [{norm_json(Key), norm_json(Val)} | norm_json_props(Rest)].
+
+norm_json_vals([]) ->
+    [];
+norm_json_vals([Val | Rest]) ->
+    [norm_json(Val) | norm_json_vals(Rest)].
+
+
 all_docs_fold(Db, #mrargs{keys=undefined}=Args, Callback, UAcc) ->
     {ok, Info} = couch_db:get_db_info(Db),
     Total = couch_util:get_value(doc_count, Info),


Mime
View raw message