Permalink
Browse files

Merge remote-tracking branch 'origin/2.0.2'

Change-Id: Ib8fa30b94891b48684aaaa161e1de311dd32760d
  • Loading branch information...
2 parents c7bc292 + fb6316e commit e0ede61b489c504ef39bd4832da2b4a5853e7b20 @fdmanana fdmanana committed Feb 25, 2013
@@ -20,6 +20,7 @@ file_compression = snappy
; Maximum number of distinct view update/building processes at any point in time.
max_parallel_indexers = 4
max_parallel_replica_indexers = 2
+max_parallel_spatial_indexers = 4
; BTree Implmentation to use (native or erlang)
btree_implementation = native
consistency_check_precompacted = false
@@ -84,6 +84,12 @@ init([]) ->
permanent,
brutal_kill,
worker,
+ [couch_index_barrier]},
+ {couch_spatial_index_barrier,
+ {couch_index_barrier, start_link, [couch_spatial_index_barrier, "max_parallel_spatial_indexers"]},
+ permanent,
+ brutal_kill,
+ worker,
[couch_index_barrier]}
],
{ok, {{one_for_one, 10, 3600}, Children}}.
@@ -411,6 +411,10 @@ Handle<Value> emit(const Arguments& args)
{
isolate_data_t *isoData = getIsolateData();
+ if (isoData->ctx->kvs == NULL) {
+ return Undefined();
+ }
+
try {
ErlNifBinary keyJson = jsonStringify(args[0]);
ErlNifBinary valueJson = jsonStringify(args[1]);
@@ -546,6 +550,7 @@ isolate_data_t *getIsolateData()
void taskStarted(map_reduce_ctx_t *ctx)
{
ctx->taskStartTime = time(NULL);
+ ctx->kvs = NULL;
}
@@ -21,7 +21,7 @@
main(_) ->
test_util:init_code_path(),
- etap:plan(126),
+ etap:plan(138),
case (catch test()) of
ok ->
etap:end_tests();
@@ -39,6 +39,8 @@ test() ->
test_reduce_single_function_count(),
test_reduce_single_function_sum(),
test_reduce_multiple_functions(),
+ test_reduce_using_emit(),
+ test_reduce_no_return(),
test_burst(reduce, 1000),
test_burst(reduce, 10000),
test_burst(reduce, 25000),
@@ -224,6 +226,68 @@ test_reduce_multiple_functions() ->
ok.
+test_reduce_using_emit() ->
+ FunBin = <<"function(key, values, rereduce) {",
+ " for (var i = 0; i < 1000; ++i) { emit(key, values); }",
+ " return values.length; }">>,
+ {ok, Ctx} = mapreduce:start_reduce_context([FunBin]),
+ Results1 = mapreduce:reduce(Ctx, [
+ {<<"\"a\"">>, <<"1">>},
+ {<<"\"b\"">>, <<"2">>},
+ {<<"\"c\"">>, <<"3">>},
+ {<<"\"d\"">>, <<"4">>}
+ ]),
+ Results2 = mapreduce:reduce(Ctx, [
+ {<<"\"x\"">>, <<"666">>}
+ ]),
+ Results3 = mapreduce:reduce(Ctx, [
+ {<<"\"y\"">>, <<"999">>},
+ {<<"\"z\"">>, <<"1000">>}
+ ]),
+ etap:is(Results1, {ok, [<<"4">>]}, "Reduce value is 4"),
+ etap:is(Results2, {ok, [<<"1">>]}, "Reduce value is 1"),
+ etap:is(Results3, {ok, [<<"2">>]}, "Reduce value is 2"),
+ {ok, [Red1]} = Results1,
+ {ok, [Red2]} = Results2,
+ {ok, [Red3]} = Results3,
+ RereduceResult1 = mapreduce:rereduce(Ctx, 1, [Red1, Red2, Red3]),
+ etap:is(RereduceResult1, {ok, <<"3">>}, "Rereduce result is 3"),
+ RereduceResult2 = mapreduce:rereduce(Ctx, 1, [Red1, Red2]),
+ etap:is(RereduceResult2, {ok, <<"2">>}, "Rereduce result is 2"),
+ RereduceResult3 = mapreduce:rereduce(Ctx, 1, [Red1]),
+ etap:is(RereduceResult3, {ok, <<"1">>}, "Rereduce result is 1").
+
+
+test_reduce_no_return() ->
+ FunBin = <<"function(key, values, rereduce) { }">>,
+ {ok, Ctx} = mapreduce:start_reduce_context([FunBin]),
+ Results1 = mapreduce:reduce(Ctx, [
+ {<<"\"a\"">>, <<"1">>},
+ {<<"\"b\"">>, <<"2">>},
+ {<<"\"c\"">>, <<"3">>},
+ {<<"\"d\"">>, <<"4">>}
+ ]),
+ Results2 = mapreduce:reduce(Ctx, [
+ {<<"\"x\"">>, <<"666">>}
+ ]),
+ Results3 = mapreduce:reduce(Ctx, [
+ {<<"\"y\"">>, <<"999">>},
+ {<<"\"z\"">>, <<"1000">>}
+ ]),
+ etap:is(Results1, {ok, [<<"null">>]}, "Reduce value is null"),
+ etap:is(Results2, {ok, [<<"null">>]}, "Reduce value is null"),
+ etap:is(Results3, {ok, [<<"null">>]}, "Reduce value is null"),
+ {ok, [Red1]} = Results1,
+ {ok, [Red2]} = Results2,
+ {ok, [Red3]} = Results3,
+ RereduceResult1 = mapreduce:rereduce(Ctx, 1, [Red1, Red2, Red3]),
+ etap:is(RereduceResult1, {ok, <<"null">>}, "Rereduce result is null"),
+ RereduceResult2 = mapreduce:rereduce(Ctx, 1, [Red1, Red2]),
+ etap:is(RereduceResult2, {ok, <<"null">>}, "Rereduce result is null"),
+ RereduceResult3 = mapreduce:rereduce(Ctx, 1, [Red1]),
+ etap:is(RereduceResult3, {ok, <<"null">>}, "Rereduce result is null").
+
+
test_burst(Fun, N) ->
Results = do_burst(Fun, N),
ExpectedResults = [

0 comments on commit e0ede61

Please sign in to comment.