neo4j-core 3.0.0.alpha.16 → 3.0.0.alpha.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -37
  3. data/lib/mydb/index/lucene-store.db +0 -0
  4. data/lib/mydb/index/lucene.log.active +0 -0
  5. data/lib/mydb/index/{lucene.log.1 → lucene.log.v0} +0 -0
  6. data/lib/mydb/messages.log +359 -0
  7. data/lib/mydb/neostore +0 -0
  8. data/lib/mydb/neostore.id +0 -0
  9. data/lib/mydb/neostore.labeltokenstore.db +0 -0
  10. data/lib/mydb/neostore.labeltokenstore.db.id +0 -0
  11. data/lib/mydb/neostore.labeltokenstore.db.names +0 -0
  12. data/lib/mydb/neostore.labeltokenstore.db.names.id +0 -0
  13. data/lib/mydb/neostore.nodestore.db +0 -0
  14. data/lib/mydb/neostore.nodestore.db.id +0 -0
  15. data/lib/mydb/neostore.nodestore.db.labels +0 -0
  16. data/lib/mydb/neostore.nodestore.db.labels.id +0 -0
  17. data/lib/mydb/neostore.propertystore.db +0 -0
  18. data/lib/mydb/neostore.propertystore.db.arrays +0 -0
  19. data/lib/mydb/neostore.propertystore.db.arrays.id +0 -0
  20. data/lib/mydb/neostore.propertystore.db.id +0 -0
  21. data/lib/mydb/neostore.propertystore.db.index +0 -0
  22. data/lib/mydb/neostore.propertystore.db.index.id +0 -0
  23. data/lib/mydb/neostore.propertystore.db.index.keys +0 -0
  24. data/lib/mydb/neostore.propertystore.db.index.keys.id +0 -0
  25. data/lib/mydb/neostore.propertystore.db.strings +0 -0
  26. data/lib/mydb/neostore.propertystore.db.strings.id +0 -0
  27. data/lib/mydb/neostore.relationshipgroupstore.db +0 -0
  28. data/lib/mydb/neostore.relationshipgroupstore.db.id +0 -0
  29. data/lib/mydb/neostore.relationshipstore.db +0 -0
  30. data/lib/mydb/neostore.relationshipstore.db.id +0 -0
  31. data/lib/mydb/neostore.relationshiptypestore.db +1 -0
  32. data/lib/mydb/neostore.relationshiptypestore.db.id +0 -0
  33. data/lib/mydb/neostore.relationshiptypestore.db.names +0 -0
  34. data/lib/mydb/neostore.relationshiptypestore.db.names.id +0 -0
  35. data/lib/mydb/neostore.schemastore.db +0 -0
  36. data/lib/mydb/neostore.schemastore.db.id +0 -0
  37. data/lib/mydb/nioneo_logical.log.active +0 -0
  38. data/lib/mydb/nioneo_logical.log.v0 +0 -0
  39. data/lib/mydb/schema/label/lucene/segments.gen +0 -0
  40. data/lib/mydb/schema/label/lucene/segments_1 +0 -0
  41. data/lib/mydb/tm_tx_log.1 +0 -0
  42. data/lib/neo4j-core.rb +1 -1
  43. data/lib/neo4j-core/helpers.rb +1 -1
  44. data/lib/neo4j-core/query.rb +298 -0
  45. data/lib/neo4j-core/query_clauses.rb +476 -0
  46. data/lib/neo4j-core/version.rb +1 -1
  47. data/lib/neo4j-core/version.rb~ +5 -0
  48. data/lib/neo4j-embedded/cypher_response.rb +9 -45
  49. data/lib/neo4j-embedded/embedded_session.rb +15 -17
  50. data/lib/neo4j-server/cypher_node.rb +16 -5
  51. data/lib/neo4j-server/cypher_relationship.rb +24 -6
  52. data/lib/neo4j-server/cypher_response.rb +35 -35
  53. data/lib/neo4j-server/cypher_session.rb +8 -12
  54. data/lib/neo4j/node.rb +4 -4
  55. data/lib/neo4j/session.rb +11 -63
  56. data/lib/neo4j/tasks/neo4j_server.rb +31 -0
  57. metadata +9 -7
  58. data/lib/mydb/lock +0 -0
  59. data/lib/mydb/nioneo_logical.log.1 +0 -0
  60. data/lib/mydb/schema/label/lucene/write.lock +0 -0
  61. data/lib/neo4j-core/query_builder.rb +0 -200
