neo4j 1.0.0.beta.22-java → 1.0.0.beta.23-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 (40) hide show
  1. data/lib/neo4j.rb +2 -0
  2. data/lib/neo4j/index/class_methods.rb +16 -0
  3. data/lib/neo4j/index/indexer.rb +6 -2
  4. data/lib/neo4j/index/lucene_query.rb +71 -29
  5. data/lib/neo4j/mapping/decl_relationship_dsl.rb +2 -2
  6. data/lib/neo4j/mapping/has_list.rb +21 -2
  7. data/lib/neo4j/mapping/has_n.rb +21 -0
  8. data/lib/neo4j/mapping/node_mixin.rb +1 -0
  9. data/lib/neo4j/node_traverser.rb +19 -0
  10. data/lib/neo4j/rails/finders.rb +115 -114
  11. data/lib/neo4j/version.rb +1 -1
  12. data/lib/tmp/neo4j/index.db +0 -0
  13. data/lib/tmp/neo4j/index/lucene/node/Person-exact/_0.cfs +0 -0
  14. data/lib/tmp/neo4j/index/lucene/node/Person-exact/_1.cfs +0 -0
  15. data/lib/tmp/neo4j/index/lucene/node/Person-exact/segments.gen +0 -0
  16. data/lib/tmp/neo4j/index/lucene/node/Person-exact/segments_3 +0 -0
  17. data/lib/tmp/neo4j/index/lucene/node/Thing-exact/_0.cfs +0 -0
  18. data/lib/tmp/neo4j/index/lucene/node/Thing-exact/segments.gen +0 -0
  19. data/lib/tmp/neo4j/index/lucene/node/Thing-exact/segments_2 +0 -0
  20. data/lib/tmp/neo4j/messages.log +42 -0
  21. data/lib/tmp/neo4j/neostore +0 -0
  22. data/lib/tmp/neo4j/neostore.nodestore.db +0 -0
  23. data/lib/tmp/neo4j/neostore.nodestore.db.id +0 -0
  24. data/lib/tmp/neo4j/neostore.propertystore.db +0 -0
  25. data/lib/tmp/neo4j/neostore.propertystore.db.id +0 -0
  26. data/lib/tmp/neo4j/neostore.propertystore.db.index +0 -0
  27. data/lib/tmp/neo4j/neostore.propertystore.db.index.id +0 -0
  28. data/lib/tmp/neo4j/neostore.propertystore.db.index.keys +0 -0
  29. data/lib/tmp/neo4j/neostore.propertystore.db.index.keys.id +0 -0
  30. data/lib/tmp/neo4j/neostore.propertystore.db.strings +0 -0
  31. data/lib/tmp/neo4j/neostore.propertystore.db.strings.id +0 -0
  32. data/lib/tmp/neo4j/neostore.relationshipstore.db +0 -0
  33. data/lib/tmp/neo4j/neostore.relationshipstore.db.id +0 -0
  34. data/lib/tmp/neo4j/neostore.relationshiptypestore.db +0 -0
  35. data/lib/tmp/neo4j/neostore.relationshiptypestore.db.id +0 -0
  36. data/lib/tmp/neo4j/neostore.relationshiptypestore.db.names +0 -0
  37. data/lib/tmp/neo4j/neostore.relationshiptypestore.db.names.id +0 -0
  38. data/lib/tmp/neo4j/tm_tx_log.1 +0 -0
  39. data/neo4j.gemspec +1 -0
  40. metadata +27 -5
data/lib/neo4j.rb CHANGED
@@ -11,6 +11,8 @@ require 'neo4j/jars/neo4j-lucene-index-0.2-1.2.M04.jar'
11
11
  require 'neo4j/jars/geronimo-jta_1.1_spec-1.1.1.jar'
12
12
  require 'neo4j/jars/lucene-core-3.0.2.jar'
13
13
 
14
+ require 'will_paginate/collection'
15
+ require 'will_paginate/finders/base'
14
16
  require 'neo4j/to_java'
15
17
  require 'neo4j/version'
16
18
  require 'neo4j/equal'
@@ -5,6 +5,22 @@ module Neo4j
5
5
 
6
6
  extend Forwardable
7
7
 
8
+ def wp_query(options, pager, args, &block) #:nodoc:
9
+ params = {}
10
+ params[:page] = pager.current_page
11
+ params[:per_page] = pager.per_page
12
+ query = if args.empty?
13
+ find(options, params, &block)
14
+ else
15
+ args << params.merge(options)
16
+ find(*args, &block)
17
+ end
18
+
19
+ pager.replace [*query]
20
+ pager.total_entries = query.size
21
+ end
22
+
23
+
8
24
  ##
9
25
  # See Neo4j::Index::Indexer#index
10
26
  # Forwards to the indexer that should be used.
@@ -90,7 +90,6 @@ module Neo4j
90
90
  conf.delete :via # avoid endless recursion
91
91
  via_indexer.index(field, conf)
92
92
  else
93
- # raise "Already defined an (via?) index on #{field}, Using the same index for from two classes ? Check index :#{field}, :via => :#{@indexer_for}" if @field_types[field.to_s]
94
93
  @field_types[field.to_s] = conf[:type] || :exact
95
94
  end
96
95
  end
@@ -238,7 +237,12 @@ module Neo4j
238
237
  @decl_props ||= @indexer_for.respond_to?(:_decl_props) && @indexer_for._decl_props
239
238
 
240
239
  index = index_for_type(params[:type] || :exact)
241
- query = (params[:wrapped].nil? || params[:wrapped]) ? LuceneQuery.new(index, @decl_props, query) : index.query(query)
240
+ if query.is_a?(Hash) && (query.include?(:conditions) || query.include?(:sort))
241
+ params.merge! query.except(:conditions)
242
+ query.delete(:sort)
243
+ query = query.delete(:conditions) if query.include?(:conditions)
244
+ end
245
+ query = (params[:wrapped].nil? || params[:wrapped]) ? LuceneQuery.new(index, @decl_props, query, params) : index.query(query)
242
246
 
243
247
  if block_given?
244
248
  begin
@@ -37,17 +37,45 @@ module Neo4j
37
37
  #
38
38
  class LuceneQuery
39
39
  include Enumerable
40
+ include WillPaginate::Finders::Base
40
41
  attr_accessor :left_and_query, :left_or_query
41
-
42
- def initialize(index, decl_props, query)
43
- @index = index
44
- @query = query
42
+
43
+ def initialize(index, decl_props, query, params={})
44
+ @index = index
45
+ @query = query
45
46
  @decl_props = decl_props
47
+ @params = params
48
+
49
+ if params.include?(:sort)
50
+ @order = {}
51
+ params[:sort].each_pair { |k, v| @order[k] = (v == :desc) }
52
+ end
53
+ end
54
+
55
+ def wp_query(options, pager, args, &block) #:nodoc:
56
+ @params[:page] = pager.current_page
57
+ @params[:per_page] = pager.per_page
58
+ pager.replace [*self]
59
+ pager.total_entries = size
46
60
  end
47
61
 
48
62
  # Since we include the Ruby Enumerable mixin we need this method.
49
63
  def each
50
- hits.each { |n| yield n.wrapper }
64
+ if @params.include?(:per_page)
65
+ # paginate the result, used by the will_paginate gem
66
+ page = @params[:page] || 1
67
+ per_page = @params[:per_page]
68
+ to = per_page * page
69
+ from = to - per_page
70
+ i = 0
71
+ hits.each do |node|
72
+ yield node.wrapper if i >= from
73
+ i += 1
74
+ break if i >= to
75
+ end
76
+ else
77
+ hits.each { |n| yield n.wrapper }
78
+ end
51
79
  end
52
80
 
53
81
  # Close hits
@@ -71,7 +99,7 @@ module Neo4j
71
99
  # Does simply loop all search items till the n'th is found.
72
100
  #
73
101
  def [](index)
74
- each_with_index {|node,i| break node if index == i}
102
+ each_with_index { |node, i| break node if index == i }
75
103
  end
76
104
 
77
105
  # Returns the number of search hits
@@ -90,25 +118,30 @@ module Neo4j
90
118
  raise "Expected a symbol. Syntax for range queries example: index(:weight).between(a,b)" unless Symbol === @query
91
119
  raise "Can't only do range queries on Neo4j::NodeMixin, Neo4j::Model, Neo4j::RelationshipMixin" unless @decl_props
92
120
  # check that we perform a range query on the same values as we have declared with the property :key, :type => ...
93
- type = @decl_props[@query] && @decl_props[@query][:type]
121
+ type = @decl_props[@query] && @decl_props[@query][:type]
94
122
  raise "find(#{@query}).between(#{lower}, #{upper}): #{lower} not a #{type}" if type && !type === lower.class
95
123
  raise "find(#{@query}).between(#{lower}, #{upper}): #{upper} not a #{type}" if type && !type === upper.class
96
124
 
97
125
  # Make it possible to convert those values
