You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2020/01/16 00:22:11 UTC

[GitHub] [couchdb] chewbranca commented on a change in pull request #2456: FDB Builtin reduce

chewbranca commented on a change in pull request #2456: FDB Builtin reduce
URL: https://github.com/apache/couchdb/pull/2456#discussion_r367063674
 
 

 ##########
 File path: src/couch_views/src/couch_views_reducer.erl
 ##########
 @@ -0,0 +1,325 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+
+-module(couch_views_reducer).
+
+
+-export([
+    start_value/1,
+    decode/1,
+    encode/1,
+    reduce/2,
+    rereduce/3,
+    finalize/2
+]).
+
+
+-include_lib("couch/include/couch_db.hrl").
+
+
+-define(SUMERROR, <<"The _sum function requires that map values be numbers, "
+"arrays of numbers, or objects. Objects cannot be mixed with other "
+"data structures. Objects can be arbitrarily nested, provided that the values "
+"for all fields are themselves numbers, arrays of numbers, or objects.">>).
+
+-define(STATERROR, <<"The _stats function requires that map values be numbers "
+"or arrays of numbers, not '~p'">>).
+
+-define(BUILTIN_SUM, <<"_sum", _/binary>>).
+-define(BUILTIN_COUNT, <<"_count", _/binary>>).
+-define(BUILTIN_STATS, <<"_stats", _/binary>>).
+-define(BUILTIN_COUNT_DISTINCT, <<"_approx_count_distinct", _/binary>>).
+
+
+start_value(<<"_approx_count_distinct">>) ->
+    hyper:new(11);
 
 Review comment:
   We should move `11` to a macro so we're not duplicating magic numbers.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services