pacer 1.0.2-java → 1.0.3-java
Sign up to get free protection for your applications and to get access to all the features.
- data/blog/2012-09-18-pacer-1.0.md +63 -0
- data/lib/pacer/core/graph/element_route.rb +8 -4
- data/lib/pacer/core/graph/vertices_route.rb +1 -1
- data/lib/pacer/core/route.rb +20 -0
- data/lib/pacer/exceptions.rb +1 -0
- data/lib/pacer/filter/future_filter.rb +2 -0
- data/lib/pacer/graph/graph_transactions_mixin.rb +13 -12
- data/lib/pacer/graph/hash_index.rb +29 -0
- data/lib/pacer/graph/pacer_graph.rb +23 -6
- data/lib/pacer/graph/simple_encoder.rb +9 -4
- data/lib/pacer/graph/yaml_encoder.rb +18 -31
- data/lib/pacer/loader.rb +93 -0
- data/lib/pacer/route/mixin/bulk_operations.rb +1 -1
- data/lib/pacer/route.rb +0 -151
- data/lib/pacer/route_builder.rb +142 -0
- data/lib/pacer/side_effect/as.rb +1 -3
- data/lib/pacer/version.rb +1 -1
- data/lib/pacer/wrappers/edge_wrapper.rb +13 -16
- data/lib/pacer/wrappers/element_wrapper.rb +12 -22
- data/lib/pacer/wrappers/vertex_wrapper.rb +7 -4
- data/lib/{pacer-1.0.2-standalone.jar → pacer-1.0.3-standalone.jar} +0 -0
- data/lib/pacer.rb +9 -15
- data/pom.xml +1 -1
- data/spec/pacer/blueprints/dex_spec.rb +1 -154
- data/spec/pacer/blueprints/neo4j_spec.rb +8 -154
- data/spec/pacer/blueprints/orient_spec.rb +5 -0
- data/spec/pacer/blueprints/tg_spec.rb +1 -76
- data/spec/pacer/core/graph/vertices_route_spec.rb +32 -5
- data/spec/pacer/graph/pacer_graph_spec.rb +304 -336
- data/spec/pacer/graph/simple_encoder_spec.rb +78 -0
- data/spec/pacer/graph/yaml_encoder_spec.rb +71 -0
- data/spec/pacer/transform/join_spec.rb +1 -1
- data/spec/pacer/utils/tsort_spec.rb +1 -3
- data/spec/pacer/wrapper/edge_wrapper_spec.rb +46 -40
- data/spec/pacer/wrapper/element_wrapper_spec.rb +8 -13
- data/spec/support/graph_runner.rb +12 -3
- metadata +13 -14
- data/lib/pacer/blueprints.rb +0 -3
- data/lib/pacer/core.rb +0 -8
- data/lib/pacer/filter.rb +0 -17
- data/lib/pacer/graph.rb +0 -12
- data/lib/pacer/route/mixins.rb +0 -2
- data/lib/pacer/routes.rb +0 -6
- data/lib/pacer/side_effect.rb +0 -11
- data/lib/pacer/support.rb +0 -10
- data/lib/pacer/transform.rb +0 -16
- data/lib/pacer/visitors.rb +0 -7
- data/lib/pacer/wrappers.rb +0 -21
@@ -16,104 +16,125 @@ shared_examples_for 'a vertex with a mixin' do
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
context 'not found' do
|
30
|
-
subject { graph.vertex '-1' }
|
31
|
-
it { should be_nil }
|
32
|
-
end
|
33
|
-
|
34
|
-
subject { graph.vertex v0.element_id }
|
35
|
-
its(:element_id) { should == v0.element_id }
|
36
|
-
its(:graph) { should == graph }
|
19
|
+
Run.all :read_write do
|
20
|
+
describe Pacer::PacerGraph do
|
21
|
+
use_simple_graph_data
|
22
|
+
before { setup_data }
|
23
|
+
|
24
|
+
describe '#vertex' do
|
25
|
+
context 'not found' do
|
26
|
+
subject { graph.vertex '-1' }
|
27
|
+
it { should be_nil }
|
28
|
+
end
|
37
29
|
|
38
|
-
|
39
|
-
subject { graph.vertex v0.element_id, Tackle::SimpleMixin }
|
30
|
+
subject { graph.vertex v0.element_id }
|
40
31
|
its(:element_id) { should == v0.element_id }
|
41
|
-
|
42
|
-
end
|
32
|
+
its(:graph) { should == graph }
|
43
33
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
it_behaves_like 'a vertex with a mixin'
|
50
|
-
end
|
34
|
+
context 'with mixins' do
|
35
|
+
subject { graph.vertex v0.element_id, Tackle::SimpleMixin }
|
36
|
+
its(:element_id) { should == v0.element_id }
|
37
|
+
it_behaves_like 'a vertex with a mixin'
|
38
|
+
end
|
51
39
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
it_behaves_like 'a vertex with a mixin'
|
60
|
-
end
|
61
|
-
end
|
40
|
+
context 'with a wrapper' do
|
41
|
+
let(:wrapper) { Pacer.vertex_wrapper Tackle::SimpleMixin }
|
42
|
+
subject { graph.vertex v0.element_id, wrapper }
|
43
|
+
its(:element_id) { should == v0.element_id }
|
44
|
+
its(:class) { should == wrapper }
|
45
|
+
it_behaves_like 'a vertex with a mixin'
|
46
|
+
end
|
62
47
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
48
|
+
context 'with a wrapper and a mixin' do
|
49
|
+
let(:orig_wrapper) { Pacer.vertex_wrapper Tackle::SimpleMixin }
|
50
|
+
let(:wrapper) { Pacer.vertex_wrapper Tackle::SimpleMixin, TP::Person }
|
51
|
+
subject { graph.vertex v0.element_id, TP::Person, orig_wrapper }
|
52
|
+
its(:element_id) { should == v0.element_id }
|
53
|
+
its(:class) { should_not == orig_wrapper }
|
54
|
+
its(:class) { should == wrapper }
|
55
|
+
it_behaves_like 'a vertex with a mixin'
|
56
|
+
end
|
67
57
|
end
|
68
58
|
|
69
|
-
|
70
|
-
|
71
|
-
|
59
|
+
describe '#edge' do
|
60
|
+
context 'not found' do
|
61
|
+
subject { graph.edge '-1' }
|
62
|
+
it { should be_nil }
|
63
|
+
end
|
72
64
|
|
73
|
-
|
74
|
-
subject { graph.edge e0.element_id, Tackle::SimpleMixin }
|
65
|
+
subject { graph.edge e0.element_id }
|
75
66
|
its(:element_id) { should == e0.element_id }
|
76
|
-
|
77
|
-
end
|
67
|
+
its(:graph) { should == graph }
|
78
68
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
it_behaves_like 'an edge with a mixin'
|
85
|
-
end
|
69
|
+
context 'with mixins' do
|
70
|
+
subject { graph.edge e0.element_id, Tackle::SimpleMixin }
|
71
|
+
its(:element_id) { should == e0.element_id }
|
72
|
+
it_behaves_like 'an edge with a mixin'
|
73
|
+
end
|
86
74
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
75
|
+
context 'with a wrapper' do
|
76
|
+
let(:wrapper) { Pacer.edge_wrapper Tackle::SimpleMixin }
|
77
|
+
subject { graph.edge e0.element_id, wrapper }
|
78
|
+
its(:element_id) { should == e0.element_id }
|
79
|
+
its(:class) { should == wrapper }
|
80
|
+
it_behaves_like 'an edge with a mixin'
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'with a wrapper and a mixin' do
|
84
|
+
let(:orig_wrapper) { Pacer.edge_wrapper Tackle::SimpleMixin }
|
85
|
+
let(:wrapper) { Pacer.edge_wrapper Tackle::SimpleMixin, TP::Wrote }
|
86
|
+
subject { graph.edge e0.element_id, orig_wrapper, TP::Wrote }
|
87
|
+
its(:element_id) { should == e0.element_id }
|
88
|
+
its(:class) { should_not == orig_wrapper }
|
89
|
+
its(:class) { should == wrapper }
|
90
|
+
it_behaves_like 'an edge with a mixin'
|
91
|
+
end
|
95
92
|
end
|
96
|
-
end
|
97
93
|
|
98
|
-
|
99
|
-
|
94
|
+
describe '#create_vertex' do
|
95
|
+
let(:use_id) { rand 1000000 }
|
100
96
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
97
|
+
context 'existing' do
|
98
|
+
it 'should raise an exception' do
|
99
|
+
unless graph.features.ignoresSuppliedIds
|
100
|
+
expect { graph.create_vertex v0.element_id }.to raise_error(Pacer::ElementExists)
|
101
|
+
end
|
105
102
|
end
|
106
103
|
end
|
107
|
-
end
|
108
104
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
105
|
+
context 'with properties' do
|
106
|
+
subject { graph.create_vertex :name => 'Frank' }
|
107
|
+
it { subject[:name].should == 'Frank' }
|
108
|
+
its(:element_id) { should_not be_nil }
|
109
|
+
|
110
|
+
context 'and an id' do
|
111
|
+
subject { graph.create_vertex use_id, :name => 'Steve' }
|
112
|
+
it { subject[:name].should == 'Steve' }
|
113
|
+
its('element_id.to_s') do
|
114
|
+
if graph.respond_to? :id_prefix
|
115
|
+
should == graph.id_prefix + use_id.to_s
|
116
|
+
elsif not graph.features.ignoresSuppliedIds
|
117
|
+
should == use_id.to_s
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context 'and mixins' do
|
122
|
+
subject { graph.create_vertex use_id, Tackle::SimpleMixin, :name => 'John' }
|
123
|
+
it { subject[:name].should == 'John' }
|
124
|
+
its('element_id.to_s') do
|
125
|
+
if graph.respond_to? :id_prefix
|
126
|
+
should == graph.id_prefix + use_id.to_s
|
127
|
+
elsif not graph.features.ignoresSuppliedIds
|
128
|
+
should == use_id.to_s
|
129
|
+
end
|
130
|
+
end
|
131
|
+
it_behaves_like 'a vertex with a mixin'
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
113
135
|
|
114
|
-
context '
|
115
|
-
subject { graph.create_vertex use_id
|
116
|
-
it { subject[:name].should == 'Steve' }
|
136
|
+
context 'with an id' do
|
137
|
+
subject { graph.create_vertex use_id }
|
117
138
|
its('element_id.to_s') do
|
118
139
|
if graph.respond_to? :id_prefix
|
119
140
|
should == graph.id_prefix + use_id.to_s
|
@@ -123,8 +144,7 @@ shared_examples_for Pacer::RubyGraph do
|
|
123
144
|
end
|
124
145
|
|
125
146
|
context 'and mixins' do
|
126
|
-
subject { graph.create_vertex use_id, Tackle::SimpleMixin
|
127
|
-
it { subject[:name].should == 'John' }
|
147
|
+
subject { graph.create_vertex use_id, Tackle::SimpleMixin }
|
128
148
|
its('element_id.to_s') do
|
129
149
|
if graph.respond_to? :id_prefix
|
130
150
|
should == graph.id_prefix + use_id.to_s
|
@@ -135,333 +155,281 @@ shared_examples_for Pacer::RubyGraph do
|
|
135
155
|
it_behaves_like 'a vertex with a mixin'
|
136
156
|
end
|
137
157
|
end
|
138
|
-
end
|
139
158
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
if graph.respond_to? :id_prefix
|
144
|
-
should == graph.id_prefix + use_id.to_s
|
145
|
-
elsif not graph.features.ignoresSuppliedIds
|
146
|
-
should == use_id.to_s
|
147
|
-
end
|
159
|
+
context 'with mixins' do
|
160
|
+
subject { graph.create_vertex Tackle::SimpleMixin }
|
161
|
+
it_behaves_like 'a vertex with a mixin'
|
148
162
|
end
|
163
|
+
end
|
149
164
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
165
|
+
|
166
|
+
describe '#create_edge' do
|
167
|
+
let(:use_id) { rand 1000000 }
|
168
|
+
let(:from) { graph.vertex v0.element_id }
|
169
|
+
let(:to) { graph.vertex v1.element_id }
|
170
|
+
|
171
|
+
context 'existing' do
|
172
|
+
it 'should raise an exception' do
|
173
|
+
if not graph.features.ignoresSuppliedIds
|
174
|
+
expect { graph.create_edge e0.element_id, from, to, :connects }.to raise_error(Pacer::ElementExists)
|
157
175
|
end
|
158
176
|
end
|
159
|
-
it_behaves_like 'a vertex with a mixin'
|
160
177
|
end
|
161
|
-
end
|
162
|
-
|
163
|
-
context 'with mixins' do
|
164
|
-
subject { graph.create_vertex Tackle::SimpleMixin }
|
165
|
-
it_behaves_like 'a vertex with a mixin'
|
166
|
-
end
|
167
|
-
end
|
168
178
|
|
179
|
+
context 'with properties' do
|
180
|
+
subject { graph.create_edge nil, from, to, :connects, :name => 'Frank' }
|
181
|
+
it { subject[:name].should == 'Frank' }
|
182
|
+
its(:label) { should == 'connects' }
|
183
|
+
its(:element_id) { should_not be_nil }
|
169
184
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
185
|
+
context 'and an id' do
|
186
|
+
subject { graph.create_edge use_id, from, to, :connects, :name => 'Steve' }
|
187
|
+
it { subject[:name].should == 'Steve' }
|
188
|
+
its(:label) { should == 'connects' }
|
189
|
+
its('element_id.to_i') { should == use_id unless graph.features.ignoresSuppliedIds }
|
174
190
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
191
|
+
context 'and mixins' do
|
192
|
+
subject { graph.create_edge use_id, from, to, :connects, Tackle::SimpleMixin, :name => 'John' }
|
193
|
+
it { subject[:name].should == 'John' }
|
194
|
+
its(:label) { should == 'connects' }
|
195
|
+
its('element_id.to_i') { should == use_id unless graph.features.ignoresSuppliedIds }
|
196
|
+
it_behaves_like 'an edge with a mixin'
|
197
|
+
end
|
179
198
|
end
|
180
199
|
end
|
181
|
-
end
|
182
|
-
|
183
|
-
context 'with properties' do
|
184
|
-
subject { graph.create_edge nil, from, to, :connects, :name => 'Frank' }
|
185
|
-
it { subject[:name].should == 'Frank' }
|
186
|
-
its(:label) { should == 'connects' }
|
187
|
-
its(:element_id) { should_not be_nil }
|
188
200
|
|
189
|
-
context '
|
190
|
-
subject { graph.create_edge use_id, from, to, :connects
|
191
|
-
it { subject[:name].should == 'Steve' }
|
201
|
+
context 'with an id' do
|
202
|
+
subject { graph.create_edge use_id, from, to, :connects }
|
192
203
|
its(:label) { should == 'connects' }
|
193
204
|
its('element_id.to_i') { should == use_id unless graph.features.ignoresSuppliedIds }
|
194
205
|
|
195
206
|
context 'and mixins' do
|
196
|
-
subject { graph.create_edge use_id, from, to, :connects, Tackle::SimpleMixin
|
197
|
-
it { subject[:name].should == 'John' }
|
207
|
+
subject { graph.create_edge use_id, from, to, :connects, Tackle::SimpleMixin }
|
198
208
|
its(:label) { should == 'connects' }
|
199
209
|
its('element_id.to_i') { should == use_id unless graph.features.ignoresSuppliedIds }
|
200
210
|
it_behaves_like 'an edge with a mixin'
|
201
211
|
end
|
202
212
|
end
|
203
|
-
end
|
204
|
-
|
205
|
-
context 'with an id' do
|
206
|
-
subject { graph.create_edge use_id, from, to, :connects }
|
207
|
-
its(:label) { should == 'connects' }
|
208
|
-
its('element_id.to_i') { should == use_id unless graph.features.ignoresSuppliedIds }
|
209
213
|
|
210
|
-
context '
|
211
|
-
subject { graph.create_edge
|
214
|
+
context 'with mixins' do
|
215
|
+
subject { graph.create_edge nil, from, to, :connects, Tackle::SimpleMixin }
|
212
216
|
its(:label) { should == 'connects' }
|
213
|
-
its('element_id.to_i') { should == use_id unless graph.features.ignoresSuppliedIds }
|
214
217
|
it_behaves_like 'an edge with a mixin'
|
215
218
|
end
|
216
219
|
end
|
217
220
|
|
218
|
-
|
219
|
-
subject { graph.
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
describe 'default' do
|
228
|
-
it { should == 5000 }
|
229
|
-
end
|
230
|
-
describe 'custom' do
|
231
|
-
before { graph.bulk_job_size = 12 }
|
232
|
-
it { should == 12 }
|
221
|
+
describe '#bulk_job_size' do
|
222
|
+
subject { graph.bulk_job_size }
|
223
|
+
describe 'default' do
|
224
|
+
it { should == 5000 }
|
225
|
+
end
|
226
|
+
describe 'custom' do
|
227
|
+
before { graph.bulk_job_size = 12 }
|
228
|
+
it { should == 12 }
|
229
|
+
end
|
233
230
|
end
|
234
|
-
end
|
235
231
|
|
236
|
-
|
237
|
-
|
238
|
-
|
232
|
+
describe '#in_bulk_job?' do
|
233
|
+
subject { graph.in_bulk_job? }
|
234
|
+
it { should be_false }
|
239
235
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
236
|
+
context 'in bulk job' do
|
237
|
+
around do |spec|
|
238
|
+
graph.v[0].bulk_job do
|
239
|
+
spec.call
|
240
|
+
end
|
244
241
|
end
|
242
|
+
it { should be_true }
|
245
243
|
end
|
246
|
-
it { should be_true }
|
247
244
|
end
|
248
|
-
end
|
249
245
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
246
|
+
describe '#load_vertices' do
|
247
|
+
context 'invalid' do
|
248
|
+
subject { graph.load_vertices [v0.element_id, nil, v0.element_id, 'missing'] }
|
249
|
+
it { should == [v0, v0] }
|
250
|
+
end
|
255
251
|
|
256
|
-
|
257
|
-
|
258
|
-
|
252
|
+
context 'valid' do
|
253
|
+
subject { graph.load_vertices [v0.element_id, v1.element_id] }
|
254
|
+
it { should == [v0, v1] }
|
255
|
+
end
|
259
256
|
end
|
260
|
-
end
|
261
257
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
258
|
+
describe '#load_edges' do
|
259
|
+
before do
|
260
|
+
c = example.metadata[:graph_commit]
|
261
|
+
c.call if c
|
262
|
+
end
|
263
|
+
context 'invalid' do
|
264
|
+
subject { graph.load_edges [e0.element_id, nil, e0.element_id, 'missing'] }
|
265
|
+
it { should == [e0, e0] }
|
266
|
+
end
|
271
267
|
|
272
|
-
|
273
|
-
|
274
|
-
|
268
|
+
context 'valid' do
|
269
|
+
subject { graph.load_edges [e0.element_id] }
|
270
|
+
it { should == [e0] }
|
271
|
+
end
|
275
272
|
end
|
276
|
-
end
|
277
273
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
274
|
+
describe '#index' do
|
275
|
+
it 'should have no indices' do
|
276
|
+
graph.indices.count.should == 0 if graph.features.supportsKeyIndices
|
277
|
+
end
|
282
278
|
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
279
|
+
context 'missing' do
|
280
|
+
around { |spec| spec.run if graph.features.supportsIndices }
|
281
|
+
subject { graph.index 'invalid' }
|
282
|
+
it { should be_nil }
|
283
|
+
context 'edge' do
|
284
|
+
before do
|
285
|
+
graph.drop_index 'missing_edge' rescue nil
|
286
|
+
graph.index('missing_edge').should be_nil
|
287
|
+
end
|
288
|
+
subject { graph.index 'missing_edge', :edge, :create => true }
|
289
|
+
its(:name) { should == 'missing_edge' }
|
290
|
+
after do
|
291
|
+
graph.transaction(nesting: true) do
|
292
|
+
graph.drop_index 'missing_edge'
|
293
|
+
end
|
297
294
|
end
|
298
295
|
end
|
299
|
-
end
|
300
296
|
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
297
|
+
context 'vertex' do
|
298
|
+
before do
|
299
|
+
graph.drop_index 'missing_vertex' rescue nil
|
300
|
+
graph.index('missing_vertex').should be_nil
|
301
|
+
end
|
302
|
+
subject { graph.index 'missing_vertex', :vertex, :create => true }
|
303
|
+
its(:name) { should == 'missing_vertex' }
|
304
|
+
after do
|
305
|
+
graph.transaction(nesting: true) do
|
306
|
+
graph.drop_index 'missing_vertex'
|
307
|
+
end
|
311
308
|
end
|
312
309
|
end
|
313
310
|
end
|
314
311
|
end
|
315
|
-
end
|
316
312
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
313
|
+
describe '#graph' do
|
314
|
+
subject { graph.graph }
|
315
|
+
it { should == graph }
|
316
|
+
end
|
321
317
|
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
318
|
+
describe '#vertex_name' do
|
319
|
+
before { graph.vertex_name = :some_proc }
|
320
|
+
subject { graph.vertex_name }
|
321
|
+
it { should == :some_proc }
|
322
|
+
after { graph.vertex_name = nil }
|
323
|
+
end
|
328
324
|
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
325
|
+
describe '#edge_name' do
|
326
|
+
before { graph.edge_name = :some_proc }
|
327
|
+
subject { graph.edge_name }
|
328
|
+
it { should == :some_proc }
|
329
|
+
after { graph.edge_name = nil }
|
330
|
+
end
|
331
|
+
|
332
|
+
describe '#import' do
|
333
|
+
it 'should load the data into an empty graph' do
|
334
|
+
graph2.v.delete!
|
335
|
+
graph2.v.count.should == 0
|
336
|
+
Pacer::GraphML.import graph2, 'spec/data/pacer.graphml'
|
337
|
+
graph2.v.count.should == 7
|
338
|
+
graph2.e.count.should == 14
|
339
|
+
end
|
335
340
|
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
341
|
+
it 'should not load the data into a graph with conflicting vertex ids' do
|
342
|
+
unless graph.features.ignoresSuppliedIds
|
343
|
+
graph.create_vertex '0' unless graph.vertex '0'
|
344
|
+
expect { Pacer::GraphML.import graph, 'spec/data/pacer.graphml' }.to raise_error(Pacer::ElementExists)
|
345
|
+
end
|
346
|
+
end
|
342
347
|
end
|
343
348
|
|
344
|
-
|
345
|
-
|
346
|
-
graph.
|
347
|
-
|
349
|
+
describe '#export' do
|
350
|
+
it 'should create a file that can be read back' do
|
351
|
+
graph.v.count.should == 2
|
352
|
+
graph.e.count.should == 2
|
353
|
+
Pacer::GraphML.export graph, 'tmp/graph_mixin_spec_export.graphml'
|
354
|
+
graph2.e.delete!
|
355
|
+
graph2.v.delete!
|
356
|
+
graph2.v.count.should == 0
|
357
|
+
graph2.e.count.should == 0
|
358
|
+
Pacer::GraphML.import graph2, 'tmp/graph_mixin_spec_export.graphml'
|
359
|
+
puts File.read 'tmp/graph_mixin_spec_export.graphml'
|
360
|
+
graph2.v.count.should == 2
|
361
|
+
graph2.e.count.should == 2
|
348
362
|
end
|
349
363
|
end
|
350
|
-
end
|
351
364
|
|
352
|
-
|
353
|
-
|
354
|
-
|
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
|
365
|
+
describe '#indices' do
|
366
|
+
subject { graph.indices.to_a }
|
367
|
+
it { should be_empty }
|
365
368
|
end
|
366
|
-
end
|
367
369
|
|
368
|
-
|
370
|
+
describe '#element_type' do
|
371
|
+
context 'invalid' do
|
372
|
+
it { expect { graph.element_type(:nothing) }.to raise_error(ArgumentError) }
|
373
|
+
end
|
369
374
|
|
375
|
+
context ':vertex' do
|
376
|
+
subject { graph.element_type(:vertex) }
|
377
|
+
it { should == :vertex }
|
378
|
+
end
|
370
379
|
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
380
|
+
context 'a vertex' do
|
381
|
+
subject { graph.element_type(v0) }
|
382
|
+
it { should == :vertex }
|
383
|
+
end
|
375
384
|
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
385
|
+
context ':edge' do
|
386
|
+
subject { graph.element_type(:edge) }
|
387
|
+
it { should == :edge }
|
388
|
+
end
|
380
389
|
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
390
|
+
context 'an edge' do
|
391
|
+
subject { graph.element_type(e0) }
|
392
|
+
it { should == :edge }
|
393
|
+
end
|
385
394
|
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
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
|
395
|
+
context ':mixed' do
|
396
|
+
subject { graph.element_type(:mixed) }
|
397
|
+
it { should == :mixed }
|
398
|
+
end
|
395
399
|
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
+
context ':object' do
|
401
|
+
subject { graph.element_type(:object) }
|
402
|
+
it { should == :object }
|
403
|
+
end
|
400
404
|
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
it
|
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
|
405
|
+
context 'from element_type' do
|
406
|
+
context ':vertex' do
|
407
|
+
subject { graph.element_type(graph.element_type :vertex) }
|
408
|
+
it { should == :vertex }
|
414
409
|
end
|
415
410
|
|
416
|
-
context '
|
417
|
-
|
418
|
-
|
419
|
-
|
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
|
425
|
-
|
426
|
-
after do
|
427
|
-
graph.drop_index :edges
|
428
|
-
graph.v.delete!
|
429
|
-
end
|
411
|
+
context ':edge' do
|
412
|
+
subject { graph.element_type(graph.element_type :edge) }
|
413
|
+
it { should == :edge }
|
414
|
+
end
|
430
415
|
|
416
|
+
context ':mixed' do
|
417
|
+
subject { graph.element_type(graph.element_type :mixed) }
|
418
|
+
it { should == :mixed }
|
419
|
+
end
|
431
420
|
|
432
|
-
|
433
|
-
subject {
|
434
|
-
it {
|
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
|
421
|
+
context ':object' do
|
422
|
+
subject { graph.element_type(graph.element_type :object) }
|
423
|
+
it { should == :object }
|
445
424
|
end
|
446
425
|
end
|
447
|
-
end
|
448
|
-
end
|
449
|
-
end
|
450
426
|
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
it 'should not raise an exception for invalid key type' do
|
458
|
-
graph.vertex('bad id').should be_nil
|
459
|
-
end
|
460
|
-
end
|
461
|
-
|
462
|
-
describe '#edge' do
|
463
|
-
it 'should not raise an exception for invalid key type' do
|
464
|
-
graph.edge('bad id').should be_nil
|
427
|
+
context 'from index_class' do
|
428
|
+
context ':vertex' do
|
429
|
+
subject { graph.element_type(graph.index_class :vertex) }
|
430
|
+
it { should == :vertex }
|
431
|
+
end
|
432
|
+
end
|
465
433
|
end
|
466
434
|
end
|
467
435
|
end
|