Skip to content

Instantly share code, notes, and snippets.

@shageman
Created March 1, 2011 19:53
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 shageman/849757 to your computer and use it in GitHub Desktop.
Save shageman/849757 to your computer and use it in GitHub Desktop.
Files for example regarding data writer + reader to test concurrency of neo4j access through neo4j gem (http://wiki.neo4j.org/content/Getting_Started_With_Ruby)
require "rubygems"
require "neo4j"
#domain model
class Waypoint
include Neo4j::NodeMixin
#the persistent properties of this class
property :name, :lon, :lat
#friend relationships to other persons
has_n :roads
index :name
end
while(true) do
Waypoint.find(:name => 'Seattle').each { |x|
puts "Found Waypoint: #{x.name}"
}
sleep 1
end
require "rubygems"
require "neo4j"
#domain model
class Waypoint
include Neo4j::NodeMixin
#the persistent properties of this class
property :name, :lon, :lat
#friend relationships to other persons
has_n :roads
index :name
end
#populate the db
Neo4j::Transaction.run do
#the waypoints
NYC = Waypoint.new :name=>'New York', :lon=>-74.007124, :lat=>40.714550
SF = Waypoint.new :name=>'San Francisco', :lon=>-122.420139, :lat=>37.779600
SEA = Waypoint.new :name=>'Seattle', :lon=>-122.329439, :lat=>47.603560
#the roads
NYC.roads << SF
NYC.roads << SEA
SEA.roads << SF
end
while(true) do
Waypoint.find(:name => 'New York').each { |x|
puts "Found Waypoint: #{x.name}"
}
sleep 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment