pacer 1.4.2-java → 1.5.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +20 -1
  3. data/README.md +29 -15
  4. data/Rakefile +0 -1
  5. data/lib/pacer/core/graph/edges_route.rb +5 -5
  6. data/lib/pacer/core/graph/vertices_route.rb +7 -7
  7. data/lib/pacer/core/route.rb +39 -23
  8. data/lib/pacer/filter/collection_filter.rb +6 -5
  9. data/lib/pacer/filter/empty_filter.rb +1 -0
  10. data/lib/pacer/filter/loop_filter.rb +13 -2
  11. data/lib/pacer/filter/property_filter.rb +1 -1
  12. data/lib/pacer/filter/property_filter/filters.rb +1 -1
  13. data/lib/pacer/filter/uniq_section.rb +56 -0
  14. data/lib/pacer/filter/where_filter/node_visitor.rb +13 -12
  15. data/lib/pacer/graph/graph_ml.rb +4 -2
  16. data/lib/pacer/graph/graph_transactions_mixin.rb +26 -0
  17. data/lib/pacer/graph/pacer_graph.rb +1 -1
  18. data/lib/pacer/loader.rb +2 -1
  19. data/lib/pacer/pipe/collection_filter_pipe.rb +2 -0
  20. data/lib/pacer/pipe/id_collection_filter_pipe.rb +12 -2
  21. data/lib/pacer/pipe/loop_pipe.rb +1 -1
  22. data/lib/pacer/pipe/property_comparison_pipe.rb +6 -6
  23. data/lib/pacer/pipes.rb +5 -4
  24. data/lib/pacer/route/mixin/bulk_operations.rb +22 -21
  25. data/lib/pacer/support/enumerable.rb +0 -4
  26. data/lib/pacer/transform/identity.rb +10 -0
  27. data/lib/pacer/transform/lookup_ids.rb +2 -2
  28. data/lib/pacer/version.rb +3 -4
  29. data/lib/pacer/wrappers/edge_wrapper.rb +3 -1
  30. data/lib/pacer/wrappers/element_wrapper.rb +5 -3
  31. data/lib/pacer/wrappers/vertex_wrapper.rb +8 -2
  32. data/pom.xml +3 -30
  33. data/spec/pacer/blueprints/neo4j2_spec.rb +62 -0
  34. data/spec/pacer/blueprints/neo4j_spec.rb +6 -4
  35. data/spec/pacer/core/graph/graph_route_spec.rb +11 -3
  36. data/spec/pacer/core/route_spec.rb +1 -1
  37. data/spec/pacer/filter/empty_filter_spec.rb +1 -1
  38. data/spec/pacer/route/mixin/bulk_operations_spec.rb +11 -3
  39. data/spec/pacer/wrapper/element_wrapper_spec.rb +15 -15
  40. data/spec/pacer/wrapper/vertex_wrapper_spec.rb +4 -4
  41. data/spec/spec_helper.rb +5 -4
  42. data/spec/support/graph_runner.rb +11 -0
  43. data/spec/support/use_transactions.rb +4 -0
  44. metadata +7 -4
  45. data/lib/pacer/support/array.rb +0 -18
@@ -30,12 +30,14 @@ module NeoSpec
30
30
 
31
31
  describe 'indexed' do
32
32
  before do
33
- graph.create_key_index :type, :vertex
34
- graph.create_key_index :name, :vertex
33
+ # TODO FIXME: why do the presence of these key indices break lots of
34
+ # subsequent tests if they are on graph rather than graph2?
35
+ graph2.create_key_index :type, :vertex
36
+ graph2.create_key_index :name, :vertex
35
37
  end
36
38
 
37
39
  describe Person do
38
- subject { graph.v(Person) }
40
+ subject { graph2.v(Person) }
39
41
 
40
42
  # sanity checks
41
43
  it { should be_a Pacer::Filter::LuceneFilter }
@@ -47,7 +49,7 @@ module NeoSpec
47
49
  end
48
50
 
49
51
  describe Frog do
50
- subject { graph.v(Frog) }
52
+ subject { graph2.v(Frog) }
51
53
 
52
54
  # sanity checks
53
55
  it { should_not be_a Pacer::Filter::LuceneFilter }
@@ -31,12 +31,20 @@ Run.all(:read_only, false) do
31
31
 
32
32
  context 'with vertex name indexed' do
33
33
  before :all do
34
- graph.v.build_index :name if graph
35
- graph.search_manual_indices = true if graph
34
+ if graph
35
+ graph.transaction do
36
+ graph.v.build_index :name
37
+ end
38
+ graph.search_manual_indices = true
39
+ end
36
40
  end
37
41
 
38
42
  after :all do
39
- graph.drop_index :name if graph
43
+ if graph
44
+ graph.transaction do
45
+ graph.drop_index :name
46
+ end
47
+ end
40
48
  end
41
49
 
42
50
  context 'basic search' do
@@ -68,7 +68,7 @@ describe Pacer::Core::Route do
68
68
  end
69
69
  specify '2 item limit' do
70
70
  Pacer.inspect_limit = 2
71
- dont_allow(base_route).puts(anything)
71
+ mock(base_route).puts("Total: > 2 (Pacer.inspect_limit)")
72
72
  base_route.inspect.should == '#<Obj>'
73
73
  end
74
74
  end
@@ -21,7 +21,7 @@ Run.tg(:read_only) do
21
21
  it 'should create a pipeline with only the pipe added to it' do
22
22
  start_pipe, end_pipe = subject.send :build_pipeline
23
23
  start_pipe.should == end_pipe
24
- start_pipe.should be_a Java::ComTinkerpopGremlinPipesFilter::PropertyFilterPipe
24
+ start_pipe.should be_a Java::ComTinkerpopPipesFilter::PropertyFilterPipe
25
25
  end
26
26
  end
27
27
  end
@@ -4,7 +4,11 @@ Run.all do
4
4
  use_pacer_graphml_data
5
5
 
6
6
  describe RouteOperations, :transactions => false do
7
- before { setup_data }
7
+ before do
8
+ graph.transaction do
9
+ setup_data
10
+ end
11
+ end
8
12
 
9
13
  describe '#bulk_job', :transactions => false do
10
14
  context 'commit every 2nd record, updating all vertices' do
@@ -13,7 +17,9 @@ Run.all do
13
17
  graph.v(Tackle::SimpleMixin).bulk_job(2) do |v|
14
18
  v[:updated] = 'yes'
15
19
  end
16
- graph.v(:updated => 'yes').count.should == 7
20
+ graph.read_transaction do
21
+ graph.v(:updated => 'yes').count.should == 7
22
+ end
17
23
  end
18
24
  end
19
25
 
@@ -21,7 +27,9 @@ Run.all do
21
27
  graph.v.bulk_job(2) do |v|
22
28
  v[:updated] = 'yup'
23
29
  end
24
- graph.v(:updated => 'yup').count.should == 7
30
+ graph.read_transaction do
31
+ graph.v(:updated => 'yup').count.should == 7
32
+ end
25
33
  end
26
34
  end
27
35
  end
@@ -91,7 +91,7 @@ shared_examples_for Pacer::Wrappers::ElementWrapper do
91
91
  it { should be_a(Pacer::Wrappers::EdgeWrapper) }
92
92
  it { should_not be_a(Pacer::Wrappers::VertexWrapper) }
93
93
 
94
- describe '#e', :transactions => false do
94
+ describe '#e', :transactions => false, read_transaction: true do
95
95
  context '()' do
96
96
  subject { e0.e }
97
97
  its(:to_a) { should == [e0] }
@@ -124,7 +124,7 @@ shared_examples_for Pacer::Wrappers::ElementWrapper do
124
124
  end
125
125
  end
126
126
 
127
- describe '#eql?', :transactions => false do
127
+ describe '#eql?', :transactions => false, read_transaction: true do
128
128
  subject { Hash.new(0) }
129
129
  before do
130
130
  subject[e0] += 1
