Skip to content

Instantly share code, notes, and snippets.

@markburns
Created August 7, 2012 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markburns/3286529 to your computer and use it in GitHub Desktop.
Save markburns/3286529 to your computer and use it in GitHub Desktop.
Problem with neo4j-core-java-2.0.1
#Alternative work around during tests
Neo4j::Transaction.run do
Neo4j.db.each_node do |n|
n.del unless n.neo_id == 0
end
end
#VehicleType.all.count #but without this line all VehicleType.count calls are 0 after 'successful import'
import_geoff_rules @an_array_of_geoff_rules
#test output
#Failure/Error: specify { VehicleType.all.to_a.size.should == 1 }
# expected: 1
# got: 0 (using ==)
#Code within project that causes this issue:
Neo4j.db.shutdown
FileUtils.rm_rf Neo4j::Config[:storage_path]
Neo4j.db.start
VehicleType.all.count #this line causes the included stack trace
import_geoff_rules @an_array_of_geoff_rules
NativeException:
java.lang.NullPointerException: null
# org/neo4j/kernel/impl/nioneo/xa/ReadTransaction.java:86:in `nodeLoadLight'
# org/neo4j/kernel/impl/persistence/PersistenceManager.java:82:in `loadLightNode'
# org/neo4j/kernel/impl/core/NodeManager.java:424:in `getLightNode'
# org/neo4j/kernel/impl/core/NodeManager.java:441:in `getNodeForProxy'
# org/neo4j/kernel/AbstractGraphDatabase.java:679:in `lookup'
# org/neo4j/kernel/impl/core/NodeProxy.java:98:in `getRelationships'
# org/neo4j/kernel/StandardExpander.java:528:in `doExpand'
# org/neo4j/kernel/StandardExpander.java:170:in `iterator'
# org/neo4j/kernel/impl/traversal/TraversalBranchImpl.java:112:in `expandRelationshipsWithoutChecks'
# org/neo4j/kernel/impl/traversal/TraversalBranchImpl.java:102:in `expandRelationships'
# org/neo4j/kernel/impl/traversal/StartNodeTraversalBranch.java:43:in `next'
# org/neo4j/kernel/PreorderBreadthFirstSelector.java:48:in `next'
# org/neo4j/kernel/impl/traversal/TraverserImpl.java:127:in `fetchNextOrNull'
# org/neo4j/kernel/impl/traversal/TraverserImpl.java:94:in `fetchNextOrNull'
# org/neo4j/helpers/collection/PrefetchingIterator.java:55:in `hasNext'
# org/neo4j/helpers/collection/IteratorWrapper.java:42:in `hasNext'
# /Users/markburns/.rvm/rubies/jruby-1.6.7.2/lib/ruby/site_ruby/shared/builtin/java/java.lang.rb:12:in `each'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/neo4j-core-2.0.1-java/lib/neo4j-core/traversal/traverser.rb:343:in `each'
# org/jruby/RubyEnumerable.java:141:in `count'
# ./lib/batch_importer.rb:39:in `go'
# ./lib/batch_importer.rb:22:in `import'
# ./spec/integration/builder_spec.rb:15:in `(root)'
# org/jruby/RubyBasicObject.java:1730:in `instance_eval'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/example.rb:236:in `instance_eval'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/hooks.rb:23:in `run'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/hooks.rb:72:in `run'
# org/jruby/RubyArray.java:1615:in `each'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/hooks.rb:72:in `run'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/hooks.rb:424:in `run_hook'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/example_group.rb:323:in `run_before_each_hooks'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/example.rb:299:in `run_before_each'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/example.rb:112:in `run'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/example.rb:253:in `with_around_each_hooks'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/example.rb:110:in `run'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/example_group.rb:378:in `run_examples'
# org/jruby/RubyArray.java:2331:in `collect'
# org/jruby/RubyArray.java:2339:in `collect'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/example_group.rb:374:in `run_examples'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/example_group.rb:360:in `run'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/example_group.rb:361:in `run'
# org/jruby/RubyArray.java:2331:in `collect'
# org/jruby/RubyArray.java:2339:in `collect'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/example_group.rb:361:in `run'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/command_line.rb:28:in `run'
# org/jruby/RubyArray.java:2331:in `collect'
# org/jruby/RubyArray.java:2339:in `collect'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/command_line.rb:28:in `run'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/reporter.rb:34:in `report'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/command_line.rb:25:in `run'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/runner.rb:66:in `run'
# /Users/markburns/.rvm/gems/jruby-1.6.7.2/gems/rspec-core-2.11.0/lib/rspec/core/runner.rb:8:in `autorun'
# org/jruby/RubyProc.java:270:in `call'
# org/jruby/RubyProc.java:224:in `call'
#Alternative work around during tests
Neo4j::Transaction.run do
Neo4j.db.each_node do |n|
n.del unless n.neo_id == 0
end
end
VehicleType.all.count
import_geoff_rules @an_array_of_geoff_rules
#test output
#success
@markburns
Copy link
Author

We're trying to get a non-hacky way of setting up neo4j data and in the middle of writing a Geoff syntax importer.

This is inside a sinatra project. One way we've found of getting it to work is rather hacky - i.e. for every model, if we call ModelName.all.count in between deleting then restarting the database and the import step then it seems to work as normal.

The other cases are shown above.

We'd hopefully like to make this gem open source as soon as we've solved these problems but at the moment we're struggling to get to the bottom of the issue.

@markburns
Copy link
Author

Any pointers would be greatly appreciated

@andreasronge
Copy link

Hmm, sorry for very late reply. Not sure what the import_geoff_rules does.
I guess you are using the java neo4j batch importer. If that's the case then there might be problem with the rule nodes.
A rule node represent a class and does have a counter property.
The counter is keeping updated be using the neo4j event framework. The listener is this class - https://github.com/andreasronge/neo4j-wrapper/blob/master/lib/neo4j-wrapper/rule/event_listener.rb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment