pacer 0.9.1.1-java → 1.0.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 (152) hide show
  1. data/.autotest +4 -1
  2. data/.gitignore +4 -0
  3. data/.rspec +1 -1
  4. data/Gemfile-dev +33 -0
  5. data/Gemfile-release +4 -0
  6. data/README.md +27 -9
  7. data/Rakefile +26 -8
  8. data/bin/autotest +1 -1
  9. data/lib/pacer/blueprints/multi_graph.rb +7 -19
  10. data/lib/pacer/blueprints/ruby_graph.rb +77 -52
  11. data/lib/pacer/blueprints/tg.rb +6 -93
  12. data/lib/pacer/blueprints.rb +0 -1
  13. data/lib/pacer/core/graph/edges_route.rb +10 -12
  14. data/lib/pacer/core/graph/element_route.rb +14 -21
  15. data/lib/pacer/core/graph/graph_index_route.rb +12 -8
  16. data/lib/pacer/core/graph/graph_route.rb +2 -5
  17. data/lib/pacer/core/graph/mixed_route.rb +3 -5
  18. data/lib/pacer/core/graph/vertices_route.rb +26 -27
  19. data/lib/pacer/core/route.rb +35 -66
  20. data/lib/pacer/exceptions.rb +13 -6
  21. data/lib/pacer/extensions/block_filter_element.rb +0 -5
  22. data/lib/pacer/filter/collection_filter.rb +9 -2
  23. data/lib/pacer/filter/empty_filter.rb +12 -3
  24. data/lib/pacer/filter/future_filter.rb +5 -5
  25. data/lib/pacer/filter/loop_filter.rb +7 -13
  26. data/lib/pacer/filter/object_filter.rb +10 -16
  27. data/lib/pacer/filter/property_filter/filters.rb +134 -93
  28. data/lib/pacer/filter/property_filter.rb +22 -19
  29. data/lib/pacer/filter/where_filter/node_visitor.rb +47 -26
  30. data/lib/pacer/filter/where_filter.rb +24 -3
  31. data/lib/pacer/function_resolver.rb +7 -2
  32. data/lib/pacer/graph/graph_ml.rb +39 -0
  33. data/lib/pacer/graph/graph_transactions_mixin.rb +107 -175
  34. data/lib/pacer/graph/pacer_graph.rb +438 -0
  35. data/lib/pacer/graph/simple_encoder.rb +20 -0
  36. data/lib/pacer/graph/yaml_encoder.rb +81 -0
  37. data/lib/pacer/graph.rb +8 -10
  38. data/lib/pacer/pipe/blackbox_pipeline.rb +11 -4
  39. data/lib/pacer/pipe/block_filter_pipe.rb +5 -22
  40. data/lib/pacer/pipe/cross_product_transform_pipe.rb +5 -7
  41. data/lib/pacer/pipe/edges_pipe.rb +22 -0
  42. data/lib/pacer/pipe/enumerable_pipe.rb +3 -9
  43. data/lib/pacer/pipe/expandable_pipe.rb +2 -14
  44. data/lib/pacer/pipe/id_collection_filter_pipe.rb +2 -8
  45. data/lib/pacer/pipe/is_empty_pipe.rb +5 -12
  46. data/lib/pacer/pipe/is_unique_pipe.rb +3 -13
  47. data/lib/pacer/pipe/label_collection_filter_pipe.rb +1 -7
  48. data/lib/pacer/pipe/label_prefix_pipe.rb +0 -6
  49. data/lib/pacer/pipe/loop_pipe.rb +27 -25
  50. data/lib/pacer/pipe/never_pipe.rb +1 -1
  51. data/lib/pacer/pipe/path_wrapping_pipe.rb +40 -0
  52. data/lib/pacer/pipe/process_pipe.rb +2 -20
  53. data/lib/pacer/pipe/property_comparison_pipe.rb +0 -6
  54. data/lib/pacer/pipe/ruby_pipe.rb +10 -3
  55. data/lib/pacer/pipe/simple_visitor_pipe.rb +12 -11
  56. data/lib/pacer/pipe/stream_sort_pipe.rb +1 -7
  57. data/lib/pacer/pipe/stream_uniq_pipe.rb +0 -6
  58. data/lib/pacer/pipe/type_filter_pipe.rb +1 -7
  59. data/lib/pacer/pipe/unary_transform_pipe.rb +6 -8
  60. data/lib/pacer/pipe/unwrapping_pipe.rb +13 -0
  61. data/lib/pacer/pipe/vertices_pipe.rb +22 -0
  62. data/lib/pacer/pipe/visitor_pipe.rb +3 -7
  63. data/lib/pacer/pipe/wrapping_pipe.rb +37 -0
  64. data/lib/pacer/pipes.rb +17 -12
  65. data/lib/pacer/route/mixin/bulk_operations.rb +8 -9
  66. data/lib/pacer/route/mixin/route_operations.rb +17 -11
  67. data/lib/pacer/route/mixins.rb +0 -1
  68. data/lib/pacer/route.rb +198 -121
  69. data/lib/pacer/side_effect/aggregate.rb +22 -2
  70. data/lib/pacer/side_effect/as.rb +73 -0
  71. data/lib/pacer/side_effect/group_count.rb +0 -3
  72. data/lib/pacer/side_effect/is_unique.rb +7 -6
  73. data/lib/pacer/side_effect.rb +1 -1
  74. data/lib/pacer/support/enumerable.rb +14 -12
  75. data/lib/pacer/support/nil_class.rb +5 -0
  76. data/lib/pacer/support/proc.rb +2 -2
  77. data/lib/pacer/support.rb +1 -1
  78. data/lib/pacer/transform/cap.rb +1 -1
  79. data/lib/pacer/transform/has_count_cap.rb +1 -1
  80. data/lib/pacer/transform/join.rb +20 -16
  81. data/lib/pacer/transform/map.rb +6 -2
  82. data/lib/pacer/transform/path.rb +44 -20
  83. data/lib/pacer/transform/sort_section.rb +58 -51
  84. data/lib/pacer/utils/tsort.rb +7 -2
  85. data/lib/pacer/utils.rb +0 -1
  86. data/lib/pacer/version.rb +4 -3
  87. data/lib/pacer/visitors/section.rb +42 -0
  88. data/lib/pacer/visitors/visits_section.rb +32 -0
  89. data/lib/pacer/visitors.rb +7 -0
  90. data/lib/pacer/wrappers/edge_wrapper.rb +164 -11
  91. data/lib/pacer/wrappers/element_wrapper.rb +133 -8
  92. data/lib/pacer/wrappers/index_wrapper.rb +47 -0
  93. data/lib/pacer/wrappers/vertex_wrapper.rb +175 -12
  94. data/lib/pacer/wrappers/wrapper_selector.rb +40 -0
  95. data/lib/pacer/wrappers/wrapping_pipe_function.rb +90 -0
  96. data/lib/pacer/wrappers.rb +3 -1
  97. data/lib/pacer-1.0.0-standalone.jar +0 -0
  98. data/lib/pacer.rb +13 -47
  99. data/pacer.gemspec +0 -8
  100. data/pom.xml +10 -3
  101. data/spec/pacer/blueprints/dex_spec.rb +12 -26
  102. data/spec/pacer/blueprints/neo4j_spec.rb +14 -28
  103. data/spec/pacer/blueprints/tg_spec.rb +6 -54
  104. data/spec/pacer/core/graph/edges_route_spec.rb +1 -1
  105. data/spec/pacer/core/graph/element_route_spec.rb +2 -2
  106. data/spec/pacer/core/graph/graph_route_spec.rb +2 -2
  107. data/spec/pacer/core/graph/vertices_route_spec.rb +10 -3
  108. data/spec/pacer/core/route_spec.rb +35 -58
  109. data/spec/pacer/filter/empty_filter_spec.rb +5 -6
  110. data/spec/pacer/filter/future_filter_spec.rb +8 -8
  111. data/spec/pacer/filter/loop_filter_spec.rb +120 -6
  112. data/spec/pacer/filter/object_filter_spec.rb +15 -0
  113. data/spec/pacer/filter/property_filter/filters_spec.rb +169 -0
  114. data/spec/pacer/filter/property_filter_spec.rb +15 -12
  115. data/spec/pacer/filter/uniq_filter_spec.rb +1 -1
  116. data/spec/pacer/filter/where_filter_spec.rb +55 -7
  117. data/spec/pacer/graph/{graph_mixin_spec.rb → pacer_graph_spec.rb} +114 -185
  118. data/spec/pacer/route/mixin/base_spec.rb +36 -35
  119. data/spec/pacer/route/mixin/route_operations_spec.rb +4 -46
  120. data/spec/pacer/side_effect/as_spec.rb +34 -0
  121. data/spec/pacer/support/enumerable_spec.rb +6 -6
  122. data/spec/pacer/transform/join_spec.rb +7 -5
  123. data/spec/pacer/transform/map_spec.rb +55 -0
  124. data/spec/pacer/transform/path_spec.rb +30 -15
  125. data/spec/pacer/transform/process_spec.rb +42 -0
  126. data/spec/pacer/transform/sort_section_spec.rb +82 -0
  127. data/spec/pacer/wrapper/edge_wrapper_spec.rb +122 -2
  128. data/spec/pacer/wrapper/element_wrapper_spec.rb +289 -3
  129. data/spec/pacer/wrapper/vertex_wrapper_spec.rb +289 -2
  130. data/spec/spec_helper.rb +16 -7
  131. data/spec/support/graph_runner.rb +80 -29
  132. data/tags +1165 -0
  133. metadata +46 -107
  134. data/.rvmrc +0 -0
  135. data/lib/pacer/blueprints/extensions.rb +0 -77
  136. data/lib/pacer/graph/edge_mixin.rb +0 -127
  137. data/lib/pacer/graph/element_mixin.rb +0 -202
  138. data/lib/pacer/graph/graph_indices_mixin.rb +0 -93
  139. data/lib/pacer/graph/graph_mixin.rb +0 -361
  140. data/lib/pacer/graph/index_mixin.rb +0 -30
  141. data/lib/pacer/graph/vertex_mixin.rb +0 -119
  142. data/lib/pacer/pipe/map_pipe.rb +0 -36
  143. data/lib/pacer/pipe/variable_store_iterator_wrapper.rb +0 -26
  144. data/lib/pacer/route/mixin/variable_route_module.rb +0 -26
  145. data/lib/pacer/side_effect/section.rb +0 -25
  146. data/lib/pacer/support/iterator_mixins.rb +0 -110
  147. data/lib/pacer/wrappers/new_element.rb +0 -106
  148. data/lib/pacer-0.9.1.1-standalone.jar +0 -0
  149. data/spec/pacer/graph/edge_mixin_spec.rb +0 -116
  150. data/spec/pacer/graph/element_mixin_spec.rb +0 -297
  151. data/spec/pacer/graph/index_mixin_spec.rb +0 -0
  152. data/spec/pacer/graph/vertex_mixin_spec.rb +0 -192
