neo4j-core 2.1.0-java → 2.2.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. data/Gemfile +0 -10
  2. data/README.rdoc +2 -130
  3. data/config/neo4j/config.yml~ +102 -0
  4. data/lib/db/active_tx_log +1 -0
  5. data/lib/db/index/lucene-store.db +0 -0
  6. data/lib/db/index/lucene.log.active +0 -0
  7. data/lib/db/index/lucene.log.v0 +0 -0
  8. data/lib/db/messages.log +285 -0
  9. data/lib/db/neostore +0 -0
  10. data/lib/db/neostore.id +0 -0
  11. data/lib/db/neostore.nodestore.db +1 -0
  12. data/lib/db/neostore.nodestore.db.id +0 -0
  13. data/lib/db/neostore.propertystore.db +1 -0
  14. data/lib/db/neostore.propertystore.db.arrays +0 -0
  15. data/lib/db/neostore.propertystore.db.arrays.id +0 -0
  16. data/lib/db/neostore.propertystore.db.id +0 -0
  17. data/lib/db/neostore.propertystore.db.index +1 -0
  18. data/lib/db/neostore.propertystore.db.index.id +0 -0
  19. data/lib/db/neostore.propertystore.db.index.keys +0 -0
  20. data/lib/db/neostore.propertystore.db.index.keys.id +0 -0
  21. data/lib/db/neostore.propertystore.db.strings +0 -0
  22. data/lib/db/neostore.propertystore.db.strings.id +0 -0
  23. data/lib/db/neostore.relationshipstore.db +1 -0
  24. data/lib/db/neostore.relationshipstore.db.id +0 -0
  25. data/lib/db/neostore.relationshiptypestore.db +1 -0
  26. data/lib/db/neostore.relationshiptypestore.db.id +0 -0
  27. data/lib/db/neostore.relationshiptypestore.db.names +0 -0
  28. data/lib/db/neostore.relationshiptypestore.db.names.id +0 -0
  29. data/lib/db/nioneo_logical.log.active +0 -0
  30. data/lib/db/nioneo_logical.log.v0 +0 -0
  31. data/lib/db/tm_tx_log.1 +0 -0
  32. data/lib/neo4j-core.rb +4 -4
  33. data/lib/neo4j-core/database.rb +1 -0
  34. data/lib/neo4j-core/index/index_config.rb +1 -1
  35. data/lib/neo4j-core/property/property.rb +11 -0
  36. data/lib/neo4j-core/relationship/class_methods.rb +1 -3
  37. data/lib/neo4j-core/traversal/traverser.rb +19 -29
  38. data/lib/neo4j-core/version.rb +1 -1
  39. data/lib/neo4j-core/version.rb~ +5 -0
  40. data/lib/neo4j/config.rb +2 -2
  41. data/lib/neo4j/config.rb~ +136 -0
  42. data/lib/neo4j/neo4j.rb +3 -3
  43. data/neo4j-core.gemspec +1 -0
  44. metadata +81 -6
  45. data/lib/neo4j-core/cypher/cypher.rb +0 -1033
  46. data/lib/neo4j-core/cypher/result_wrapper.rb +0 -48
  47. data/lib/neo4j/cypher.rb +0 -180
data/lib/db/neostore ADDED
Binary file
Binary file
@@ -0,0 +1 @@
1
+ ��������NodeStore v0.A.0
Binary file
@@ -0,0 +1 @@
1
+ PropertyStore v0.A.0
Binary file
@@ -0,0 +1 @@
1
+ PropertyIndexStore v0.A.0
@@ -0,0 +1 @@
1
+ RelationshipStore v0.A.0
@@ -0,0 +1 @@
1
+ RelationshipTypeStore v0.A.0
Binary file
Binary file
File without changes
data/lib/neo4j-core.rb CHANGED
@@ -6,6 +6,10 @@ module Neo4j
6
6
  Enumerator = Enumerable::Enumerator unless defined? Enumerator
7
7
  end
8
8
 
9
+ require 'set'
10
+
11
+ require 'neo4j-cypher'
12
+
9
13
  require 'neo4j-core/version'
10
14
  require 'neo4j/config'