@@ -223,7 +223,7 @@ shared_examples_for Pacer::Wrappers::ElementWrapper do
223
223
  end
224
224
  end
225
225
 
226
- describe '#result', :transactions => false do
226
+ describe '#result', :transactions => false, read_transaction: true do
227
227
  subject { element.result }
228
228
  it { should equal(element) }
229
229
  end
@@ -287,22 +287,22 @@ end
287
287
 
288
288
  Run.all do
289
289
  it_uses Pacer::Wrappers::ElementWrapper do
290
- let(:v0) { graph.create_vertex :name => 'eliza' }
291
- let(:v1) { graph.create_vertex :name => 'darrick' }
292
- let(:e0) { graph.create_edge nil, v0, v1, :links }
293
- let(:e1) { graph.create_edge nil, v0, v1, :relinks }
290
+ let(:v0) { graph.transaction(nesting: true) { graph.create_vertex :name => 'eliza' } }
291
+ let(:v1) { graph.transaction(nesting: true) { graph.create_vertex :name => 'darrick' } }
292
+ let(:e0) { graph.transaction(nesting: true) { graph.create_edge nil, v0, v1, :links } }
293
+ let(:e1) { graph.transaction(nesting: true) { graph.create_edge nil, v0, v1, :relinks } }
294
294
  end
295
295
 
296
296
  context 'vertex' do
297
- let(:v0) { graph.create_vertex :name => 'eliza' }
297
+ let(:v0) { graph.transaction(nesting: true) { graph.create_vertex :name => 'eliza' } }
298
298
  subject { v0 }
299
299
  its(:class) { should == graph.base_vertex_wrapper }
300
300
  end
301
301
 
302
302
  context 'edge' do
303
- let(:v0) { graph.create_vertex :name => 'eliza' }
304
- let(:v1) { graph.create_vertex :name => 'darrick' }
305
- let(:e0) { graph.create_edge nil, v0, v1, :links }
303
+ let(:v0) { graph.transaction(nesting: true) { graph.create_vertex :name => 'eliza' } }
304
+ let(:v1) { graph.transaction(nesting: true) { graph.create_vertex :name => 'darrick' } }
305
+ let(:e0) { graph.transaction(nesting: true) { graph.create_edge nil, v0, v1, :links } }
306
306
  subject { e0 }
307
307
  its(:class) { should == graph.base_edge_wrapper }
308
308
  end
@@ -312,10 +312,10 @@ Run.all do
312
312
  # that wrappers act the same as native elements
313
313
  describe 'wrapped elements' do
314
314
  it_uses Pacer::Wrappers::ElementWrapper do
315
- let(:v0) { graph.create_vertex(Tackle::SimpleMixin, :name => 'eliza') }
316
- let(:v1) { graph.create_vertex(Tackle::SimpleMixin, :name => 'darrick') }
317
- let(:e0) { graph.create_edge nil, v0, v1, :links, Tackle::SimpleMixin }
318
- let(:e1) { graph.create_edge nil, v0, v1, :relinks, Tackle::SimpleMixin }
315
+ let(:v0) { graph.transaction(nesting: true) { graph.create_vertex(Tackle::SimpleMixin, :name => 'eliza') } }
316
+ let(:v1) { graph.transaction(nesting: true) { graph.create_vertex(Tackle::SimpleMixin, :name => 'darrick') } }
317
+ let(:e0) { graph.transaction(nesting: true) { graph.create_edge nil, v0, v1, :links, Tackle::SimpleMixin } }
318
+ let(:e1) { graph.transaction(nesting: true) { graph.create_edge nil, v0, v1, :relinks, Tackle::SimpleMixin } }
319
319
  end
320
320
  end
321
321
  end
@@ -178,14 +178,14 @@ shared_examples_for Pacer::Wrappers::VertexWrapper do
178
178
  before { pending 'support temporary hash indices for clone/copy' unless graph.features.supportsIndices }
179
179
  let(:dest) { graph2 }
180
180
  }) do
