Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

! random sanpling default value

  • Loading branch information...
commit 03b8699eb2300ca18d692fe2fd1fd02fa4394978 1 parent 67b092e
Niko Dittmann authored
Showing with 9 additions and 1 deletion.
  1. +3 −1 lib/jsongrepper.rb
  2. +6 −0 qed/jsongrep.rdoc
4 lib/jsongrepper.rb
View
@@ -71,7 +71,9 @@ def sums
def reset_sums!
@sums = {}
end
- def summarize(random_sampling=1)
+ def summarize(random_sampling=nil)
+ random_sampling ||= 1
+
sums.each do |field, occurences|
total = 0
puts "\nSummary for #{field}:"
6 qed/jsongrep.rdoc
View
@@ -145,4 +145,10 @@ Is meant to speed up the processing of large data sets.
}.equals ''
+Random sampling also works with an explicit nil.
+
+ g = JsonGrepper.new('{"a":3, "b":5}').random_sampling(nil).grep(nil).condition('self.c = a + b ; c > 6').print('c').summarize(['a','c'])
+ output_of { JsonGrepper.summarize(nil) }
+
+
JsonGrepper.summarize then also takes a random sampling argument and multiplies the respective occurrences with the sample rate.
Please sign in to comment.
Something went wrong with that request. Please try again.