class ApacheCrunch::LogDistribution
Same as Distribution
, but the buckets get expenentially wider
Public Instance Methods
_key_for(val, width_base)
click to toggle source
Determines the key for the distribution hash given the value and logarithmic base for the bucket width
# File lib/procedure_dsl.rb, line 195 def _key_for(val, width_base) exp = (Math.log(val) / Math.log(width_base)).to_i width_base ** exp end
execute(width_base, &blk)
click to toggle source
# File lib/procedure_dsl.rb, line 171 def execute(width_base, &blk) dist = {} while @_current_entry = @_log_parser.next_entry val = instance_eval(&blk) k = _key_for(val, width_base) if dist.key?(k) dist[k] += 1 else dist[k] = 1 end end # Backfill keys for which we didn't find a value k = dist.keys.min max_key = dist.keys.max while k *= width_base and k < max_key dist[k] = 0 unless dist.key?(k) end dist end