diff --git a/lib/neo4j/neo.rb b/lib/neo4j/neo.rb index da219b79f..0ad7cd0c6 100644 --- a/lib/neo4j/neo.rb +++ b/lib/neo4j/neo.rb @@ -115,10 +115,27 @@ def self.number_of_relationships_in_use instance.neo.getConfig().getNeoModule().getNodeManager().getNumberOfIdsInUse(org.neo4j.api.core.Relationship.java_class) end - def self.number_of_properties_in_use + # Total number of relationships, nodes and properties in use + def self.number_of_ids_in_use instance.neo.getConfig().getNeoModule().getNodeManager().getNumberOfIdsInUse(org.neo4j.impl.nioneo.store.PropertyStore.java_class) end + def self.number_of_properties_in_use + self.number_of_ids_in_use - self.number_of_relationships_in_use - self.number_of_nodes_in_use + 1 + end + + # Prints some info about the database + def self.info + puts "Neo4j version: #{Neo4j::VERSION}" + puts "Neo4j db running #{self.running?}" + puts "number_of_nodes_in_use: #{self.number_of_nodes_in_use}" + puts "number_of_relationships_in_use: #{self.number_of_relationships_in_use}" + puts "number_of_properties_in_use: #{self.number_of_properties_in_use}" + puts "number_of_ids_in_use: #{self.number_of_ids_in_use}" + puts "neo db storage location: #{Neo4j::Config[:storage_path]}" + puts "lucene index storage location: #{Lucene::Config[:storage_path]}" + puts "keep lucene index in memory: #{!Lucene::Config[:store_on_file]}" + end # # Allows run and stop the Neo4j service # Contains global ćonstants such as location of the neo storage and index files diff --git a/test/neo4j/neo_spec.rb b/test/neo4j/neo_spec.rb index 6e70ed68c..5b812b2fe 100644 --- a/test/neo4j/neo_spec.rb +++ b/test/neo4j/neo_spec.rb @@ -80,6 +80,25 @@ class Foo Neo4j.number_of_properties_in_use.should == 1 end + it "should only count properties using Neo4j.number_of_properties_in_use" do + # only reference node exists + node1 = node2 = nil + Neo4j::Transaction.run do + node1 = Neo4j::Node.new + node2 = Neo4j::Node.new + end + + Neo4j.number_of_properties_in_use.should == 1 # a bit weird, should be 3 since each node sets the classname property ... + + + Neo4j::Transaction.run do + node1.relationships.outgoing(:baaz) << node2 + Neo4j::Node.new + end + + Neo4j.number_of_properties_in_use.should == 1 + end + it "should return correct number of properties when using Neo4j.number_of_relationships_in_use" do # create two nodes that we can create relationships between node1 = node2 = nil