@@ -3,6 +3,12 @@ require 'spec_helper'
3
3
 
4
4
  Run.tg(:read_only) do
5
5
  use_pacer_graphml_data(:read_only)
6
+ before :all do
7
+ n = 0
8
+ graph.v.each { |v| v[:number] = n += 1 }
9
+ graph.vertex('0')[:note] = "note"
10
+ graph.vertex('2')[:note] = "note"
11
+ end
6
12
 
7
13
  describe Pacer::Filter::WhereFilter do
8
14
  context "name = 'blueprints'" do
@@ -11,38 +17,80 @@ Run.tg(:read_only) do
11
17
  its(:first) { should == 'blueprints' }
12
18
  end
13
19
 
20
+ context "{ name: 'blueprints' }" do
21
+ subject { graph.v.where(name: 'blueprints')[:name] }
22
+ its(:count) { should == 1 }
23
+ its(:first) { should == 'blueprints' }
24
+ end
25
+
14
26
  context "name != nil" do
15
27
  subject { graph.v.where("name != nil") }
16
28
  its(:count) { should == 7 }
17
29
  end
18
30
 
31
+ context :note do
32
+ subject { graph.v.where :note }
33
+ its(:count) { should == 2 }
34
+ end
35
+
36
+ context '#unless(:note)' do
37
+ subject { graph.v.unless :note }
38
+ its(:count) { should == 5 }
39
+ end
40
+
41
+ context 'name and note' do
42
+ subject { graph.v.where 'name and note' }
43
+ its(:count) { should == 2 }
44
+ end
45
+
46
+ context 'name and not note' do
47
+ subject { graph.v.where 'name and not note' }
48
+ its(:count) { should == 5 }
49
+ end
50
+
51
+ context '#unless(name and not note)' do
52
+ subject { graph.v.unless 'name and not note' }
53
+ its(:count) { should == 2 }
54
+ end
55
+
56
+ context 'name and type == "project"' do
57
+ subject { graph.v.where 'note and type == "project"' }
58
+ its(:count) { should == 1 }
59
+ end
60
+
61
+ context '#unless(:name)' do
62
+ subject { graph.v.unless :name }
63
+ its(:count) { should == 0 }
64
+ end
65
+
19
66
  context "name = nil" do