11
15
 
@@ -59,12 +63,8 @@ require 'neo4j-core/traversal/prune_evaluator'
59
63
  require 'neo4j-core/traversal/rel_expander'
60
64
  require 'neo4j-core/traversal/traversal'
61
65
  require 'neo4j-core/traversal/traverser'
62
-
63
- require 'neo4j-core/cypher/cypher'
64
- require 'neo4j-core/cypher/result_wrapper'
65
66
  require 'neo4j-core/hash_with_indifferent_access'
66
67
 
67
68
  require 'neo4j/algo'
68
- require 'neo4j/cypher'
69
69
  require 'neo4j/node'
70
70
  require 'neo4j/relationship'
@@ -53,6 +53,7 @@ module Neo4j
53
53
  return if running?
54
54
  @running = true
55
55
  @storage_path = Config.storage_path
56
+ Java::JavaLang::System.setProperty("neo4j.ext.udc.source", "neo4rb")
56
57
 
57
58
  begin
58
59
  if self.class.locked?
@@ -39,7 +39,7 @@ module Neo4j
39
39
 
40
40
  # Specifies an index with configuration
41
41
  # Used in the Index DSL.
42
- # @param [Hash] args the field and its configuration TODO
42
+ # @param [Hash] args the field and its configuration
43
43
  # @see Neo4j::Core::Index::ClassMethods#index
44
44
  def index(args)
45
45
  conf = args.last.kind_of?(Hash) ? args.pop : {}
@@ -2,6 +2,9 @@ module Neo4j
2
2
  module Core
3
3
  module Property
4
4
 
5
+ # the valid values on a property, and arrays of those.
6
+ VALID_PROPERTY_VALUE_CLASSES = Set.new([Array, NilClass, String, Float, TrueClass, FalseClass, Fixnum])
7
+
5
8
  # @return [Hash] all properties plus the id of the node with the key <tt>_neo_id</tt>
6
9
  def props
7
10
  ret = {"_neo_id" => neo_id}
@@ -69,6 +72,12 @@ module Neo4j
69
72
  val.class.superclass == ArrayJavaProxy ? val.to_a : val
70
73
  end
71
74
 
75
+ # @param [Object] value the value we want to check if it's a valid neo4j property value
76
+ # @return [True, False] A false means it can't be persisted.
77
+ def valid_property?(value)
78
+ VALID_PROPERTY_VALUE_CLASSES.include?(value.class)
79
+ end
80
+
72
81
  # Sets the property of this node.
73
82
  # Property keys are always strings. Valid property value types are the primitives(<tt>String</tt>, <tt>Fixnum</tt>, <tt>Float</tt>, <tt>FalseClass</tt>, <tt>TrueClass</tt>) or array of those primitives.
74
83
  #
@@ -79,6 +88,8 @@ module Neo4j
79
88
  # @param [String, Symbol] key of the property to set
80
89
  # @param [String,Fixnum,Float,true,false, Array] value to set
81
90
  def []=(key, value)
91
+ raise "Not valid Neo4j Property value #{value.class}, valid: #{VALID_PROPERTY_VALUE_CLASSES.join(', ')}" unless valid_property?(value)
92
+
82
93
  k = key.to_s
83
94
  if value.nil?
84
95
  remove_property(k)
@@ -45,9 +45,7 @@ module Neo4j
45
45
  # @see #load
46
46
  def _load(rel_id, db = Neo4j.started_db)
47
47
  return nil if rel_id.nil?
48
- rel = db.graph.get_relationship_by_id(rel_id.to_i)
49
- # TODO
50
- rel
48
+ db.graph.get_relationship_by_id(rel_id.to_i)
51
49
  rescue Java::OrgNeo4jGraphdb::NotFoundException
52
50
  nil
53
51
  end
@@ -7,44 +7,34 @@ module Neo4j
7
7
  attr_accessor :query, :return_variable
8
8
 
9
9
  def initialize(start_id, dir, types, query_hash=nil, &block)
