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.
- data/.autotest +4 -1
- data/.gitignore +4 -0
- data/.rspec +1 -1
- data/Gemfile-dev +33 -0
- data/Gemfile-release +4 -0
- data/README.md +27 -9
- data/Rakefile +26 -8
- data/bin/autotest +1 -1
- data/lib/pacer/blueprints/multi_graph.rb +7 -19
- data/lib/pacer/blueprints/ruby_graph.rb +77 -52
- data/lib/pacer/blueprints/tg.rb +6 -93
- data/lib/pacer/blueprints.rb +0 -1
- data/lib/pacer/core/graph/edges_route.rb +10 -12
- data/lib/pacer/core/graph/element_route.rb +14 -21
- data/lib/pacer/core/graph/graph_index_route.rb +12 -8
- data/lib/pacer/core/graph/graph_route.rb +2 -5
- data/lib/pacer/core/graph/mixed_route.rb +3 -5
- data/lib/pacer/core/graph/vertices_route.rb +26 -27
- data/lib/pacer/core/route.rb +35 -66
- data/lib/pacer/exceptions.rb +13 -6
- data/lib/pacer/extensions/block_filter_element.rb +0 -5
- data/lib/pacer/filter/collection_filter.rb +9 -2
- data/lib/pacer/filter/empty_filter.rb +12 -3
- data/lib/pacer/filter/future_filter.rb +5 -5
- data/lib/pacer/filter/loop_filter.rb +7 -13
- data/lib/pacer/filter/object_filter.rb +10 -16
- data/lib/pacer/filter/property_filter/filters.rb +134 -93
- data/lib/pacer/filter/property_filter.rb +22 -19
- data/lib/pacer/filter/where_filter/node_visitor.rb +47 -26
- data/lib/pacer/filter/where_filter.rb +24 -3
- data/lib/pacer/function_resolver.rb +7 -2
- data/lib/pacer/graph/graph_ml.rb +39 -0
- data/lib/pacer/graph/graph_transactions_mixin.rb +107 -175
- data/lib/pacer/graph/pacer_graph.rb +438 -0
- data/lib/pacer/graph/simple_encoder.rb +20 -0
- data/lib/pacer/graph/yaml_encoder.rb +81 -0
- data/lib/pacer/graph.rb +8 -10
- data/lib/pacer/pipe/blackbox_pipeline.rb +11 -4
- data/lib/pacer/pipe/block_filter_pipe.rb +5 -22
- data/lib/pacer/pipe/cross_product_transform_pipe.rb +5 -7
- data/lib/pacer/pipe/edges_pipe.rb +22 -0
- data/lib/pacer/pipe/enumerable_pipe.rb +3 -9
- data/lib/pacer/pipe/expandable_pipe.rb +2 -14
- data/lib/pacer/pipe/id_collection_filter_pipe.rb +2 -8
- data/lib/pacer/pipe/is_empty_pipe.rb +5 -12
- data/lib/pacer/pipe/is_unique_pipe.rb +3 -13
- data/lib/pacer/pipe/label_collection_filter_pipe.rb +1 -7
- data/lib/pacer/pipe/label_prefix_pipe.rb +0 -6
- data/lib/pacer/pipe/loop_pipe.rb +27 -25
- data/lib/pacer/pipe/never_pipe.rb +1 -1
- data/lib/pacer/pipe/path_wrapping_pipe.rb +40 -0
- data/lib/pacer/pipe/process_pipe.rb +2 -20
- data/lib/pacer/pipe/property_comparison_pipe.rb +0 -6
- data/lib/pacer/pipe/ruby_pipe.rb +10 -3
- data/lib/pacer/pipe/simple_visitor_pipe.rb +12 -11
- data/lib/pacer/pipe/stream_sort_pipe.rb +1 -7
- data/lib/pacer/pipe/stream_uniq_pipe.rb +0 -6
- data/lib/pacer/pipe/type_filter_pipe.rb +1 -7
- data/lib/pacer/pipe/unary_transform_pipe.rb +6 -8
- data/lib/pacer/pipe/unwrapping_pipe.rb +13 -0
- data/lib/pacer/pipe/vertices_pipe.rb +22 -0
- data/lib/pacer/pipe/visitor_pipe.rb +3 -7
- data/lib/pacer/pipe/wrapping_pipe.rb +37 -0
- data/lib/pacer/pipes.rb +17 -12
- data/lib/pacer/route/mixin/bulk_operations.rb +8 -9
- data/lib/pacer/route/mixin/route_operations.rb +17 -11
- data/lib/pacer/route/mixins.rb +0 -1
- data/lib/pacer/route.rb +198 -121
- data/lib/pacer/side_effect/aggregate.rb +22 -2
- data/lib/pacer/side_effect/as.rb +73 -0
- data/lib/pacer/side_effect/group_count.rb +0 -3
- data/lib/pacer/side_effect/is_unique.rb +7 -6
- data/lib/pacer/side_effect.rb +1 -1
- data/lib/pacer/support/enumerable.rb +14 -12
- data/lib/pacer/support/nil_class.rb +5 -0
- data/lib/pacer/support/proc.rb +2 -2
- data/lib/pacer/support.rb +1 -1
- data/lib/pacer/transform/cap.rb +1 -1
- data/lib/pacer/transform/has_count_cap.rb +1 -1
- data/lib/pacer/transform/join.rb +20 -16
- data/lib/pacer/transform/map.rb +6 -2
- data/lib/pacer/transform/path.rb +44 -20
- data/lib/pacer/transform/sort_section.rb +58 -51
- data/lib/pacer/utils/tsort.rb +7 -2
- data/lib/pacer/utils.rb +0 -1
- data/lib/pacer/version.rb +4 -3
- data/lib/pacer/visitors/section.rb +42 -0
- data/lib/pacer/visitors/visits_section.rb +32 -0
- data/lib/pacer/visitors.rb +7 -0
- data/lib/pacer/wrappers/edge_wrapper.rb +164 -11
- data/lib/pacer/wrappers/element_wrapper.rb +133 -8
- data/lib/pacer/wrappers/index_wrapper.rb +47 -0
- data/lib/pacer/wrappers/vertex_wrapper.rb +175 -12
- data/lib/pacer/wrappers/wrapper_selector.rb +40 -0
- data/lib/pacer/wrappers/wrapping_pipe_function.rb +90 -0
- data/lib/pacer/wrappers.rb +3 -1
- data/lib/pacer-1.0.0-standalone.jar +0 -0
- data/lib/pacer.rb +13 -47
- data/pacer.gemspec +0 -8
- data/pom.xml +10 -3
- data/spec/pacer/blueprints/dex_spec.rb +12 -26
- data/spec/pacer/blueprints/neo4j_spec.rb +14 -28
- data/spec/pacer/blueprints/tg_spec.rb +6 -54
- data/spec/pacer/core/graph/edges_route_spec.rb +1 -1
- data/spec/pacer/core/graph/element_route_spec.rb +2 -2
- data/spec/pacer/core/graph/graph_route_spec.rb +2 -2
- data/spec/pacer/core/graph/vertices_route_spec.rb +10 -3
- data/spec/pacer/core/route_spec.rb +35 -58
- data/spec/pacer/filter/empty_filter_spec.rb +5 -6
- data/spec/pacer/filter/future_filter_spec.rb +8 -8
- data/spec/pacer/filter/loop_filter_spec.rb +120 -6
- data/spec/pacer/filter/object_filter_spec.rb +15 -0
- data/spec/pacer/filter/property_filter/filters_spec.rb +169 -0
- data/spec/pacer/filter/property_filter_spec.rb +15 -12
- data/spec/pacer/filter/uniq_filter_spec.rb +1 -1
- data/spec/pacer/filter/where_filter_spec.rb +55 -7
- data/spec/pacer/graph/{graph_mixin_spec.rb → pacer_graph_spec.rb} +114 -185
- data/spec/pacer/route/mixin/base_spec.rb +36 -35
- data/spec/pacer/route/mixin/route_operations_spec.rb +4 -46
- data/spec/pacer/side_effect/as_spec.rb +34 -0
- data/spec/pacer/support/enumerable_spec.rb +6 -6
- data/spec/pacer/transform/join_spec.rb +7 -5
- data/spec/pacer/transform/map_spec.rb +55 -0
- data/spec/pacer/transform/path_spec.rb +30 -15
- data/spec/pacer/transform/process_spec.rb +42 -0
- data/spec/pacer/transform/sort_section_spec.rb +82 -0
- data/spec/pacer/wrapper/edge_wrapper_spec.rb +122 -2
- data/spec/pacer/wrapper/element_wrapper_spec.rb +289 -3
- data/spec/pacer/wrapper/vertex_wrapper_spec.rb +289 -2
- data/spec/spec_helper.rb +16 -7
- data/spec/support/graph_runner.rb +80 -29
- data/tags +1165 -0
- metadata +46 -107
- data/.rvmrc +0 -0
- data/lib/pacer/blueprints/extensions.rb +0 -77
- data/lib/pacer/graph/edge_mixin.rb +0 -127
- data/lib/pacer/graph/element_mixin.rb +0 -202
- data/lib/pacer/graph/graph_indices_mixin.rb +0 -93
- data/lib/pacer/graph/graph_mixin.rb +0 -361
- data/lib/pacer/graph/index_mixin.rb +0 -30
- data/lib/pacer/graph/vertex_mixin.rb +0 -119
- data/lib/pacer/pipe/map_pipe.rb +0 -36
- data/lib/pacer/pipe/variable_store_iterator_wrapper.rb +0 -26
- data/lib/pacer/route/mixin/variable_route_module.rb +0 -26
- data/lib/pacer/side_effect/section.rb +0 -25
- data/lib/pacer/support/iterator_mixins.rb +0 -110
- data/lib/pacer/wrappers/new_element.rb +0 -106
- data/lib/pacer-0.9.1.1-standalone.jar +0 -0
- data/spec/pacer/graph/edge_mixin_spec.rb +0 -116
- data/spec/pacer/graph/element_mixin_spec.rb +0 -297
- data/spec/pacer/graph/index_mixin_spec.rb +0 -0
- 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 >=
|
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::
|
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
|
-
|
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
|
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 +
|
118
|
-
elsif graph.
|
119
|
-
should ==
|
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
|
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 +
|
129
|
-
elsif graph.
|
130
|
-
should ==
|
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
|
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 +
|
143
|
-
elsif graph.
|
144
|
-
should ==
|
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
|
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 +
|
153
|
-
elsif graph.
|
154
|
-
should ==
|
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.
|
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
|
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 ==
|
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
|
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 ==
|
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
|
206
|
+
subject { graph.create_edge use_id, from, to, :connects }
|
204
207
|
its(:label) { should == 'connects' }
|
205
|
-
its('element_id.to_i') { should ==
|
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
|
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 ==
|
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
|
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 '#
|
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.
|
315
|
-
subject { graph.
|
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.
|
290
|
+
graph.index('missing_edge').should be_nil
|
321
291
|
end
|
322
|
-
subject { graph.
|
323
|
-
its(:
|
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.
|
304
|
+
graph.index('missing_vertex').should be_nil
|
337
305
|
end
|
338
|
-
subject { graph.
|
339
|
-
its(:
|
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
|
-
|
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
|
-
|
345
|
+
unless graph.features.ignoresSuppliedIds
|
400
346
|
graph.create_vertex '0' unless graph.vertex '0'
|
401
|
-
expect {
|
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.
|
410
|
-
|
411
|
-
graph2.
|
412
|
-
graph2.
|
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::
|
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
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
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
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
396
|
+
after do
|
397
|
+
graph.drop_index :vertices
|
398
|
+
graph.v.delete!
|
399
|
+
end
|
447
400
|
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
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
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
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
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
426
|
+
after do
|
427
|
+
graph.drop_index :edges
|
428
|
+
graph.v.delete!
|
429
|
+
end
|
477
430
|
|
478
431
|
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
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::
|
451
|
+
Run.all :read_write do
|
452
|
+
it_uses Pacer::RubyGraph
|
524
453
|
end
|
525
454
|
|
526
455
|
Run.neo4j do
|