20
67
  subject { graph.v.where("name = nil") }
21
68
  its(:count) { should == 0 }
22
69
  end
23
70
 
24
- context 'with number' do
25
- before do
26
- n = 0
27
- graph.v.each { |v| v[:number] = n += 1 }
28
- end
29
71
 
72
+ context 'with number' do
30
73
  context "number = 1" do
31
74
  subject { graph.v.where("number = 1") }
32
75
  its(:count) { should == 1 }
33
76
  end
34
77
 
35
- context "number >= 1" do
78
+ context "number >= 2" do
36
79
  subject { graph.v.where("number >= 2") }
37
80
  its(:count) { should == 6 }
38
81
  end
39
82
 
83
+ context "#unless(number >= 2)" do
84
+ subject { graph.v.unless("number >= 2") }
85
+ its(:count) { should == 1 }
86
+ end
87
+
40
88
  context "number % 2 == 0" do
41
89
  subject { graph.v.where("number % 2 == 0") }
42
90
  its(:count) { should == 3 }
43
91
  end
44
92
 
45
- context "number % 2 == 1" do
93
+ context "number % 2 == 0 + 1" do
46
94
  subject { graph.v.where("number % 2 == 0 + 1") }
47
95
  its(:count) { should == 4 }
48
96
  end
@@ -16,7 +16,7 @@ shared_examples_for 'a vertex with a mixin' do
16
16
  end
17
17
  end
18
18
 
19
- shared_examples_for Pacer::GraphMixin do
19
+ shared_examples_for Pacer::RubyGraph do
20
20
  let(:v0) { graph.create_vertex }
21
21
  let(:v1) { graph.create_vertex }
22
22
  let(:e0) { graph.create_edge nil, v0, v1, :links }
@@ -96,9 +96,11 @@ shared_examples_for Pacer::GraphMixin do
96
96
  end
97
97
 
98
98
  describe '#create_vertex' do
99
+ let(:use_id) { rand 1000000 }
100
+
99
101
  context 'existing' do
100
102
  it 'should raise an exception' do
101
- if graph.supports_custom_element_ids?
103
+ unless graph.features.ignoresSuppliedIds
102
104
  expect { graph.create_vertex v0.element_id }.to raise_error(Pacer::ElementExists)
103
105
  end
104
106
  end
@@ -110,24 +112,24 @@ shared_examples_for Pacer::GraphMixin do
110
112
  its(:element_id) { should_not be_nil }
111
113
 
112
114
  context 'and an id' do
113
- subject { graph.create_vertex 1234, :name => 'Steve' }
115
+ subject { graph.create_vertex use_id, :name => 'Steve' }
114
116
  it { subject[:name].should == 'Steve' }
115
117
  its('element_id.to_s') do
116
118
  if graph.respond_to? :id_prefix
117
- should == graph.id_prefix + '1234'
118
- elsif graph.supports_custom_element_ids?
119
- should == '1234'
119
+ should == graph.id_prefix + use_id.to_s
120
+ elsif not graph.features.ignoresSuppliedIds
121
+ should == use_id.to_s
120
122
  end
121
123
  end
122
124
 
123
125
  context 'and mixins' do
124
- subject { graph.create_vertex 1234, Tackle::SimpleMixin, :name => 'John' }
126
+ subject { graph.create_vertex use_id, Tackle::SimpleMixin, :name => 'John' }
125
127
  it { subject[:name].should == 'John' }
126
128
  its('element_id.to_s') do
127
129
  if graph.respond_to? :id_prefix
128
- should == graph.id_prefix + '1234'
129
- elsif graph.supports_custom_element_ids?
130
- should == '1234'
130
+ should == graph.id_prefix + use_id.to_s
131
+ elsif not graph.features.ignoresSuppliedIds
132
+ should == use_id.to_s
131
133
  end
132
134
  end
133
135
  it_behaves_like 'a vertex with a mixin'
@@ -136,22 +138,22 @@ shared_examples_for Pacer::GraphMixin do
136
138
  end
137
139
 
138
140
  context 'with an id' do
139
- subject { graph.create_vertex 1234 }
141
+ subject { graph.create_vertex use_id }
140
142
  its('element_id.to_s') do
141
143
  if graph.respond_to? :id_prefix
142
- should == graph.id_prefix + '1234'
143
- elsif graph.supports_custom_element_ids?
144
- should == '1234'
144
+ should == graph.id_prefix + use_id.to_s
145
+ elsif not graph.features.ignoresSuppliedIds
146
+ should == use_id.to_s
145
147
  end