10
- this = self
11
-
12
- rel_type = ":#{types.map{|x| "`#{x}`"}.join('|')}"
13
-
14
- @query = Neo4j::Cypher.new do
15
- default_ret = node(:default_ret)
10
+ q = Neo4j::Cypher.query do
16
11
  n = node(start_id)
17
- case dir
18
- when :outgoing then
19
- n > rel_type > default_ret
20
- when :incoming then
21
- n < rel_type < default_ret
22
- when :both then
23
- n - rel_type - default_ret
24
- end
25
-
26
- # where statement
27
- ret_maybe = block && self.instance_exec(default_ret, &block)
28
- ret = ret_maybe.respond_to?(:var_name) ? ret_maybe : default_ret
29
- if query_hash
30
- expr = []
31
- query_hash.each{|pair| expr << (ret[pair[0]] == pair[1])}.to_a
32
- expr.each_with_index do |obj, i|
33
- Neo4j::Core::Cypher::ExprOp.new(obj, expr[i+1], "and") if i < expr.size - 1
34
- end
12
+ next_nodes = case dir
13
+ when :outgoing then
14
+ n.outgoing(types)
15
+ when :incoming then
16
+ n.incoming(types)
17
+ when :both then
18
+ n.both(types)
19
+ end
20
+ if block
21
+ self.instance_exec(next_nodes, &block)
22
+ else
23
+ query_hash.each{|pair| next_nodes[pair[0]] == pair[1]}.to_a if query_hash
24
+ next_nodes
35
25
  end
26
+ end
36
27
 
37
- this.return_variable = ret.var_name.to_sym
38
- ret
39
- end.to_s
28
+ @query = q.to_s
29
+ self.return_variable=q.return_names.last
40
30
  end
41
31
 
42
32
  def to_s
43
- @query
33
+ @query.to_s
44
34
  end
45
35
 
46
36
  def each
47
- Neo4j._query(query).each do |r|
37
+ Neo4j._query(to_s).each do |r|
48
38
  yield r[return_variable]
49
39
  end
50
40
  end
@@ -1,5 +1,5 @@
1
1
  module Neo4j
2
2
  module Core
3
- VERSION = "2.1.0"
3
+ VERSION = "2.2.0"
4
4
  end
5
5
  end
@@ -0,0 +1,5 @@
1
+ module Neo4j
2
+ module Core
3
+ VERSION = "2.2.0.rc1"
4
+ end
5
+ end
data/lib/neo4j/config.rb CHANGED
@@ -112,9 +112,9 @@ module Neo4j
112
112
  to_hash.each_pair do |k, v|
113
113
  case v
114
114
  when TrueClass
115
- map[k.to_s] = "YES"
115
+ map[k.to_s] = "true"
116
116
  when FalseClass
117
- map[k.to_s] = "NO"
117
+ map[k.to_s] = "false"
118
118
  when String, Fixnum, Float
119
119
  map[k.to_s] = v.to_s
120
120
  # skip list and hash values - not accepted by the Java Neo4j API