@@ -15,13 +15,44 @@ namespace :neo4j do
15
15
  end
16
16
 
17
17
  unless File.exist?(file_name)
18
+ # check if file is available
19
+ status = HTTParty.head(download_url).code
20
+ raise "#{file} is not available to download, try a different version" if status < 200 || status >= 300
21
+
18
22
  df = File.open(file_name, 'wb')
23
+
24
+
25
+ success = false
19
26
  begin
20
27
  df << HTTParty.get(download_url)
28
+ success = true
21
29
  ensure
22
30
  df.close()
31
+ File.delete(file_name) unless success
23
32
  end
24
33
  end
34
+
35
+
36
+
37
+ # # http://download.neo4j.org/artifact?edition=community&version=2.1.2&distribution=tarball&dlid=3462770&_ga=1.110610309.1220184053.1399636580
38
+ #
39
+ # parsed_url = URI.parse(download_url)
40
+ #
41
+ # puts "parsed_url.host #{parsed_url.host} port #{parsed_url.port} uri: #{parsed_url.request_uri}"
42
+ # Net::HTTP.start(parsed_url.host, parsed_url.port) do |http|
43
+ # request = Net::HTTP::Get.new parsed_url.request_uri
44
+ # http.request request do |response|
45
+ # File.open 'large_file.tar.gz', 'wb' do |io|
46
+ # response.read_body do |chunk|
47
+ # io.write chunk
48
+ # end
49
+ # end
50
+ # end
51
+ # end
52
+ #
53
+ # puts "DOWN LOAD URL #{download_url}, exist #{file_name} : #{File.exist?(file_name)}"
54
+ #
55
+
25
56
  file_name
26
57
  end
27
58
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo4j-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.alpha.16
4
+ version: 3.0.0.alpha.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Ronge
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-07 00:00:00.000000000 Z
11
+ date: 2014-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -81,9 +81,8 @@ files:
81
81
  - README.md
82
82
  - lib/mydb/active_tx_log
83
83
  - lib/mydb/index/lucene-store.db
84
- - lib/mydb/index/lucene.log.1
85
84
  - lib/mydb/index/lucene.log.active
86
- - lib/mydb/lock
85
+ - lib/mydb/index/lucene.log.v0
87
86
  - lib/mydb/messages.log
88
87
  - lib/mydb/neostore
89
88
  - lib/mydb/neostore.id
@@ -115,9 +114,10 @@ files:
115
114
  - lib/mydb/neostore.relationshiptypestore.db.names.id
116
115
  - lib/mydb/neostore.schemastore.db
117
116
  - lib/mydb/neostore.schemastore.db.id
118
- - lib/mydb/nioneo_logical.log.1
119
117
  - lib/mydb/nioneo_logical.log.active
120
- - lib/mydb/schema/label/lucene/write.lock
118
+ - lib/mydb/nioneo_logical.log.v0
119
+ - lib/mydb/schema/label/lucene/segments.gen
120
+ - lib/mydb/schema/label/lucene/segments_1
121
121
  - lib/mydb/store_lock
122
122
  - lib/mydb/tm_tx_log.1
123
123
  - lib/neo4j-core.rb
@@ -125,8 +125,10 @@ files:
125
125
  - lib/neo4j-core/hash_with_indifferent_access.rb
126
126
  - lib/neo4j-core/helpers.rb
127
127
  - lib/neo4j-core/label.rb