146
148
  end
147
149
 
148
150
  context 'and mixins' do
149
- subject { graph.create_vertex 1234, Tackle::SimpleMixin }
151
+ subject { graph.create_vertex use_id, Tackle::SimpleMixin }
150
152
  its('element_id.to_s') do
151
153
  if graph.respond_to? :id_prefix
152
- should == graph.id_prefix + '1234'
153
- elsif graph.supports_custom_element_ids?
154
- should == '1234'
154
+ should == graph.id_prefix + use_id.to_s
155
+ elsif not graph.features.ignoresSuppliedIds
156
+ should == use_id.to_s
155
157
  end
156
158
  end
157
159
  it_behaves_like 'a vertex with a mixin'
@@ -166,12 +168,13 @@ shared_examples_for Pacer::GraphMixin do
166
168
 
167
169
 
168
170
  describe '#create_edge' do
171
+ let(:use_id) { rand 1000000 }
169
172
  let(:from) { graph.vertex v0.element_id }
170
173
  let(:to) { graph.vertex v1.element_id }
171
174
 
172
175
  context 'existing' do
173
176
  it 'should raise an exception' do
174
- if graph.supports_custom_element_ids?
177
+ if not graph.features.ignoresSuppliedIds
175
178
  expect { graph.create_edge e0.element_id, from, to, :connects }.to raise_error(Pacer::ElementExists)
176
179
  end
177
180
  end
@@ -184,30 +187,30 @@ shared_examples_for Pacer::GraphMixin do
184
187
  its(:element_id) { should_not be_nil }
185
188
 
186
189
  context 'and an id' do
187
- subject { graph.create_edge 1234, from, to, :connects, :name => 'Steve' }
190
+ subject { graph.create_edge use_id, from, to, :connects, :name => 'Steve' }
188
191
  it { subject[:name].should == 'Steve' }
189
192
  its(:label) { should == 'connects' }
190
- its('element_id.to_i') { should == 1234 if graph.supports_custom_element_ids? }
193
+ its('element_id.to_i') { should == use_id unless graph.features.ignoresSuppliedIds }
191
194
 
192
195
  context 'and mixins' do
193
- subject { graph.create_edge 1234, from, to, :connects, Tackle::SimpleMixin, :name => 'John' }
196
+ subject { graph.create_edge use_id, from, to, :connects, Tackle::SimpleMixin, :name => 'John' }
194
197
  it { subject[:name].should == 'John' }
195
198
  its(:label) { should == 'connects' }
196
- its('element_id.to_i') { should == 1234 if graph.supports_custom_element_ids? }
199
+ its('element_id.to_i') { should == use_id unless graph.features.ignoresSuppliedIds }
197
200
  it_behaves_like 'an edge with a mixin'
198
201
  end
199
202
  end
200
203
  end
201
204
 
202
205
  context 'with an id' do
203
- subject { graph.create_edge 1234, from, to, :connects }
206
+ subject { graph.create_edge use_id, from, to, :connects }
204
207
  its(:label) { should == 'connects' }
205
- its('element_id.to_i') { should == 1234 if graph.supports_custom_element_ids? }
208
+ its('element_id.to_i') { should == use_id unless graph.features.ignoresSuppliedIds }
206
209
 
207
210
  context 'and mixins' do
208
- subject { graph.create_edge 1234, from, to, :connects, Tackle::SimpleMixin }
211
+ subject { graph.create_edge use_id, from, to, :connects, Tackle::SimpleMixin }
209
212
  its(:label) { should == 'connects' }
210
- its('element_id.to_i') { should == 1234 if graph.supports_custom_element_ids? }
213
+ its('element_id.to_i') { should == use_id unless graph.features.ignoresSuppliedIds }
211
214
  it_behaves_like 'an edge with a mixin'
212
215
  end
213
216
  end
@@ -257,7 +260,10 @@ shared_examples_for Pacer::GraphMixin do
257
260
  end
258
261
 
259
262
  describe '#load_edges' do
260
- before { graph.checkpoint }
263
+ before do
264
+ c = example.metadata[:graph_commit]
265
+ c.call if c
266
+ end
261
267
  context 'invalid' do
262
268
  subject { graph.load_edges [e0.element_id, nil, e0.element_id, 'missing'] }
263
269
  it { should == [e0, e0] }
@@ -269,60 +275,22 @@ shared_examples_for Pacer::GraphMixin do
269
275
  end
270
276
  end
271
277
 
272
- describe '#index_name' do
273
-
274
-
275
- it 'should have 2 indices' do
276
- graph.indices.count.should == 2 if graph.supports_automatic_indices?
277
- end
278
-
279
- context "'vertices'" do
280
- around { |spec| spec.run if graph.supports_automatic_indices? }
281
- subject { graph.index_name 'vertices' }
282
- it { should_not be_nil }
283
- its(:index_name) { should == 'vertices' }
284
- its(:index_type) { should == Pacer.automatic_index }
285
- its(:index_class) { should == graph.index_class(:vertex) }
286
- context ':vertex' do
287
- subject { graph.index_name 'vertices', :vertex }
288
- it { should_not be_nil }
289
- end
290
- context ':edge' do
291
- subject { graph.index_name 'vertices', :edge }
292
- it { should be_nil }
293
- end
294
- end
295
-
296
- context "'edges'" do
297
- around { |spec| spec.run if graph.supports_edge_indices? }
298
- subject { graph.index_name 'edges' }
299
- it { should_not be_nil }
300
- its(:index_name) { should == 'edges' }
301
- its(:index_type) { should == Pacer.automatic_index }
302
- its(:index_class) { should == graph.index_class(:edge) }
303
- context ':vertex' do
304
- subject { graph.index_name 'edges', :vertex }
305
- it { should be_nil }
306
- end
307
- context ':edge' do
308
- subject { graph.index_name 'edges', :edge }
309
- it { should_not be_nil }
310
- end
278
+ describe '#index' do
279
+ it 'should have no indices' do
280
+ graph.indices.count.should == 0 if graph.features.supportsKeyIndices
311
281
  end
312
282
 
313
283
  context 'missing' do
314
- around { |spec| spec.run if graph.supports_manual_indices? }
315
- subject { graph.index_name 'invalid' }
284
+ around { |spec| spec.run if graph.features.supportsIndices }
285
+ subject { graph.index 'invalid' }
316
286
  it { should be_nil }
317
287
  context 'edge' do
318
288
  before do
319
289
  graph.drop_index 'missing_edge' rescue nil
320
- graph.index_name('missing_edge').should be_nil
290
+ graph.index('missing_edge').should be_nil
321
291
  end
322
- subject { graph.index_name 'missing_edge', :edge, :create => true }
323
- its(:index_name) { should == 'missing_edge' }
324
- its(:index_type) { should == Pacer.manual_index }
325
- its(:index_class) { should == graph.index_class(:edge) }
292
+ subject { graph.index 'missing_edge', :edge, :create => true }
293
+ its(:name) { should == 'missing_edge' }
326
294
  after do
327
295
  graph.transaction do
328
296
  graph.drop_index 'missing_edge'
@@ -333,12 +301,10 @@ shared_examples_for Pacer::GraphMixin do
333
301
  context 'vertex' do
334
302
  before do
335
303
  graph.drop_index 'missing_vertex' rescue nil
336
- graph.index_name('missing_vertex').should be_nil
304
+ graph.index('missing_vertex').should be_nil
337
305
  end
338
- subject { graph.index_name 'missing_vertex', :vertex, :create => true }
339
- its(:index_name) { should == 'missing_vertex' }
340
- its(:index_type) { should == Pacer.manual_index }
341
- its(:index_class) { should == graph.index_class(:vertex) }
306
+ subject { graph.index 'missing_vertex', :vertex, :create => true }
307
+ its(:name) { should == 'missing_vertex' }
342
308
  after do
343
309
  graph.transaction do
344
310
  graph.drop_index 'missing_vertex'
@@ -346,12 +312,6 @@ shared_examples_for Pacer::GraphMixin do
346
312
  end
347
313
  end
348
314
  end
349
-
350
- it 'should return the same object each time' do
351
- if graph.supports_manual_indices? or graph.supports_automatic_indices?
352
- graph.index_name('vertices').should equal(graph.index_name('vertices'))
353
- end
354
- end
355
315
  end
356
316
 
357
317
  describe '#graph' do
@@ -373,43 +333,35 @@ shared_examples_for Pacer::GraphMixin do
373
333
  after { graph.edge_name = nil }
374
334
  end
375
335
 