98
- lower = TypeConverters.convert(lower)
99
- upper = TypeConverters.convert(upper)
100
-
101
- @query = case lower
102
- when Fixnum
103
- org.apache.lucene.search.NumericRangeQuery.new_long_range(@query.to_s, lower, upper, lower_incusive, upper_inclusive)
104
- when Float
105
- org.apache.lucene.search.NumericRangeQuery.new_double_range(@query.to_s, lower, upper, lower_incusive, upper_inclusive)
106
- else
107
- org.apache.lucene.search.TermRangeQuery.new(@query.to_s, lower, upper, lower_incusive, upper_inclusive)
108
- end
126
+ @query = range_query(@query, lower, upper, lower_incusive, upper_inclusive)
109
127
  self
110
128
  end
111
129
 
130
+ def range_query(field, lower, upper, lower_incusive, upper_inclusive)
131
+ lower = TypeConverters.convert(lower)
132
+ upper = TypeConverters.convert(upper)
133
+
134
+ case lower
135
+ when Fixnum
136
+ org.apache.lucene.search.NumericRangeQuery.new_long_range(field.to_s, lower, upper, lower_incusive, upper_inclusive)
137
+ when Float
138
+ org.apache.lucene.search.NumericRangeQuery.new_double_range(field.to_s, lower, upper, lower_incusive, upper_inclusive)
139
+ else
140
+ org.apache.lucene.search.TermRangeQuery.new(field.to_s, lower, upper, lower_incusive, upper_inclusive)
141
+ end
142
+ end
143
+
144
+
112
145
  # Create a compound lucene query.
113
146
  #
114
147
  # ==== Parameters
@@ -119,7 +152,7 @@ module Neo4j
119
152
  # Person.find(:name=>'kalle').and(:age => 3)
120
153
  #
121
154
  def and(query2)
122
- new_query = LuceneQuery.new(@index, @decl_props, query2)
155
+ new_query = LuceneQuery.new(@index, @decl_props, query2)
123
156
  new_query.left_and_query = self
124
157
  new_query
125
158
  end
@@ -145,7 +178,7 @@ module Neo4j
145
178
  and_query
146
179
  end
147
180
 
148
- def build_sort_query(query) #:nodoc:
181
+ def build_sort_query(query) #:nodoc:
149
182
  java_sort_fields = @order.keys.inject([]) do |memo, field|
150
183
  decl_type = @decl_props && @decl_props[field] && @decl_props[field][:type]
151
184
  type = case
@@ -162,19 +195,28 @@ module Neo4j
162
195
  org.neo4j.index.impl.lucene.QueryContext.new(query).sort(sort)
163
196
  end
164
197
 
165
- def build_hash_query(query) #:nodoc:
166
- and_query = org.apache.lucene.search.BooleanQuery.new
198
+ def build_hash_query(query) #:nodoc:
199
+ and_query = org.apache.lucene.search.BooleanQuery.new
167
200
 
168
201
  query.each_pair do |key, value|
169
- raise "Only String values valid in find(hash) got :#{key} => #{value} which is not a String" if !value.is_a?(String) && @decl_props[key] && @decl_props[key][:type] != String
170
- term = org.apache.lucene.index.Term.new(key.to_s, value.to_s)
171
- term_query = org.apache.lucene.search.TermQuery.new(term)
172
- and_query.add(term_query, org.apache.lucene.search.BooleanClause::Occur::MUST)
202
+ type = @decl_props[key.to_sym] && @decl_props[key.to_sym][:type]
203
+ if !type.nil? && type != String
204
+ if Range === value
205
+ and_query.add(range_query(key, value.first, value.last, true, !value.exclude_end?), org.apache.lucene.search.BooleanClause::Occur::MUST)
206
+ else
207
+ and_query.add(range_query(key, value, value, true, true), org.apache.lucene.search.BooleanClause::Occur::MUST)
208
+ end
209
+ else
210
+ conv_value = type ? TypeConverters.convert(value) : value.to_s
211
+ term = org.apache.lucene.index.Term.new(key.to_s, conv_value)
212
+ term_query = org.apache.lucene.search.TermQuery.new(term)
213
+ and_query.add(term_query, org.apache.lucene.search.BooleanClause::Occur::MUST)
214
+ end
173
215
  end
174
216
  and_query
175
217
  end
176
-
177
- def build_query #:nodoc:
218
+
219
+ def build_query #:nodoc:
178
220
  query = @query
179
221
  query = build_hash_query(query) if Hash === query
180
222
  query = build_and_query(query) if @left_and_query
@@ -182,7 +224,7 @@ module Neo4j
182
224
  query
183
225
  end
184
226
 
185
- def perform_query #:nodoc:
227
+ def perform_query #:nodoc:
186
228
  @index.query(build_query)
187
229
  end
188
230
  end
@@ -51,11 +51,11 @@ module Neo4j::Mapping
51
51
  @has_one
52
52
  end
53
53
 
54
- def each_node(node, direction, &block) #:nodoc:
54
+ def each_node(node, direction, raw = false, &block) #:nodoc:
55
55
  type = type_to_java(rel_type)
56
56
  dir = dir_to_java(direction)
57
57
  node._java_node.getRelationships(type, dir).each do |rel|
58
- other = rel.getOtherNode(node).wrapper
58
+ other = raw ? rel.getOtherNode(node) : rel.getOtherNode(node).wrapper
59
59
  block.call other
60
60
  end
61
61
  end
@@ -34,6 +34,8 @@ module Neo4j
34
34
  class HasList
35
35
  include Enumerable
36
36
  include ToJava
37
+ include WillPaginate::Finders::Base
38
+
37
39
 
38
40
  def initialize(node, name)
39
41
  @time_line = org.neo4j.index.timeline.Timeline.new(name, node._java_node, true, Neo4j.started_db.graph)
@@ -102,12 +104,29 @@ module Neo4j
102
104
  # person.feeds.each {|node| node}
103
105
  #
104
106
  def each
105
- @time_line.all_nodes.iterator.each { |node|
107
+ @time_line.all_nodes.iterator.each do |node|
106
108
  if @raw then
107
109
  yield node
108
110
  else
109
111
  yield node.wrapper
110
- end }
112
+ end
113
+ end
114
+ end
115
+
116
+ def wp_query(options, pager, args, &block) #:nodoc:
117
+ @raw = true
118
+ page = pager.current_page || 1
119
+ to = pager.per_page * page
120
+ from = to - pager.per_page
121
+ i = 0
122
+ res = []
123
+ each do |node|
124
+ res << node.wrapper if i >= from
125
+ i += 1
126
+ break if i >= to
127
+ end
128
+ pager.replace res
129
+ pager.total_entries ||= size
111
130
  end
112
131
 
113
132
  # If called then it will only return the raw java nodes and not the Ruby wrappers using the Neo4j::NodeMixin
@@ -12,6 +12,8 @@ module Neo4j
12
12
  #
13
13
  class HasN
14
14
  include Enumerable
15
+ include WillPaginate::Finders::Base
16
+
15
17
  include ToJava
16
18
 
17
19
  def initialize(node, dsl) # :nodoc:
@@ -46,6 +48,25 @@ module Neo4j
46
48
  @dsl.each_node(@node, @direction, &block)
47
49
  end
48
50
 
51
+ # returns none wrapped nodes, you may get better performance using this method
52
+ def _each(&block)
53
+ @dsl.each_node(@node, @direction, true, &block)
54
+ end
55
+
56
+ def wp_query(options, pager, args, &block) #:nodoc:
57
+ page = pager.current_page || 1
58
+ to = pager.per_page * page
59
+ from = to - pager.per_page
60
+ i = 0
61
+ res = []
62
+ _each do |node|
63
+ res << node.wrapper if i >= from
64
+ i += 1
65
+ break if i >= to
66
+ end
67
+ pager.replace res
68
+ pager.total_entries ||= self.size # TODO, this could be very slow to do
69
+ end
49
70
 
50
71
  # Returns true if there are no node in this type of relationship
51
72
  def empty?
@@ -95,6 +95,7 @@ module Neo4j::Mapping
95
95
  c.extend ClassMethods::Rule
96
96
  c.extend ClassMethods::List
97
97
  c.extend Neo4j::Index::ClassMethods
98
+ c.extend WillPaginate::Finders::Base
98
99
 
99
100
  def c.inherited(subclass)
100
101
  # inherit the index properties
@@ -37,6 +37,8 @@ module Neo4j
37
37
  class NodeTraverser
38
38
  include Enumerable
39
39
  include ToJava
40
+ include WillPaginate::Finders::Base
41
+
40
42
 
41
43
  def initialize(from, type = nil, dir=nil)
42
44
  @from = from
@@ -55,6 +57,23 @@ module Neo4j
55
57
  "NodeTraverser [from: #{@from.neo_id} depth: #{@depth} type: #{@type} dir:#{@dir}"
56
58
  end
57
59
 
60
+
61
+ def wp_query(options, pager, args, &block) #:nodoc:
62
+ page = pager.current_page || 1
63
+ per_page = pager.per_page
64
+ to = per_page * page
65
+ from = to - per_page
66
+ i = 0
67
+ res = []
68
+ iterator.each do |node|
69
+ res << node.wrapper if i >= from
70
+ i += 1
71
+ break if i >= to
72
+ end
73
+ pager.replace res
74
+ pager.total_entries ||= size # TODO, this could be very slow to do
75
+ end
76
+
58
77
  def <<(other_node)
59
78
  new(other_node)
60
79
  self
@@ -1,17 +1,17 @@
1
1
  module Neo4j
