Created
March 1, 2011 19:53
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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