376
- describe '#index_class' do
377
- around { |spec| spec.run if graph.respond_to? :index_class }
378
- subject { graph.index_class(:vertex) }
379
- specify 'should be the class the index returns when queried for index_class' do
380
- if graph.is_a? Pacer::DexGraph
381
- subject.should == graph.indices.first.index_class
382
- else
383
- subject.to_s.should == graph.index_name('vertices').index_class.to_s
384
- end
385
- end
386
- end
387
-
388
336
  describe '#import' do
389
- before { pending 'create a fresh graph for these tests' if graph.is_a? Pacer::DexGraph }
390
-
391
337
  it 'should load the data into an empty graph' do
392
338
  graph2.v.count.should == 0
393
- graph2.import 'spec/data/pacer.graphml'
339
+ Pacer::GraphML.import graph2, 'spec/data/pacer.graphml'
394
340
  graph2.v.count.should == 7
395
341
  graph2.e.count.should == 14
396
342
  end
397
343
 
398
344
  it 'should not load the data into a graph with conflicting vertex ids' do
399
- if graph.supports_custom_element_ids?
345
+ unless graph.features.ignoresSuppliedIds
400
346
  graph.create_vertex '0' unless graph.vertex '0'
401
- expect { graph.import 'spec/data/pacer.graphml' }.to raise_error(Pacer::ElementExists)
347
+ expect { Pacer::GraphML.import graph, 'spec/data/pacer.graphml' }.to raise_error(Pacer::ElementExists)
402
348
  end
403
349
  end
404
350
  end
405
351
 
406
352
  describe '#export' do
407
- before { pending 'create a fresh graph for these tests' if graph.is_a? Pacer::DexGraph }
408
353
  it 'should create a file that can be read back' do
409
- graph.export 'tmp/graph_mixin_spec_export.graphml'
410
- graph2.import 'tmp/graph_mixin_spec_export.graphml'
411
- graph2.v.count.should == graph.v.count
412
- graph2.e.count.should == graph.e.count
354
+ graph.v.count.should == 2
355
+ graph.e.count.should == 1
356
+ graph2.e.delete!
357
+ graph2.v.delete!
358
+ graph2.v.count.should == 0
359
+ graph2.e.count.should == 0
360
+ Pacer::GraphML.export graph, 'tmp/graph_mixin_spec_export.graphml'
361
+ Pacer::GraphML.import graph2, 'tmp/graph_mixin_spec_export.graphml'
362
+ puts File.read 'tmp/graph_mixin_spec_export.graphml'
363
+ graph2.v.count.should == 2
364
+ graph2.e.count.should == 1
413
365
  end
414
366
  end
415
367
 
@@ -426,101 +378,78 @@ Run.all :read_only, false do
426
378
  let(:e0) { graph.create_edge nil, v0, v1, :links }
427
379
  let(:e1) { graph.create_edge nil, v0, v1, :relinks }
428
380
 
429
- describe Pacer::GraphMixin do
381
+ describe Pacer::RubyGraph do
430
382
  before do
431
383
  e0 # force edge and vertices to be created.
432
384
  end
433
385
 
434
- describe 'rebuild_automatic_index', :transactions => false do
435
- context 'vertices' do
436
- before do
437
- v0.properties = { :name => 'darrick', :type => 'person' }
438
- v1.properties = { :name => 'eliza', :type => 'person' }
439
- @orig_idx = graph.createAutomaticIndex 'vertices', graph.index_class(:vertex), nil
440
- @new_idx = graph.rebuild_automatic_index @orig_idx
441
- end
386
+ pending "not sure if index rebuilding will be needed anymore" do
387
+ describe 'rebuild_automatic_index', :transactions => false do
388
+ context 'vertices' do
389
+ before do
390
+ v0.properties = { :name => 'darrick', :type => 'person' }
391
+ v1.properties = { :name => 'eliza', :type => 'person' }
392
+ @orig_idx = graph.createAutomaticIndex 'vertices', graph.index_class(:vertex), nil
393
+ @new_idx = graph.rebuild_automatic_index @orig_idx
394
+ end
442
395
 
443
- after do
444
- graph.drop_index :vertices
445
- graph.v.delete!
446
- end
396
+ after do
397
+ graph.drop_index :vertices
398
+ graph.v.delete!
399
+ end
447
400
 