2
- module Rails
3
- module Finders
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- rule :_all
8
- end
9
-
10
- module ClassMethods
11
- # overwrite the index method to add find_by_xxx class methods
12
- def index(*args)
13
- field = args.first
14
- module_eval <<-RUBY, __FILE__, __LINE__
2
+ module Rails
3
+ module Finders
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ rule :_all
8
+ end
9
+
10
+ module ClassMethods
11
+ # overwrite the index method to add find_by_xxx class methods
12
+ def index(*args)
13
+ field = args.first
14
+ module_eval <<-RUBY, __FILE__, __LINE__
15
15
  def self.all_by_#{field}(value)
16
16
  find_with_indexer("#{field}: \\"\#{value}\\"")
17
17
  end
@@ -19,13 +19,13 @@ module Neo4j
19
19
  def self.find_by_#{field}(value)
20
20
  all_by_#{field}(value).first
21
21
  end
22
- RUBY
23
-
24
- super
25
- end
26
-
27
- # load an id or array of ids from the database
28
- def load(*ids)
22
+ RUBY
23
+
24
+ super
25
+ end
26
+
27
+ # load an id or array of ids from the database
28
+ def load(*ids)
29
29
  result = ids.map { |id| Neo4j::Node.load(id) }
30
30
  if ids.length == 1
31
31
  result.first
@@ -33,102 +33,103 @@ module Neo4j
33
33
  result
34
34
  end
35
35
  end
36
-
37
- # Behave like the ActiveRecord query interface
38
-
39
- # Handle Model.find(params[:id])
40
-
41
- # Model.find
42
- # Model.find(:first)
43
-
44
- # Model.find("1")
45
- # Model.find(1)
46
-
47
- # Model.find("name: test")
48
- # Model.find(:name => "test")
49
-
50
- # Model.find(:first, "name: test")
51
- # Model.find(:first, { :name => "test" })
52
-
53
- # Model.find(:first, :conditions => "name: test")
54
- # Model.find(:first, :conditions => { :name => "test" })
55
-
56
- # Model.find(:all, "name: test")
57
- # Model.find(:all, { :name => "test" })
58
-
59
- # Model.find(:all, :conditions => "name: test")
60
- # Model.find(:all, :conditions => { :name => "test" })
36
+
37
+ # Behave like the ActiveRecord query interface
38
+ #
39
+ # === Example
40
+ #
41
+ # Handle Model.find(params[:id])
42
+ # Model.find
43
+ # Model.find(:first)
44
+ # Model.find("1")
45
+ # Model.find(1)
46
+ # Model.find("name: test")
47
+ # Model.find(:name => "test")
48
+ # Model.find(:first, "name: test")
49
+ # Model.find(:first, { :name => "test" })
50
+ # Model.find(:first, :conditions => "name: test")
51
+ # Model.find(:first, :conditions => { :name => "test" })
52
+ # Model.find(:all, "name: test")
53
+ # Model.find(:all, { :name => "test" })
54
+ # Model.find(:all, :conditions => "name: test")
55
+ # Model.find(:all, :conditions => { :name => "test" })
56
+ #
61
57
  def find(*args)
62
- case args.first
63
- when :all, :first
64
- kind = args.shift
65
- send(kind, *args)
66
- else
67
- find_with_ids(*args) or first(*args)
68
- end
58
+ case args.first
59
+ when :all, :first
60
+ kind = args.shift
61
+ send(kind, *args)
62
+ else
63
+ find_with_ids(*args) or first(*args)
64
+ end
69
65
  end
70
-
71
- def all(*args)
72
- args = normalize_args(*args)
73
- if args.empty?
74
- # use the _all rule to recover all the stored instances of this node
75
- _all
76
- else
77
- # handle the special case of a search by id
78
- if args.first.is_a?(Hash) && args.first[:id]
79
- [find_with_ids(args.first[:id])].flatten
80
- else
81
- find_with_indexer(*args)
82
- end
83
- end
84
- end
85
-
86
- def first(*args)
87
- all(*args).first
88
- end
89
-
90
- def last(*args)
91
- a = all(*args)
92
- a.empty? ? nil : a[a.size - 1]
93
- end
94
-
95
- def count
96
- all.size
97
- end
98
-
99
- protected
100
- def find_with_ids(*args)
101
- if ((args.first.is_a?(String) || args.first.is_a?(Integer)) && args.first.to_i > 0)
102
- load(*args.map { |p| p.to_i })
103
- end
104
- end
105
-
106
- def find_with_indexer(*args)
107
- hits = _indexer.find(*args)
108
- # We need to save this so that the Rack Neo4j::Rails:LuceneConnection::Closer can close it
109
- Thread.current[:neo4j_lucene_connection] ||= []
110
- Thread.current[:neo4j_lucene_connection] << hits
111
- hits
112
- end
113
-
114
- def normalize_args(*args)
115
- options = args.extract_options!
116
-
117
- if options.present?
118
-
119
- # TODO: Handle order
120
- options.delete(:order)
121
-
122
- if options[:conditions]
123
- args << options[:conditions] if options[:conditions].present?
124
- else
125
- args << options if options.present?
126
- end
127
- end
128
- args
129
- end
66
+
67
+ def all(*args)
68
+ if !conditions_in?(*args)
69
+ # use the _all rule to recover all the stored instances of this node
70
+ _all
71
+ else
72
+ # handle the special case of a search by id
73
+ ids = ids_in(args.first)
74
+ if ids
75
+ [find_with_ids(ids)].flatten
76
+ else
77
+ find_with_indexer(*args)
78
+ end
79
+ end
80
+ end
81
+
82
+ def first(*args)
83
+ all(*args).first
84
+ end
85
+
86
+ def last(*args)
87
+ a = all(*args)
88
+ a.empty? ? nil : a[a.size - 1]
89
+ end
90
+
91
+ def count
92
+ all.size
93
+ end
94
+
95
+ protected
96
+
97
+ def ids_in(arg)
98
+ return nil unless arg.is_a?(Hash)
99
+ arg[:conditions].present? ? arg[:conditions][:id] : arg[:id]
100
+ end
101
+
102
+
103
+ def conditions_in?(*args)
104
+ return false if args.empty?
105
+
106
+ # does it contain an string, which will be treated like a condition ?
107
+ return true if args.find { |a| a.is_a?(String) }
108
+
109
+ # does it contain an empty conditions param ?
110
+ hash = args.find { |a| a.is_a?(Hash) }
111
+ return false if hash.include?(:conditions) && hash[:conditions].empty?
112
+
113
+ # does it contain only paging or sorting params ?
114
+ !hash.except(:sort, :page, :per_page).empty?
115
+ end
116
+
117
+ def find_with_ids(*args)
118
+ if ((args.first.is_a?(String) || args.first.is_a?(Integer)) && args.first.to_i > 0)
119
+ load(*args.map { |p| p.to_i })
120
+ end
121
+ end
122
+
123
+ def find_with_indexer(*args)
124
+ hits = _indexer.find(*args)
125
+ # We need to save this so that the Rack Neo4j::Rails:LuceneConnection::Closer can close it
126
+ Thread.current[:neo4j_lucene_connection] ||= []
127
+ Thread.current[:neo4j_lucene_connection] << hits
128
+ hits
129
+ end
130
+
130
131
  end
131
- end
132
- end
132
+ end
133
+ end
133
134
  end
134
135
 
data/lib/neo4j/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Neo4j
2
- VERSION = "1.0.0.beta.22"
2
+ VERSION = "1.0.0.beta.23"
3
3
  end
Binary file
@@ -132,3 +132,45 @@ Thu Nov 25 14:38:03 CET 2010: Closed log tmp/neo4j/lucene/lucene.log
132
132
  Thu Nov 25 14:38:03 CET 2010: NeoStore closed
133
133
  Thu Nov 25 14:38:03 CET 2010: Closed log tmp/neo4j/lucene-fulltext/lucene.log
134
134
  Thu Nov 25 14:38:03 CET 2010: TM shutting down
135
+ Thu Dec 02 10:15:07 CET 2010: Opened [tmp/neo4j/nioneo_logical.log.1] clean empty log, version=0
136
+ Thu Dec 02 10:15:07 CET 2010: Opened [tmp/neo4j/lucene/lucene.log.1] clean empty log, version=0
137
+ Thu Dec 02 10:15:07 CET 2010: Opened [tmp/neo4j/lucene-fulltext/lucene.log.1] clean empty log, version=0
138
+ Thu Dec 02 10:15:07 CET 2010: Opened [/home/andreas/projects/neo4j/lib/tmp/neo4j/index/lucene.log.1] clean empty log, version=0
139
+ Thu Dec 02 10:15:07 CET 2010: Extension org.neo4j.graphdb.index.IndexProvider[lucene] initialized ok
140
+ Thu Dec 02 10:15:07 CET 2010: TM opening log: tmp/neo4j/tm_tx_log.1
141
+ Thu Dec 02 10:15:07 CET 2010: --- CONFIGURATION START ---
142
+ Thu Dec 02 10:15:07 CET 2010: Physical mem: 4017MB, Heap size: 483MB
143
+ Thu Dec 02 10:15:07 CET 2010: Kernel version: Neo4j - Graph Database Kernel 1.2-1.2.M04
144
+ Thu Dec 02 10:15:07 CET 2010: Operating System: Linux; version: 2.6.32-26-generic-pae; arch: i386
145
+ Thu Dec 02 10:15:07 CET 2010: VM Name: Java HotSpot(TM) Client VM
146
+ Thu Dec 02 10:15:07 CET 2010: VM Vendor: Sun Microsystems Inc.
147
+ Thu Dec 02 10:15:07 CET 2010: VM Version: 17.1-b03
148
+ Thu Dec 02 10:15:07 CET 2010: Boot Class Path: /usr/lib/jvm/java-6-sun-1.6.0.22/jre/lib/resources.jar:/usr/lib/jvm/java-6-sun-1.6.0.22/jre/lib/rt.jar:/usr/lib/jvm/java-6-sun-1.6.0.22/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-6-sun-1.6.0.22/jre/lib/jsse.jar:/usr/lib/jvm/java-6-sun-1.6.0.22/jre/lib/jce.jar:/usr/lib/jvm/java-6-sun-1.6.0.22/jre/lib/charsets.jar:/usr/lib/jvm/java-6-sun-1.6.0.22/jre/classes:/home/andreas/.rvm/rubies/jruby-1.5.5/lib/jruby.jar
149
+ Thu Dec 02 10:15:07 CET 2010: Class Path: :
150
+ Thu Dec 02 10:15:07 CET 2010: Library Path: /usr/lib/jvm/java-6-sun-1.6.0.22/jre/lib/i386/client:/usr/lib/jvm/java-6-sun-1.6.0.22/jre/lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.22/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib
151
+ Thu Dec 02 10:15:07 CET 2010: Garbage Collector: Copy: [Eden Space, Survivor Space]
152
+ Thu Dec 02 10:15:07 CET 2010: Garbage Collector: MarkSweepCompact: [Eden Space, Survivor Space, Tenured Gen, Perm Gen, Perm Gen [shared-ro], Perm Gen [shared-rw]]
153
+ Thu Dec 02 10:15:07 CET 2010: VM Arguments: [-Djruby.memory.max=500m, -Djruby.stack.max=1024k, -Xmx500m, -Xss1024k, -Djffi.boot.library.path=/home/andreas/.rvm/rubies/jruby-1.5.5/lib/native/i386-Linux:/home/andreas/.rvm/rubies/jruby-1.5.5/lib/native/ppc-Linux:/home/andreas/.rvm/rubies/jruby-1.5.5/lib/native/x86_64-Linux, -Xbootclasspath/a:/home/andreas/.rvm/rubies/jruby-1.5.5/lib/jruby.jar, -Djruby.home=/home/andreas/.rvm/rubies/jruby-1.5.5, -Djruby.lib=/home/andreas/.rvm/rubies/jruby-1.5.5/lib, -Djruby.script=jruby, -Djruby.shell=/bin/sh]
154
+ Thu Dec 02 10:15:07 CET 2010:
155
+ Thu Dec 02 10:15:07 CET 2010: create=true
156
+ Thu Dec 02 10:15:07 CET 2010: dir=tmp/neo4j/lucene-fulltext
157
+ Thu Dec 02 10:15:07 CET 2010: logical_log=tmp/neo4j/nioneo_logical.log
158
+ Thu Dec 02 10:15:07 CET 2010: neo_store=tmp/neo4j/neostore
159
+ Thu Dec 02 10:15:07 CET 2010: neostore.nodestore.db.mapped_memory=20M
160
+ Thu Dec 02 10:15:07 CET 2010: neostore.propertystore.db.arrays.mapped_memory=130M
161
+ Thu Dec 02 10:15:07 CET 2010: neostore.propertystore.db.index.keys.mapped_memory=1M
162
+ Thu Dec 02 10:15:07 CET 2010: neostore.propertystore.db.index.mapped_memory=1M
163
+ Thu Dec 02 10:15:07 CET 2010: neostore.propertystore.db.mapped_memory=90M
164
+ Thu Dec 02 10:15:07 CET 2010: neostore.propertystore.db.strings.mapped_memory=130M
165
+ Thu Dec 02 10:15:07 CET 2010: neostore.relationshipstore.db.mapped_memory=100M
166
+ Thu Dec 02 10:15:07 CET 2010: rebuild_idgenerators_fast=true
167
+ Thu Dec 02 10:15:07 CET 2010: store_dir=tmp/neo4j
168
+ Thu Dec 02 10:15:07 CET 2010: --- CONFIGURATION END ---
169
+ Thu Dec 02 10:15:07 CET 2010: Extension org.neo4j.graphdb.index.IndexProvider[lucene] loaded ok
170
+ Thu Dec 02 11:54:16 CET 2010: Closed log tmp/neo4j/nioneo_logical.log
171
+ Thu Dec 02 11:54:16 CET 2010: NeoStore closed
172
+ Thu Dec 02 11:54:16 CET 2010: Closed log /home/andreas/projects/neo4j/lib/tmp/neo4j/index/lucene.log
173
+ Thu Dec 02 11:54:16 CET 2010: Closed log tmp/neo4j/lucene/lucene.log
174
+ Thu Dec 02 11:54:16 CET 2010: NeoStore closed
175
+ Thu Dec 02 11:54:16 CET 2010: Closed log tmp/neo4j/lucene-fulltext/lucene.log
176
+ Thu Dec 02 11:54:16 CET 2010: TM shutting down
Binary file
Binary file
Binary file
Binary file
data/neo4j.gemspec CHANGED
@@ -27,5 +27,6 @@ EOF
27
27
  s.required_ruby_version = ">= 1.8.7"
28
28
  s.add_dependency('orm_adapter',">= 0.0.3")
29
29
  s.add_dependency("activemodel", ">= 3.0.0")
30
+ s.add_dependency("will_paginate", ["~>3.0.pre"])
30
31
  s.add_dependency("railties", ">= 3.0.0")
31
32
  end
metadata CHANGED
@@ -7,8 +7,8 @@ version: !ruby/object:Gem::Version
7
7
  - 0
8
8
  - 0
9
9
  - beta
10
- - 22
11
- version: 1.0.0.beta.22
10
+ - 23
11
+ version: 1.0.0.beta.23
12
12
  platform: java
13
13
  authors:
14
14
  - Andreas Ronge
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-11-25 00:00:00 +01:00
19
+ date: 2010-12-03 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -48,9 +48,23 @@ dependencies:
48
48
  type: :runtime
49
49
  version_requirements: *id002
50
50
  - !ruby/object:Gem::Dependency
51
- name: railties
51
+ name: will_paginate
52
52
  prerelease: false
53
53
  requirement: &id003 !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 3
59
+ - 0
60
+ - pre
61
+ version: 3.0.pre
62
+ type: :runtime
63
+ version_requirements: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ name: railties
66
+ prerelease: false
67
+ requirement: &id004 !ruby/object:Gem::Requirement
54
68
  requirements:
55
69
  - - ">="
56
70
  - !ruby/object:Gem::Version
@@ -60,7 +74,7 @@ dependencies:
60
74
  - 0
61
75
  version: 3.0.0
62
76
  type: :runtime
63
- version_requirements: *id003
77
+ version_requirements: *id004
64
78
  description: "You can think of Neo4j as a high-performance graph engine with all the features of a mature and robust database.\n\
65
79
  The programmer works with an object-oriented, flexible network structure rather than with strict and static tables \xE2\x80\x94 yet enjoys all the benefits of a fully transactional, enterprise-strength database.\n\
66
80
  It comes included with the Apache Lucene document database.\n"
@@ -96,6 +110,7 @@ files:
96
110
  - lib/tmp/neo4j/neostore.relationshipstore.db
97
111
  - lib/tmp/neo4j/neostore.propertystore.db.index.id
98
112
  - lib/tmp/neo4j/neostore.propertystore.db.id
113
+ - lib/tmp/neo4j/index.db
99
114
  - lib/tmp/neo4j/neostore.propertystore.db
100
115
  - lib/tmp/neo4j/tm_tx_log.1
101
116
  - lib/tmp/neo4j/neostore.relationshiptypestore.db
@@ -105,6 +120,13 @@ files:
105
120
  - lib/tmp/neo4j/lucene-fulltext/lucene.log.active
106
121
  - lib/tmp/neo4j/index/lucene-store.db
107
122
  - lib/tmp/neo4j/index/lucene.log.active
123
+ - lib/tmp/neo4j/index/lucene/node/Person-exact/segments.gen
124
+ - lib/tmp/neo4j/index/lucene/node/Person-exact/_1.cfs
125
+ - lib/tmp/neo4j/index/lucene/node/Person-exact/_0.cfs
126
+ - lib/tmp/neo4j/index/lucene/node/Person-exact/segments_3
127
+ - lib/tmp/neo4j/index/lucene/node/Thing-exact/segments.gen
128
+ - lib/tmp/neo4j/index/lucene/node/Thing-exact/segments_2
129
+ - lib/tmp/neo4j/index/lucene/node/Thing-exact/_0.cfs
108
130
  - lib/tmp/neo4j/lucene/lucene-store.db
109
131
  - lib/tmp/neo4j/lucene/lucene.log.active
110
132
  - lib/neo4j/event_handler.rb