lib/perobs/BigTree.rb in perobs-4.1.0 vs lib/perobs/BigTree.rb in perobs-4.2.0
- old
+ new
@@ -138,11 +138,11 @@
# key.
# @yield [key, value]
def each(&block)
node = @first_leaf
while node
- node.each_element(&block)
+ break if node.each_element(&block).nil?
node = node.next_sibling
end
end
# Iterate over all entries in the tree in reverse order. Entries are
@@ -164,9 +164,22 @@
# Check if the tree file contains any errors.
# @return [Boolean] true if no erros were found, false otherwise
def check(&block)
@root.check(&block)
+
+ i = 0
+ each do |k, v|
+ i += 1
+ end
+
+ unless @entry_counter == i
+ PEROBS.log.error "BigTree contains #{i} values but entry counter " +
+ "is #{@entry_counter}"
+ return false
+ end
+
+ true
end
# Gather some statistics regarding the tree structure.
# @return [Stats] Structs with gathered data
def statistics