181
- describe '#clone_into', :transactions => false do
182
- subject { v0.clone_into(dest) }
181
+ describe '#clone_into', :transactions => false, read_transaction: true do
182
+ subject { dest.transaction { v0.clone_into(dest) } }
183
183
  its(:properties) { should == { 'name' => 'eliza' } }
184
184
  its(:graph) { should equal(dest) }
185
185
  its('element_id.to_s') { should == v0.element_id.to_s unless graph.features.ignoresSuppliedIds }
186
186
  end
187
187
 
188
- describe '#copy_into', :transaction => false do
188
+ describe '#copy_into', :transaction => false, read_transaction: true do
189
189
  subject { v1.copy_into(dest) }
190
190
  its(:properties) { should == { 'name' => 'darrick' } }
191
191
  its(:graph) { should equal(dest) }
@@ -205,7 +205,7 @@ shared_examples_for Pacer::Wrappers::VertexWrapper do
205
205
  end
206
206
  it { should_not == v1 }
207
207
  it { should == v0 }
208
- context 'edge with same element id', :transactions => false do
208
+ context 'edge with same element id', :transactions => false, read_transaction: true do
209
209
  it { should_not == e0 }
210
210
  end
211
211
 
@@ -30,6 +30,7 @@ def in_editor?
30
30
  end
31
31
 
32
32
  maybe_require 'pacer-neo4j'
33
+ maybe_require 'pacer-neo4j2'
33
34
  maybe_require 'pacer-orient'
34
35
  maybe_require 'pacer-dex'
35
36
  maybe_require 'pacer-mcfly'
@@ -38,10 +39,10 @@ Run = RSpec::GraphRunner.new ENV['GRAPHS']
38
39
 
39
40
  def use_simple_graph_data
40
41
  let(:setup_data) { e0; e1 }
41
- let(:v0) { graph.create_vertex :name => 'eliza' }
42
- let(:v1) { graph.create_vertex :name => 'darrick' }
43
- let(:e0) { graph.create_edge nil, v0, v1, :links }
44
- let(:e1) { graph.create_edge nil, v0, v1, :relinks }
42
+ let(:v0) { graph.transaction(nesting: true) { graph.create_vertex :name => 'eliza' } }
43
+ let(:v1) { graph.transaction(nesting: true) { graph.create_vertex :name => 'darrick' } }
44
+ let(:e0) { graph.transaction(nesting: true) { graph.create_edge nil, v0, v1, :links } }
45
+ let(:e1) { graph.transaction(nesting: true) { graph.create_edge nil, v0, v1, :relinks } }
45
46
  end
46
47
 
47
48
  def use_pacer_graphml_data(usage_style = :read_write)
@@ -1,4 +1,5 @@
1
1
  maybe_require 'pacer-neo4j/rspec'
2
+ maybe_require 'pacer-neo4j2/rspec'
2
3
  maybe_require 'pacer-orient/rspec'
3
4
  maybe_require 'pacer-dex/rspec'
4
5
  maybe_require 'pacer-mcfly/rspec'
@@ -14,6 +15,9 @@ class RSpec::GraphRunner
14
15
  def neo4j(*args)
15
16
  end
16
17
 
18
+ def neo4j2(*args)
19
+ end
20
+
17
21
  def rg(*args)
18
22
  end
19
23
 
@@ -49,6 +53,7 @@ class RSpec::GraphRunner
49
53
  include Stubs
50
54
  include Tg
51
55
  include Neo4j if defined? Neo4j
56
+ include Neo4j2 if defined? Neo4j2
52
57
  include Dex if defined? Dex
53
58
  include Orient if defined? Orient
54
59
  include McFly if defined? McFly
@@ -130,6 +135,12 @@ protected
130
135
  end
131
136
  end
132
137
  end
138
+ elsif graph and transactions and spec.use_read_transaction?
139
+ graph.read_transaction do
140
+ graph2.read_transaction do
141
+ spec.run
142
+ end
143
+ end
133
144
  else
134
145
  spec.run
135
146
  end
@@ -6,6 +6,10 @@ module RSpec
6
6
  find_metadata(metadata, :transactions) != false
