Skip to content

Commit

Permalink
implemented new aggregate function on ZINTERSTORE:
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcos Almonacid committed Dec 22, 2011
1 parent 516e840 commit 2a00732
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/edis_db.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1876,7 +1876,7 @@ weighted_intersection(Aggregate, [{ZSet, Weight} | Rest], AccWeight, AccZSet) ->
Aggregate, Rest, 1.0,
zsets:intersection(
fun(Score, AccScore) ->
lists:Aggregate([Score * Weight, AccScore * AccWeight])
edis_util:Aggregate(edis_util:multiply(Score,Weight),edis_util:multiply(AccScore,AccWeight))
end, ZSet, AccZSet)).

weighted_union(_Aggregate, [{ZSet, Weight}]) ->
Expand All @@ -1890,13 +1890,10 @@ weighted_union(Aggregate, [{ZSet, Weight} | Rest], AccWeight, AccZSet) ->
Aggregate, Rest, 1.0,
zsets:union(
fun(undefined, AccScore) ->
%% AccScore * AccWeight;
edis_util:multiply(AccScore,AccWeight);
(Score, undefined) ->
%% Score * Weight;
edis_util:multiply(Score,Weight);
(Score, AccScore) ->
%% lists:Aggregate([Score * Weight, AccScore * AccWeight])
edis_util:Aggregate(edis_util:multiply(Score,Weight),edis_util:multiply(AccScore,AccWeight))
end, ZSet, AccZSet)).

Expand Down

0 comments on commit 2a00732

Please sign in to comment.