@@ -0,0 +1,136 @@
1
+ module Neo4j
2
+
3
+
4
+ # == Keeps configuration for neo4j
5
+ #
6
+ # The most important configuration is storage_path which is used to
7
+ # locate where the neo4j database is stored on the filesystem.
8
+ # If this directory is empty then a new database will be created, otherwise it will use the
9
+ # database from that directory.
10
+ #
11
+ # == Configurations keys
12
+ #
13
+ # storage_path where the database is stored
14
+ # timestamps if timestamps should be used when saving the model (Neo4j::Rails::Model)
15
+ # lucene lucene configuration for fulltext and exact indices
16
+ # enable_rules if false the _all relationship to all instances will not be created and custom rules will not be available. (Neo4j::NodeMixin and Neo4j::Rails::Model)
17
+ # identity_map default false, See Neo4j::IdentityMap (Neo4j::NodeMixin and Neo4j::Rails::Model)
18
+ #
19
+ class Config
20
+
21
+ class << self
22
+
23
+ # @return [Fixnum] The location of the default configuration file.
24
+ def default_file
25
+ @default_file ||= File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "config", "neo4j", "config.yml"))
26
+ end
27
+
28
+ # Sets the location of the configuration YAML file and old deletes configurations.
29
+ #
30
+ # @param [String] file_path represent the path to the file.
31
+ def default_file=(file_path)
32
+ @configuration = nil
33
+ @defaults = nil
34
+ @default_file = File.expand_path(file_path)
35
+ end
36
+
37
+ # @return [Hash] the default file loaded by yaml
38
+ def defaults
39
+ require 'yaml'
40
+ @defaults ||= Neo4j::Core::HashWithIndifferentAccess.new(YAML.load_file(default_file))
41
+ end
42
+
43
+ # @return [String] the expanded path of the Config[:storage_path] property
44
+ def storage_path
45
+ File.expand_path(self[:storage_path])
46
+ end
47
+
48
+ # Yields the configuration
49
+ #
50
+ # @example
51
+ # Neo4j::Config.use do |config|
52
+ # config[:storage_path] = '/var/neo4j'
53
+ # end
54
+ #
55
+ # @return nil
56
+ # @yield config
57
+ # @yieldparam [Neo4j::Config] config - this configuration class
58
+ def use
59
+ @configuration ||= Neo4j::Core::HashWithIndifferentAccess.new
60
+ yield @configuration
61
+ nil
62
+ end
63
+
64
+
65
+ # Sets the value of a config entry.
66
+ #
67
+ # @param [Symbol] key the key to set the parameter for
68
+ # @param val the value of the parameter.
69
+ def []=(key, val)
70
+ (@configuration ||= setup)[key.to_s] = val
71
+ end
72
+
73
+
74
+ # @param [Symbol] key The key of the config entry value we want
75
+ # @return the the value of a config entry
76
+ def [](key)
77
+ (@configuration ||= setup)[key.to_s]
78
+ end
79
+
80
+
81
+ # Remove the value of a config entry.
82
+ #
83
+ # @param [Symbol] key the key of the configuration entry to delete
84
+ # @return The value of the removed entry.
85
+ def delete(key)
86
+ @configuration.delete(key)
87
+ end
88
+
89
+
90
+ # Remove all configuration. This can be useful for testing purpose.
91
+ #
92
+ # @return nil
93
+ def delete_all
94
+ @configuration = nil
95
+ end
96
+
97
+
98
+ # @return [Hash] The config as a hash.
99
+ def to_hash
100
+ @configuration ||= setup
101
+ end
102
+
103
+ # @return [String] The config as a YAML
104
+ def to_yaml
105
+ @configuration.to_yaml
106
+ end
107
+
108
+ # Converts the defaults hash to a Java HashMap used by the Neo4j API.
109
+ # @return a Java HashMap used by the Java Neo4j API as configuration for the GraphDatabase
110
+ def to_java_map
111
+ map = java.util.HashMap.new
112
+ to_hash.each_pair do |k, v|
113
+ case v
114
+ when TrueClass
115
+ map[k.to_s] = "YES"
116
+ when FalseClass
117
+ map[k.to_s] = "NO"
118
+ when String, Fixnum, Float
119
+ map[k.to_s] = v.to_s
120
+ # skip list and hash values - not accepted by the Java Neo4j API
121
+ end
122
+ end
123
+ map
124
+ end
125
+
126
+ # @return The a new configuration using default values as a hash.
127
+ def setup()
128
+ @configuration = Neo4j::Core::HashWithIndifferentAccess.new
129
+ @configuration.merge!(defaults)
130
+ @configuration
131
+ end
132
+
133
+ end
134
+ end
135
+
136
+ end
data/lib/neo4j/neo4j.rb CHANGED
@@ -112,9 +112,9 @@ module Neo4j
112
112
  # @see http://docs.neo4j.org/chunked/milestone/cypher-query-lang.html The Cypher Query Language Documentation
113
113
  # @note Returns a read-once only forward iterable.
114
114
  # @param params parameter for the query_dsl block
115
- # @return [Neo4j::Core::Cypher::ResultWrapper] a forward read once only Enumerable, containing hash values.
115
+ # @return [Neo4j::Cypher::ResultWrapper] a forward read once only Enumerable, containing hash values.
116
116
  def query(*params, &query_dsl)
