class GeoTreeModule::TreeStats

Attributes

interior_count[RW]
leaf_count[RW]
leaf_depth_max[RW]
overflow_count[RW]

Public Class Methods

new() click to toggle source
# File lib/geotree/geotree.rb, line 806
def initialize
  @leaf_count = 0
  @interior_count = 0
  @overflow_count = 0
  @leaf_used_sum = 0
  @leaf_depth_sum = 0
  @leaf_depth_max = 0
end

Public Instance Methods

process_node(n, overflow, depth) click to toggle source
# File lib/geotree/geotree.rb, line 815
def process_node(n, overflow, depth)
  if n.leaf
    @leaf_count += 1
    @leaf_used_sum += n.used
    @leaf_depth_sum += depth
    if overflow
      @overflow_count += 1
    end
    @leaf_depth_max = [@leaf_depth_max,depth].max
  else
    @interior_count += 1
  end
end
summary() click to toggle source
# File lib/geotree/geotree.rb, line 829
def summary
  s = {}
  s['leaf_nodes'] = leaf_count
  s['interior_nodes'] = interior_count
  s['overflow_nodes'] = overflow_count
  leaf_usage = 0
  if (leaf_count > 0)
    leaf_usage = (@leaf_used_sum / @leaf_count.to_f) / NODEL_CAPACITY
  end
  s['leaf_usage'] = leaf_usage
  avg_depth = 0
  if @leaf_count > 0
    avg_depth = @leaf_depth_sum / @leaf_count.to_f
  end
  s['leaf_depth (avg)'] = avg_depth
  s['leaf_depth (max)'] = leaf_depth_max
  s
end