Class: Groonga::StatisticMeasurer

Inherits:
Object
  • Object
show all
Defined in:
lib/groonga/statistic-measurer.rb

Overview

Measures statistic.

Constant Summary collapse

MAX_N_ADDITIONAL_PATHS =
4096

Instance Method Summary collapse

Instance Method Details

#measure_disk_usage(path) ⇒ Integer

Returns 0 if path is @nil@, disk usage of the path otherwise.

Parameters:

  • path (String, nil)

    Measures disk usage of the path.

Returns:

  • (Integer)

    0 if path is @nil@, disk usage of the path otherwise.



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/groonga/statistic-measurer.rb', line 25

def measure_disk_usage(path)
  return 0 if path.nil?

  usage = File.size(path)
  1.step(MAX_N_ADDITIONAL_PATHS) do |i|
    additional_path = "%s.%03X" % [path, i]
    break unless File.exist?(additional_path)
    usage += File.size(additional_path)
  end
  usage
end