117
- q = Cypher.new(*params, &query_dsl).to_s
117
+ q = Neo4j::Cypher.query(*params, &query_dsl).to_s
118
118
  _query(q)
119
119
  end
120
120
 
@@ -124,7 +124,7 @@ module Neo4j
124
124
  def _query(q)
125
125
  engine = Java::OrgNeo4jCypherJavacompat::ExecutionEngine.new(db)
126
126
  result = engine.execute(q)
127
- Neo4j::Core::Cypher::ResultWrapper.new(result)
127
+ Neo4j::Cypher::ResultWrapper.new(result)
128
128
  end
129
129
 
130
130
 
data/neo4j-core.gemspec CHANGED
@@ -28,4 +28,5 @@ It comes included with the Apache Lucene document database.
28
28
  s.rdoc_options = ["--quiet", "--title", "Neo4j::Core", "--line-numbers", "--main", "README.rdoc", "--inline-source"]
29
29
 
30
30
  s.add_dependency("neo4j-community", '>= 1.8.M05', '< 1.9')
31
+ s.add_dependency("neo4j-cypher", '~> 1.0.0')
31
32
  end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: neo4j-core
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.1.0
5
+ version: 2.2.0
6
6
  platform: java
7
7
  authors:
8
8
  - Andreas Ronge
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-14 00:00:00.000000000 Z
12
+ date: 2012-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: neo4j-community
@@ -35,6 +35,22 @@ dependencies:
35
35
  none: false
36
36
  prerelease: false
37
37
  type: :runtime
38
+ - !ruby/object:Gem::Dependency
39
+ name: neo4j-cypher
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: 1.0.0
45
+ none: false
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ~>
49
+ - !ruby/object:Gem::Version
50
+ version: 1.0.0
51
+ none: false
52
+ prerelease: false
53
+ type: :runtime
38
54
  description: ! "You can think of Neo4j as a high-performance graph engine with all\
39
55
  \ the features of a mature and robust database.\nThe programmer works with an object-oriented,\
40
56
  \ flexible network structure rather than with strict and static tables \nyet enjoys\
@@ -48,12 +64,71 @@ extra_rdoc_files:
48
64
  files:
49
65
  - !binary |-
50
66
  bGliL25lbzRqLWNvcmUucmI=
