Sha256: 513ae32d2ae3aed575e9d796b2445b199e02a275dfdc32256980f56ec30ac880

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

module Neo4j
  class Database #:nodoc:
    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 =  @graph.index #org.neo4j.index.impl.lucene.LuceneIndexProvider.new
      @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)
        @graph.shutdown
        @graph = nil
        @lucene = nil
      end

      @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 iter.next.wrapper
      end
    end

    def _each_node
      iter = @graph.all_nodes.iterator
      while (iter.hasNext)
        yield iter.next
      end
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
neo4j-1.0.0.beta.21-java lib/neo4j/database.rb
neo4j-1.0.0.beta.20 lib/neo4j/database.rb
neo4j-1.0.0.beta.19 lib/neo4j/database.rb
neo4j-1.0.0.beta.18 lib/neo4j/database.rb