Sha256: b75088905125e25fa69ca04ec8d383eaa64c289ae64e1d4bdffd7feb1c918bb1
Contents?: true
Size: 1.33 KB
Versions: 6
Compression:
Stored size: 1.33 KB
Contents
class Geoff class Error < StandardError ; end class MissingIndexedProperty < Geoff::Error ; end module Indexer class << self def rebuild_indices db @db = db Geoff.log 're-building indexes' Neo4j::Transaction.run do node_types.each do |type| re_index(type) end end end private def node_types root_node.relationships.map { |r| Kernel.const_get(r.get_type.to_s) rescue nil }.compact end def re_index(type) Geoff.log "-> re-indexing #{type}" props = type.instance_variable_get(:@_decl_props) indexed_props = props.find_all { |_, p| p.has_key?(:index) } indexed_props.each do |index| all = type.all all.each do |node| @current_node = node @current_index = index.first node.add_index index.first end end rescue NativeException => e Geoff.log "-" * 80 message = "#{type} missing indexed attribute #{@current_index}, on node: #{@current_node.attributes}" Geoff.log message Geoff.log "-" * 80 Geoff.log e.message Geoff.log "-" * 80 raise Geoff::MissingIndexedProperty, message end def root_node @db.reference_node end end end end
Version data entries
6 entries across 6 versions & 1 rubygems