67
+ - !binary |-
68
+ bGliL2RiL2FjdGl2ZV90eF9sb2c=
69
+ - !binary |-
70
+ bGliL2RiL21lc3NhZ2VzLmxvZw==
71
+ - !binary |-
72
+ bGliL2RiL25lb3N0b3Jl
73
+ - !binary |-
74
+ bGliL2RiL25lb3N0b3JlLmlk
75
+ - !binary |-
76
+ bGliL2RiL25lb3N0b3JlLm5vZGVzdG9yZS5kYg==
77
+ - !binary |-
78
+ bGliL2RiL25lb3N0b3JlLm5vZGVzdG9yZS5kYi5pZA==
79
+ - !binary |-
80
+ bGliL2RiL25lb3N0b3JlLnByb3BlcnR5c3RvcmUuZGI=
81
+ - !binary |-
82
+ bGliL2RiL25lb3N0b3JlLnByb3BlcnR5c3RvcmUuZGIuYXJyYXlz
83
+ - !binary |-
84
+ bGliL2RiL25lb3N0b3JlLnByb3BlcnR5c3RvcmUuZGIuYXJyYXlzLmlk
85
+ - !binary |-
86
+ bGliL2RiL25lb3N0b3JlLnByb3BlcnR5c3RvcmUuZGIuaWQ=
87
+ - !binary |-
88
+ bGliL2RiL25lb3N0b3JlLnByb3BlcnR5c3RvcmUuZGIuaW5kZXg=
89
+ - !binary |-
90
+ bGliL2RiL25lb3N0b3JlLnByb3BlcnR5c3RvcmUuZGIuaW5kZXguaWQ=
91
+ - !binary |-
92
+ bGliL2RiL25lb3N0b3JlLnByb3BlcnR5c3RvcmUuZGIuaW5kZXgua2V5cw==
93
+ - !binary |-
94
+ bGliL2RiL25lb3N0b3JlLnByb3BlcnR5c3RvcmUuZGIuaW5kZXgua2V5cy5p
95
+ ZA==
96
+ - !binary |-
97
+ bGliL2RiL25lb3N0b3JlLnByb3BlcnR5c3RvcmUuZGIuc3RyaW5ncw==
98
+ - !binary |-
99
+ bGliL2RiL25lb3N0b3JlLnByb3BlcnR5c3RvcmUuZGIuc3RyaW5ncy5pZA==
100
+ - !binary |-
101
+ bGliL2RiL25lb3N0b3JlLnJlbGF0aW9uc2hpcHN0b3JlLmRi
102
+ - !binary |-
103
+ bGliL2RiL25lb3N0b3JlLnJlbGF0aW9uc2hpcHN0b3JlLmRiLmlk
104
+ - !binary |-
105
+ bGliL2RiL25lb3N0b3JlLnJlbGF0aW9uc2hpcHR5cGVzdG9yZS5kYg==
106
+ - !binary |-
107
+ bGliL2RiL25lb3N0b3JlLnJlbGF0aW9uc2hpcHR5cGVzdG9yZS5kYi5pZA==
108
+ - !binary |-
109
+ bGliL2RiL25lb3N0b3JlLnJlbGF0aW9uc2hpcHR5cGVzdG9yZS5kYi5uYW1l
110
+ cw==
111
+ - !binary |-
112
+ bGliL2RiL25lb3N0b3JlLnJlbGF0aW9uc2hpcHR5cGVzdG9yZS5kYi5uYW1l
113
+ cy5pZA==
114
+ - !binary |-
115
+ bGliL2RiL25pb25lb19sb2dpY2FsLmxvZy5hY3RpdmU=
116
+ - !binary |-
117
+ bGliL2RiL25pb25lb19sb2dpY2FsLmxvZy52MA==
118
+ - !binary |-
119
+ bGliL2RiL3RtX3R4X2xvZy4x
120
+ - !binary |-
121
+ bGliL2RiL2luZGV4L2x1Y2VuZS1zdG9yZS5kYg==
122
+ - !binary |-
123
+ bGliL2RiL2luZGV4L2x1Y2VuZS5sb2cuYWN0aXZl
124
+ - !binary |-
125
+ bGliL2RiL2luZGV4L2x1Y2VuZS5sb2cudjA=
51
126
  - !binary |-
52
127
  bGliL25lbzRqL2FsZ28ucmI=
53
128
  - !binary |-
54
129
  bGliL25lbzRqL2NvbmZpZy5yYg==
55
130
  - !binary |-
56
- bGliL25lbzRqL2N5cGhlci5yYg==
131
+ bGliL25lbzRqL2NvbmZpZy5yYn4=
57
132
  - !binary |-
58
133
  bGliL25lbzRqL25lbzRqLnJi
59
134
  - !binary |-
@@ -78,9 +153,7 @@ files:
78
153
  - !binary |-
79
154
  bGliL25lbzRqLWNvcmUvdmVyc2lvbi5yYg==
80
155
  - !binary |-
81
- bGliL25lbzRqLWNvcmUvY3lwaGVyL2N5cGhlci5yYg==
82
- - !binary |-
83
- bGliL25lbzRqLWNvcmUvY3lwaGVyL3Jlc3VsdF93cmFwcGVyLnJi
156
+ bGliL25lbzRqLWNvcmUvdmVyc2lvbi5yYn4=
84
157
  - !binary |-
85
158
  bGliL25lbzRqLWNvcmUvZXF1YWwvZXF1YWwucmI=
86
159
  - !binary |-
@@ -131,6 +204,8 @@ files:
131
204
  bGliL25lbzRqLWNvcmUvd3JhcHBlci93cmFwcGVyLnJi
132
205
  - !binary |-
133
206
  Y29uZmlnL25lbzRqL2NvbmZpZy55bWw=
207
+ - !binary |-
208
+ Y29uZmlnL25lbzRqL2NvbmZpZy55bWx+
134
209
  - README.rdoc
135
210
  - Gemfile
136
211
  - neo4j-core.gemspec