7
7
  end
8
8
 
9
+ def use_read_transaction?
10
+ find_metadata(metadata, :read_transaction) != false
11
+ end
12
+
9
13
  def find_metadata(hash, key)
10
14
  return unless hash.is_a? Hash
11
15
  if hash.key? key
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pacer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.5.1
5
5
  platform: java
6
6
  authors:
7
7
  - Darrick Wiebe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-28 00:00:00.000000000 Z
11
+ date: 2014-08-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Pacer defines routes through a graph and then traverses them very quickly.
14
14
  email: darrick@innatesoftware.com
@@ -67,6 +67,7 @@ files:
67
67
  - lib/pacer/filter/random_filter.rb
68
68
  - lib/pacer/filter/range_filter.rb
69
69
  - lib/pacer/filter/uniq_filter.rb
70
+ - lib/pacer/filter/uniq_section.rb
70
71
  - lib/pacer/filter/where_filter.rb
71
72
  - lib/pacer/filter/where_filter/node_visitor.rb
72
73
  - lib/pacer/function_resolver.rb
@@ -117,7 +118,6 @@ files:
117
118
  - lib/pacer/side_effect/group_count.rb
118
119
  - lib/pacer/side_effect/is_unique.rb
119
120
  - lib/pacer/side_effect/visitor.rb
120
- - lib/pacer/support/array.rb
121
121
  - lib/pacer/support/array_list.rb
122
122
  - lib/pacer/support/awesome_print.rb
123
123
  - lib/pacer/support/enumerable.rb
@@ -130,6 +130,7 @@ files:
130
130
  - lib/pacer/transform/flat_map.rb
131
131
  - lib/pacer/transform/gather.rb
132
132
  - lib/pacer/transform/has_count_cap.rb
133
+ - lib/pacer/transform/identity.rb
133
134
  - lib/pacer/transform/intersect_sections.rb
134
135
  - lib/pacer/transform/join.rb
135
136
  - lib/pacer/transform/lookup_ids.rb
@@ -170,6 +171,7 @@ files:
170
171
  - spec/data/grateful-dead.xml
171
172
  - spec/data/pacer.graphml
172
173
  - spec/pacer/blueprints/dex_spec.rb
174
+ - spec/pacer/blueprints/neo4j2_spec.rb
173
175
  - spec/pacer/blueprints/neo4j_spec.rb
174
176
  - spec/pacer/blueprints/orient_spec.rb
175
177
  - spec/pacer/blueprints/tg_spec.rb
@@ -220,7 +222,7 @@ files:
220
222
  - spec/support/use_transactions.rb
221
223
  - spec/tackle/simple_mixin.rb
222
224
  - spec/tackle/tinkerpop_graph_mixins.rb
223
- - lib/pacer-1.4.2-standalone.jar
225
+ - lib/pacer-1.5.1-standalone.jar
224
226
  homepage: http://github.com/pangloss/pacer
225
227
  licenses:
226
228
  - MIT
@@ -249,6 +251,7 @@ test_files:
249
251
  - spec/data/grateful-dead.xml
250
252
  - spec/data/pacer.graphml
251
253
  - spec/pacer/blueprints/dex_spec.rb
254
+ - spec/pacer/blueprints/neo4j2_spec.rb
252
255
  - spec/pacer/blueprints/neo4j_spec.rb
253
256
  - spec/pacer/blueprints/orient_spec.rb
254
257
  - spec/pacer/blueprints/tg_spec.rb
@@ -1,18 +0,0 @@
1
-
2
- class Array
3
- PipesPipe = com.tinkerpop.pipes.Pipe
4
- unless instance_methods.include? :plus_without_multi
5
- alias plus_without_multi +
6
- def +(other)
7
- plus_with_multi(other)
8
- end
9
- end
10
-
11
- def plus_with_multi(other)
12
- if other.is_a? PipesPipe or other.is_a? Enumerator
13
- Pacer::Pipes::MultiPipe.new [self, other]
14
- else
15
- plus_without_multi(other)
16
- end
17
- end
18
- end