Sha256: e0c3e40c752e5f633078d524a2a9d35bab6c81c911ba26431ba2052d2dad6c52

Contents?: true

Size: 937 Bytes

Versions: 5

Compression:

Stored size: 937 Bytes

Contents

module Neo4j
  class Database
    attr_reader :graph, :lucene, :event_handler

    def initialize()
      @event_handler = EventHandler.new
    end


    def start
      @graph = org.neo4j.kernel.EmbeddedGraphDatabase.new(Config[:storage_path])
      @lucene = org.neo4j.index.impl.lucene.LuceneIndexProvider.new(@graph)
      @graph.register_transaction_event_handler(@event_handler)
      @running = true
      @event_handler.neo4j_started(self)
      at_exit { shutdown }
    end

    def shutdown
      if @running
        @graph.unregister_transaction_event_handler(@event_handler)
        @event_handler.neo4j_shutdown(self)
      end
      @graph.shutdown
      @running = false
    end

    def running?
      @running
    end

    def begin_tx
      @graph.begin_tx
    end


    def each_node
      iter = @graph.all_nodes.iterator
      while (iter.hasNext)
        yield Node.wrapper(iter.next)
      end
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
neo4j-1.0.0.beta.13 lib/neo4j/database.rb
neo4j-1.0.0.beta.12 lib/neo4j/database.rb
neo4j-1.0.0.beta.11 lib/neo4j/database.rb
neo4j-1.0.0.beta.10 lib/neo4j/database.rb
neo4j-1.0.0.beta.9 lib/neo4j/database.rb