You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/07/31 23:10:19 UTC

[28/30] bear commit: updated refs/heads/import-master to 5f99806

get_statistics_subset should return well-formatted null results

The existing code for handling lists of values that don't meet minimum
length causes problems when the `percentiles` key is used; e.g., rather
than the expected

    [{percentile, [{0.5, 0.0}, ... ]}]

the user is presented with

    [{{percentile, [0.5, ... ]}, 0.0}]

which doesn't match the formatting for other subset key. This patch
special-cases the `percentile` key to return the expected result.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-bear/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-bear/commit/1a902e8c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-bear/tree/1a902e8c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-bear/diff/1a902e8c

Branch: refs/heads/import-master
Commit: 1a902e8c37f5f894a6b3203ee8a0279ff543eb82
Parents: 7d1ee8e
Author: Benjamin Anderson <b...@banjiewen.net>
Authored: Sat Nov 16 18:19:37 2013 -0800
Committer: Benjamin Anderson <b...@banjiewen.net>
Committed: Sat Nov 16 18:24:35 2013 -0800

----------------------------------------------------------------------
 src/bear.erl | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-bear/blob/1a902e8c/src/bear.erl
----------------------------------------------------------------------
diff --git a/src/bear.erl b/src/bear.erl
index 7d9eed9..67f4139 100644
--- a/src/bear.erl
+++ b/src/bear.erl
@@ -114,7 +114,14 @@ get_statistics_subset([_,_,_,_,_|_] = Values, Items) ->
 			  SortedValues, Scan_res, Scan_res2)
     end;
 get_statistics_subset(Values, Items) when is_list(Values) ->
-    [{Item, 0.0} || Item <- Items].
+    get_null_statistics_subset(Items, []).
+
+get_null_statistics_subset([{percentile, Ps}|Items], Acc) ->
+    get_null_statistics_subset(Items, [{percentile, [{P, 0.0} || P <- Ps]}|Acc]);
+get_null_statistics_subset([I|Items], Acc) ->
+    get_null_statistics_subset(Items, [{I, 0.0}|Acc]);
+get_null_statistics_subset([], Acc) ->
+    lists:reverse(Acc).
 
 calc_steps(Items) ->
     lists:foldl(fun({I,_},Acc) ->