128
- - lib/neo4j-core/query_builder.rb
128
+ - lib/neo4j-core/query.rb
129
+ - lib/neo4j-core/query_clauses.rb
129
130
  - lib/neo4j-core/version.rb
131
+ - lib/neo4j-core/version.rb~
130
132
  - lib/neo4j-embedded.rb
131
133
  - lib/neo4j-embedded/cypher_response.rb
132
134
  - lib/neo4j-embedded/cypher_response.rb~
data/lib/mydb/lock DELETED
File without changes
Binary file
File without changes
@@ -1,200 +0,0 @@
1
- module Neo4j::Core
2
-
3
- class QueryBuilder
4
- include CypherTranslator
5
-
6
- DEFAULT_VAR_NAME = :n
7
-
8
- class InvalidQueryError < StandardError;
9
- end
10
-
11
- def initialize(map_return={})
12
- @map_return = map_return
13
- @map_return[:node] = ->(id) { "ID(#{id})" }
14
- end
15
-
16
- # TODO should be moved somewhere else
17
- def self.default_cypher_map_return_procs
18
- {
19
- id_to_node: ->(column) { Neo4j::Node.load(column) },
20
- to_node: ->(column) { column.wrapper }, # for embedded db
21
- value: ->(column) { column },
22
- id_to_rel: ->(column) { Neo4j::Relationship.load(column) },
23
- to_rel: ->(column) { column.wrapper } # for embedded db
24
- }
25
- end
26
-
27
-
28
- def to_query_hash(params, default_map_return)
29
- if params.first.is_a?(Hash)
30
- hash = params.first.clone
31
- hash[:map_return] ||= default_map_return unless hash[:q] || hash[:return]
32
- hash[:map_return] ||= :value if hash[:return].is_a?(Symbol)
33
- return hash
34
- else
35
- hash = (params[1] && params[1].clone) || {}
36
- hash[:q] = params[0]
37
- return hash
38
- end
39
- end
40
-
41
- def to_map_return_procs(query_hash)
42
- map_return_procs = query_hash[:map_return_procs] || self.class.default_cypher_map_return_procs
43
- map_return = query_hash[:map_return]
44
- case map_return
45
- when NilClass
46
- return {}
47
- when Symbol, String
48
- return map_return_procs[map_return.to_sym]
49
- when Hash
50
- map_return.keys.inject({}) do |ack, key|
51
- proc_key = map_return[key]
52
- ack[key] = map_return_procs[proc_key]
53
- raise InvalidQueryError.new("Illegal map_return, '#{ack[key]}' not defined for #{key}") unless ack[key]
54
- ack
55
- end
56
- end
57
- end
58
-
59
- def to_cypher(query_hash)
60
- return query_hash[:q] if query_hash[:q]
61
- match_parts = label_parts(query_hash[:label])
62
- match_parts += match_parts(query_hash[:match])
63
- conditions_parts = conditions_parts(query_hash[:conditions])
64
- conditions_parts += where_parts(query_hash[:where])
65
-
66
- return_parts = return_parts(query_hash)
67
- return_parts += order_parts(query_hash[:order])
68
- return_parts += skip_parts(query_hash[:skip])
69
- return_parts += limit_parts(query_hash[:limit])
70
-
71
- cypher = "MATCH #{match_parts.join(',')}"
72
- cypher += " WHERE #{conditions_parts.join(' AND ')}" if !conditions_parts.empty?
73
- cypher + " RETURN #{return_parts.join(' ')}"
74
- end
75
-
76
-
77
- def order_parts(order)
78
- return [] unless order
79
- cypher = "ORDER BY "
80
-
81
- handleHash = Proc.new do |hash|
82
- if (hash.is_a?(Hash))
83
- k, v = hash.first
84
- raise "only :asc or :desc allowed in order, got #{query.inspect}" unless [:asc, :desc].include?(v)
85
- v.to_sym == :asc ? "#{DEFAULT_VAR_NAME}.`#{k}`" : "#{DEFAULT_VAR_NAME}.`#{k}` DESC"
86
- else
87
- "#{DEFAULT_VAR_NAME}.`#{hash}`" unless hash.is_a?(Hash)
88
- end
89
- end
90
-
91
- case order
92
- when Array
93
- cypher += order.map(&handleHash).join(', ')
94
- when Hash
95
- cypher += handleHash.call(order)
96
- else
97
- cypher += "#{DEFAULT_VAR_NAME}.`#{order}`"
98
- end
99
-
100
- [cypher]
101
- end
102
-
103
- def return_parts(query_hash)
104
- query_hash[:return] ? [cypher_return(query_hash[:return])] : [cypher_default_return(query_hash[:label], query_hash)]
105
- end
106
-
107
- def cypher_return(ret)
108
- case ret
109
- when Array
110
- ret.map { |r| cypher_return_val(r) }.join(',')
111
- when String, Symbol
112
- cypher_return_val(ret)
113
- end
114
-
115
- end
116
-
117
- def cypher_default_return(label, query_hash)
118
- raise InvalidQueryError, "Can't have default return for two labels" if label.is_a?(Hash) && label.key.size > 1
119
- if (query_hash[:map_return] == :id_to_node)
120
- label.is_a?(Hash) ? "ID(#{label.key.first})" : "ID(#{DEFAULT_VAR_NAME})"
121
- elsif (query_hash[:map_return] == :to_node)
122
- label.is_a?(Hash) ? "#{label.key.first}" : "#{DEFAULT_VAR_NAME}"
123
- else
124
- raise InvalidQueryError.new("Don't know how to generate a cypher return #{query_hash.inspect}")
125
- end
126
-
127
- end
128
-
129
-
130
- def where_parts(conditions)
131
- return [] unless conditions
132
- conditions.is_a?(Array) ? conditions : [conditions]
133
- end
134
-
135
- def limit_parts(limit)
136
- return [] unless limit
137
- raise InvalidQueryError.new ":limit value not a number" unless limit.is_a?(Integer)
138
- return ["LIMIT #{limit}"]
139
- end
140
-
141
- def skip_parts(skip)
142
- return [] unless skip
143
- raise InvalidQueryError.new ":skip value not a number" unless skip.is_a?(Integer)
144
- return ["SKIP #{skip}"]
145
- end
146
-
147
- def conditions_parts(conditions)
148
-
149
- return [] unless conditions
150
- neo_id = conditions.delete(:neo_id)
151
- conditions["id(#{as})"] = neo_id if neo_id
152
-
153
- conditions.map do |key, value|
154
- operator, value_string = case value
155
- when Regexp
156
- pattern = (value.casefold? ? "(?i)" : "") + value.source
157
- ['=~', escape_value(pattern.gsub(/\\/, '\\\\\\'))]
158
- else
159
- ['=', escape_value(value)]
160
- end
161
-
162
- k = key.to_s.dup
163
- k = "#{DEFAULT_VAR_NAME}.#{k}" unless k.match(/[\(\.]/)
164
- k + operator + value_string.to_s
165
- end
166
- end
167
-
168
- def label_parts(label)
169
- case label
170
- when NilClass then
171
- []
172
- when Hash
173
- label.map { |variable, label_name| "(#{variable}:`#{label_name}`)" }
174
- else
175
- ["(n:`#{label}`)"]
176
- end
177
- end
178
-
179
-
180
- def match_parts(match)
181
- case match
182
- when Array then
183
- return match
184
- when String then
185
- return [match]
186
- when NilClass
187
- return []
188
- else
189
- raise InvalidQueryError, "Invalid value for 'match' query key #{match.inspect}"
190
- end
191
- end
192
-
193
- def cypher_return_val(val)
194
- val.is_a?(Symbol) ? "#{DEFAULT_VAR_NAME}.`#{val}` AS `#{val}`" : val
195
- end
196
-
197
- end
198
-
199
- end
200
-