Class: Neo4j::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/neo4j/spatial/database.rb

Overview

We extend the normal Neo4j::Database module with the ability to switch between normal and batch-inserter modes

Instance Method Summary collapse

Instance Method Details

#is_batch?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/neo4j/spatial/database.rb', line 36

def is_batch?
  @batch
end

#restart_batch_inserterObject



25
26
27
28
29
30
31
# File 'lib/neo4j/spatial/database.rb', line 25

def restart_batch_inserter
  shutdown
  @running = true
  @batch = org.neo4j.kernel.impl.batchinsert.BatchInserterImpl.new(Config[:storage_path])
  @graph = @batch.graph_db_service
  @batch
end

#restart_normal_databaseObject



32
33
34
35
# File 'lib/neo4j/spatial/database.rb', line 32

def restart_normal_database
  shutdown
  start
end

#shutdownObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/neo4j/spatial/database.rb', line 9

def shutdown
  if @running
    #puts "Shutting down database"
    if @batch.nil?
      #puts "Unregistering event handler"
      @graph.unregister_transaction_event_handler(@event_handler) unless read_only?
      @event_handler.neo4j_shutdown(self)
    end
    @graph.shutdown
    @graph  = nil
    @batch  = nil
    @lucene = nil
    @spatial = nil
    @running = false
  end
end

#spatialObject



39
40
41
# File 'lib/neo4j/spatial/database.rb', line 39

def spatial
  @spatial ||= org.neo4j.gis.spatial.SpatialDatabaseService.new(@graph)
end