Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 913BE186B7 for ; Wed, 12 Aug 2015 15:57:45 +0000 (UTC) Received: (qmail 71202 invoked by uid 500); 12 Aug 2015 15:57:45 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 71023 invoked by uid 500); 12 Aug 2015 15:57:45 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 71007 invoked by uid 99); 12 Aug 2015 15:57:45 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Aug 2015 15:57:45 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3AA5FDFF41; Wed, 12 Aug 2015 15:57:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rnewson@apache.org To: commits@couchdb.apache.org Date: Wed, 12 Aug 2015 15:57:46 -0000 Message-Id: <2cdcc2fc6c834accb175ab24c70f32be@git.apache.org> In-Reply-To: <57db1dd73b0a415d90d7dc6e9972524f@git.apache.org> References: <57db1dd73b0a415d90d7dc6e9972524f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] couch-index commit: updated refs/heads/master to 86a6cd4 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 Authored: Wed Aug 5 14:56:42 2015 -0700 Committer: ILYA Khlopotov 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]).