Skip to content
This repository has been archived by the owner on Sep 19, 2019. It is now read-only.

Commit

Permalink
Generalize merging of 'other' results
Browse files Browse the repository at this point in the history
BugzID: 9995
  • Loading branch information
kocolosk committed Apr 19, 2011
1 parent e7eb5a8 commit f64e4a5
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/fabric_db_info.erl
Expand Up @@ -63,14 +63,20 @@ merge_results(Info) ->
(disk_size, X, Acc) ->
[{disk_size, lists:sum(X)} | Acc];
(other, X, Acc) ->
[{other, {[{data_size, total_sizes(X)}]}} | Acc];
[{other, {merge_other_results(X)}} | Acc];
(disk_format_version, X, Acc) ->
[{disk_format_version, lists:max(X)} | Acc];
(_, _, Acc) ->
Acc
end, [{instance_start_time, <<"0">>}], Dict).

total_sizes(X) ->
lists:foldl(fun({[{_,Size}]}, Acc) ->
Acc + Size
end,0,X).
merge_other_results(Results) ->
Dict = lists:foldl(fun({Props}, D) ->
lists:foldl(fun({K,V},D0) -> orddict:append(K,V,D0) end, D, Props)
end, orddict:new(), Results),
orddict:fold(fun
(data_size, X, Acc) ->
[{data_size, lists:sum(X)} | Acc];
(_, _, Acc) ->
Acc
end, [], Dict).

0 comments on commit f64e4a5

Please sign in to comment.