couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [2/2] couch-index commit: updated refs/heads/master to 86a6cd4
Date Wed, 12 Aug 2015 15:57:46 GMT
Support transformer functions as args


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/commit/86a6cd4c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/tree/86a6cd4c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/diff/86a6cd4c

Branch: refs/heads/master
Commit: 86a6cd4c9860c55a311a14fde56ab30926736933
Parents: d267eab
Author: ILYA Khlopotov <iilyak@ca.ibm.com>
Authored: Wed Aug 5 14:56:42 2015 -0700
Committer: ILYA Khlopotov <iilyak@ca.ibm.com>
Committed: Wed Aug 5 14:56:42 2015 -0700

----------------------------------------------------------------------
 src/couch_index_plugin.erl | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/blob/86a6cd4c/src/couch_index_plugin.erl
----------------------------------------------------------------------
diff --git a/src/couch_index_plugin.erl b/src/couch_index_plugin.erl
index 1e10c61..9707089 100644
--- a/src/couch_index_plugin.erl
+++ b/src/couch_index_plugin.erl
@@ -24,5 +24,22 @@
 
 index_update(State, View, Updated, Removed) ->
     Handle = couch_epi:get_handle(?SERVICE_ID),
-    Args = [State, View, Updated, Removed],
+    case couch_epi:is_configured(Handle, index_update, 4) of
+        true ->
+            update(Handle, State, View, Updated, Removed);
+        false ->
+            ok
+    end.
+
+%% ------------------------------------------------------------------
+%% Internal Function Definitions
+%% ------------------------------------------------------------------
+
+maybe_transform(Fun) when is_function(Fun) ->
+    Fun();
+maybe_transform(Items) ->
+    Items.
+
+update(Handle, State, View, Updated, Removed) ->
+    Args = [State, View, maybe_transform(Updated), maybe_transform(Removed)],
     couch_epi:apply(Handle, ?SERVICE_ID, index_update, Args, [ignore_providers]).


Mime
View raw message