448
- let(:orig_idx) { @orig_idx }
449
- subject { @new_idx }
450
- it { should_not equal(orig_idx) }
451
- it 'should not use the old vertices index' do
452
- graph.index_name('vertices').should_not equal(orig_idx)
453
- end
454
- it { should equal(graph.index_name('vertices')) }
455
- it 'should have 2 persons' do
456
- subject.count('type', 'person').should == 2
457
- end
458
- it 'should have v1 for eliza' do
459
- subject.get('name', 'eliza').to_a.should == [v1].to_a
401
+ let(:orig_idx) { @orig_idx }
402
+ subject { @new_idx }
403
+ it { should_not equal(orig_idx) }
404
+ it 'should not use the old vertices index' do
405
+ graph.index('vertices').should_not equal(orig_idx)
406
+ end
407
+ it { should equal(graph.index('vertices')) }
408
+ it 'should have 2 persons' do
409
+ subject.count('type', 'person').should == 2
410
+ end
411
+ it 'should have v1 for eliza' do
412
+ subject.get('name', 'eliza').to_a.should == [v1].to_a
413
+ end
460
414
  end
461
- end
462
415
 
463
- context 'edges' do
464
- before do
465
- v0.properties = { :name => 'darrick', :type => 'person' }
466
- v1.properties = { :name => 'eliza', :type => 'person' }
467
- e0.properties = { :style => 'edgy' }
468
- e1.properties = { :style => 'edgy' }
469
- @orig_idx = graph.createAutomaticIndex 'edges', graph.index_class(:edge), nil
470
- @new_idx = graph.rebuild_automatic_index @orig_idx
471
- end
416
+ context 'edges' do
417
+ before do
418
+ v0.properties = { :name => 'darrick', :type => 'person' }
419
+ v1.properties = { :name => 'eliza', :type => 'person' }
420
+ e0.properties = { :style => 'edgy' }
421
+ e1.properties = { :style => 'edgy' }
422
+ @orig_idx = graph.createAutomaticIndex 'edges', graph.index_class(:edge), nil
423
+ @new_idx = graph.rebuild_automatic_index @orig_idx
424
+ end
472
425
 
473
- after do
474
- graph.drop_index :edges
475
- graph.v.delete!
476
- end
426
+ after do
427
+ graph.drop_index :edges
428
+ graph.v.delete!
429
+ end
477
430
 
478
431
 
479
- let(:orig_idx) { @orig_idx }
480
- subject { @new_idx }
481
- it { should_not equal(orig_idx) }
482
- it 'should not use the old edges index' do
483
- graph.index_name('edges').should_not equal(orig_idx)
484
- end
485
- it { should equal(graph.index_name('edges')) }
486
- it 'should have 1 edge' do
487
- subject.count('label', 'links').should == 1
488
- end
489
- it 'should have e0 and e1 for style => edgy' do
490
- subject.get('style', 'edgy').to_set.should == [e0, e1].to_set
432
+ let(:orig_idx) { @orig_idx }
433
+ subject { @new_idx }
434
+ it { should_not equal(orig_idx) }
435
+ it 'should not use the old edges index' do
436
+ graph.index('edges').should_not equal(orig_idx)
437
+ end
438
+ it { should equal(graph.index('edges')) }
439
+ it 'should have 1 edge' do
440
+ subject.count('label', 'links').should == 1
441
+ end
442
+ it 'should have e0 and e1 for style => edgy' do
443
+ subject.get('style', 'edgy').to_set.should == [e0, e1].to_set
444
+ end
491
445
  end
492
446
  end
493
447
  end
494
448
  end
495
-
496
- describe 'edges can be indexed', :transactions => false do
497
- after do
498
- graph.drop_index 'edges'
499
- graph.v.delete!
500
- end
501
-
502
- specify 'in an auto index' do
503
- index = graph.createAutomaticIndex 'edges', graph.index_class(:edge), nil
504
- graph.edges.count.should == 0
505
- label = e0.label
506
- graph.edges.count.should == 1
507
- index.get('label', label).count.should == 1
508
- end
509
-
510
- specify 'by adding them to a new auto index' do
511
- graph.edges.count.should == 0
512
- label = e0.label
513
- graph.edges.count.should == 1
514
- index = graph.createAutomaticIndex 'edges', graph.index_class(:edge), nil
515
- index.get('label', label).count.should == 0
516
- Pacer::Utils::AutomaticIndexHelper.addElement(index, e0)
517
- index.get('label', label).count.should == 1
518
- end
519
- end
520
449
  end
521
450
 
522
- Run.all do
523
- it_uses Pacer::GraphMixin
451
+ Run.all :read_write do
452
+ it_uses Pacer::RubyGraph
524
453
  end
525
454
 
526
455
  Run.neo4j do