pacer 0.9.1.1-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 +8 -0
- data/.document +5 -0
- data/.gitignore +26 -0
- data/.rspec +1 -0
- data/.rvmrc +0 -0
- data/CONTRIBUTORS +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +24 -0
- data/README.md +187 -0
- data/Rakefile +49 -0
- data/autotest/discover.rb +1 -0
- data/bin/autospec +16 -0
- data/bin/autotest +16 -0
- data/bin/rake +16 -0
- data/bin/rcov +16 -0
- data/bin/rspec +16 -0
- data/bin/yard +16 -0
- data/bin/yardoc +16 -0
- data/lib/pacer/blueprints/extensions.rb +77 -0
- data/lib/pacer/blueprints/multi_graph.rb +121 -0
- data/lib/pacer/blueprints/ruby_graph.rb +199 -0
- data/lib/pacer/blueprints/tg.rb +100 -0
- data/lib/pacer/blueprints.rb +4 -0
- data/lib/pacer/core/graph/edges_route.rb +92 -0
- data/lib/pacer/core/graph/element_route.rb +171 -0
- data/lib/pacer/core/graph/graph_index_route.rb +48 -0
- data/lib/pacer/core/graph/graph_route.rb +55 -0
- data/lib/pacer/core/graph/mixed_route.rb +96 -0
- data/lib/pacer/core/graph/vertices_route.rb +220 -0
- data/lib/pacer/core/graph.rb +13 -0
- data/lib/pacer/core/route.rb +502 -0
- data/lib/pacer/core/side_effect.rb +11 -0
- data/lib/pacer/core.rb +8 -0
- data/lib/pacer/exceptions.rb +11 -0
- data/lib/pacer/extensions/block_filter_element.rb +22 -0
- data/lib/pacer/extensions.rb +6 -0
- data/lib/pacer/filter/block_filter.rb +31 -0
- data/lib/pacer/filter/collection_filter.rb +109 -0
- data/lib/pacer/filter/empty_filter.rb +70 -0
- data/lib/pacer/filter/future_filter.rb +68 -0
- data/lib/pacer/filter/index_filter.rb +30 -0
- data/lib/pacer/filter/loop_filter.rb +95 -0
- data/lib/pacer/filter/object_filter.rb +55 -0
- data/lib/pacer/filter/property_filter/edge_filters.rb +93 -0
- data/lib/pacer/filter/property_filter/filters.rb +269 -0
- data/lib/pacer/filter/property_filter.rb +111 -0
- data/lib/pacer/filter/random_filter.rb +13 -0
- data/lib/pacer/filter/range_filter.rb +104 -0
- data/lib/pacer/filter/uniq_filter.rb +12 -0
- data/lib/pacer/filter/where_filter/node_visitor.rb +280 -0
- data/lib/pacer/filter/where_filter.rb +47 -0
- data/lib/pacer/filter.rb +17 -0
- data/lib/pacer/function_resolver.rb +43 -0
- data/lib/pacer/graph/edge_mixin.rb +127 -0
- data/lib/pacer/graph/element_mixin.rb +202 -0
- data/lib/pacer/graph/graph_indices_mixin.rb +93 -0
- data/lib/pacer/graph/graph_mixin.rb +361 -0
- data/lib/pacer/graph/graph_transactions_mixin.rb +207 -0
- data/lib/pacer/graph/index_mixin.rb +30 -0
- data/lib/pacer/graph/vertex_mixin.rb +119 -0
- data/lib/pacer/graph.rb +14 -0
- data/lib/pacer/pipe/blackbox_pipeline.rb +48 -0
- data/lib/pacer/pipe/block_filter_pipe.rb +38 -0
- data/lib/pacer/pipe/collection_filter_pipe.rb +10 -0
- data/lib/pacer/pipe/cross_product_transform_pipe.rb +48 -0
- data/lib/pacer/pipe/enumerable_pipe.rb +30 -0
- data/lib/pacer/pipe/expandable_pipe.rb +63 -0
- data/lib/pacer/pipe/id_collection_filter_pipe.rb +33 -0
- data/lib/pacer/pipe/is_empty_pipe.rb +30 -0
- data/lib/pacer/pipe/is_unique_pipe.rb +61 -0
- data/lib/pacer/pipe/label_collection_filter_pipe.rb +21 -0
- data/lib/pacer/pipe/label_prefix_pipe.rb +21 -0
- data/lib/pacer/pipe/loop_pipe.rb +86 -0
- data/lib/pacer/pipe/map_pipe.rb +36 -0
- data/lib/pacer/pipe/never_pipe.rb +9 -0
- data/lib/pacer/pipe/process_pipe.rb +37 -0
- data/lib/pacer/pipe/property_comparison_pipe.rb +40 -0
- data/lib/pacer/pipe/ruby_pipe.rb +25 -0
- data/lib/pacer/pipe/simple_visitor_pipe.rb +43 -0
- data/lib/pacer/pipe/stream_sort_pipe.rb +84 -0
- data/lib/pacer/pipe/stream_uniq_pipe.rb +33 -0
- data/lib/pacer/pipe/type_filter_pipe.rb +22 -0
- data/lib/pacer/pipe/unary_transform_pipe.rb +59 -0
- data/lib/pacer/pipe/variable_store_iterator_wrapper.rb +26 -0
- data/lib/pacer/pipe/visitor_pipe.rb +67 -0
- data/lib/pacer/pipes.rb +61 -0
- data/lib/pacer/route/mixin/bulk_operations.rb +52 -0
- data/lib/pacer/route/mixin/route_operations.rb +107 -0
- data/lib/pacer/route/mixin/variable_route_module.rb +26 -0
- data/lib/pacer/route/mixins.rb +3 -0
- data/lib/pacer/route.rb +228 -0
- data/lib/pacer/routes.rb +6 -0
- data/lib/pacer/side_effect/aggregate.rb +31 -0
- data/lib/pacer/side_effect/counted.rb +30 -0
- data/lib/pacer/side_effect/group_count.rb +44 -0
- data/lib/pacer/side_effect/is_unique.rb +32 -0
- data/lib/pacer/side_effect/section.rb +25 -0
- data/lib/pacer/side_effect/visitor.rb +37 -0
- data/lib/pacer/side_effect.rb +11 -0
- data/lib/pacer/support/array_list.rb +28 -0
- data/lib/pacer/support/enumerable.rb +100 -0
- data/lib/pacer/support/hash.rb +9 -0
- data/lib/pacer/support/iterator_mixins.rb +110 -0
- data/lib/pacer/support/native_exception.rb +22 -0
- data/lib/pacer/support/proc.rb +16 -0
- data/lib/pacer/support.rb +10 -0
- data/lib/pacer/transform/cap.rb +50 -0
- data/lib/pacer/transform/gather.rb +9 -0
- data/lib/pacer/transform/has_count_cap.rb +41 -0
- data/lib/pacer/transform/join.rb +181 -0
- data/lib/pacer/transform/map.rb +23 -0
- data/lib/pacer/transform/path.rb +50 -0
- data/lib/pacer/transform/process.rb +23 -0
- data/lib/pacer/transform/scatter.rb +23 -0
- data/lib/pacer/transform/sort_section.rb +103 -0
- data/lib/pacer/transform/stream_sort.rb +21 -0
- data/lib/pacer/transform/stream_uniq.rb +21 -0
- data/lib/pacer/transform.rb +16 -0
- data/lib/pacer/utils/graph_analysis.rb +112 -0
- data/lib/pacer/utils/trie.rb +93 -0
- data/lib/pacer/utils/tsort.rb +65 -0
- data/lib/pacer/utils/y_files.rb +127 -0
- data/lib/pacer/utils.rb +10 -0
- data/lib/pacer/version.rb +13 -0
- data/lib/pacer/wrappers/edge_wrapper.rb +51 -0
- data/lib/pacer/wrappers/element_wrapper.rb +78 -0
- data/lib/pacer/wrappers/new_element.rb +106 -0
- data/lib/pacer/wrappers/vertex_wrapper.rb +51 -0
- data/lib/pacer/wrappers.rb +19 -0
- data/lib/pacer-0.9.1.1-standalone.jar +0 -0
- data/lib/pacer.rb +290 -0
- data/pacer.gemspec +30 -0
- data/pom/standalone.xml +22 -0
- data/pom.xml +124 -0
- data/samples/grateful-dead.xml +26380 -0
- data/samples/grateful_dead.rb +63 -0
- data/samples/profile.rb +15 -0
- data/spec/data/grateful-dead.xml +26380 -0
- data/spec/data/pacer.graphml +319 -0
- data/spec/pacer/blueprints/dex_spec.rb +172 -0
- data/spec/pacer/blueprints/neo4j_spec.rb +177 -0
- data/spec/pacer/blueprints/tg_spec.rb +128 -0
- data/spec/pacer/core/graph/edges_route_spec.rb +52 -0
- data/spec/pacer/core/graph/element_route_spec.rb +46 -0
- data/spec/pacer/core/graph/graph_route_spec.rb +94 -0
- data/spec/pacer/core/graph/vertices_route_spec.rb +169 -0
- data/spec/pacer/core/route_spec.rb +197 -0
- data/spec/pacer/filter/collection_filter_spec.rb +19 -0
- data/spec/pacer/filter/empty_filter_spec.rb +29 -0
- data/spec/pacer/filter/future_filter_spec.rb +97 -0
- data/spec/pacer/filter/loop_filter_spec.rb +31 -0
- data/spec/pacer/filter/property_filter_spec.rb +111 -0
- data/spec/pacer/filter/random_filter_spec.rb +17 -0
- data/spec/pacer/filter/uniq_filter_spec.rb +18 -0
- data/spec/pacer/filter/where_filter_spec.rb +93 -0
- data/spec/pacer/graph/edge_mixin_spec.rb +116 -0
- data/spec/pacer/graph/element_mixin_spec.rb +297 -0
- data/spec/pacer/graph/graph_mixin_spec.rb +538 -0
- data/spec/pacer/graph/index_mixin_spec.rb +0 -0
- data/spec/pacer/graph/vertex_mixin_spec.rb +192 -0
- data/spec/pacer/pipe/block_filter_pipe_spec.rb +0 -0
- data/spec/pacer/pipe/labels_filter_pipe_spec.rb +0 -0
- data/spec/pacer/pipe/ruby_pipe_spec.rb +0 -0
- data/spec/pacer/pipe/type_filter_pipe_spec.rb +0 -0
- data/spec/pacer/route/mixin/base_spec.rb +419 -0
- data/spec/pacer/route/mixin/bulk_operations_spec.rb +30 -0
- data/spec/pacer/route/mixin/route_operations_spec.rb +127 -0
- data/spec/pacer/support/array_list_spec.rb +0 -0
- data/spec/pacer/support/enumerable_spec.rb +115 -0
- data/spec/pacer/transform/join_spec.rb +138 -0
- data/spec/pacer/transform/path_spec.rb +54 -0
- data/spec/pacer/utils/tsort_spec.rb +89 -0
- data/spec/pacer/wrapper/edge_wrapper_spec.rb +33 -0
- data/spec/pacer/wrapper/element_wrapper_spec.rb +169 -0
- data/spec/pacer/wrapper/vertex_wrapper_spec.rb +33 -0
- data/spec/pacer_spec.rb +0 -0
- data/spec/spec_helper.rb +91 -0
- data/spec/support/contexts.rb +14 -0
- data/spec/support/graph_runner.rb +142 -0
- data/spec/support/matchers.rb +19 -0
- data/spec/support/use_transactions.rb +31 -0
- data/spec/tackle/simple_mixin.rb +21 -0
- data/spec/tackle/tinkerpop_graph_mixins.rb +60 -0
- metadata +364 -0
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
shared_examples_for 'an edge with a mixin' do
|
|
4
|
+
its(:route_mixin_method) { should be_true }
|
|
5
|
+
its(:edge_mixin_method) { should be_true }
|
|
6
|
+
it 'should not include the Vertex module' do
|
|
7
|
+
expect { subject.vertex_mixin_method }.to raise_error(NoMethodError)
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
shared_examples_for 'a vertex with a mixin' do
|
|
12
|
+
its(:route_mixin_method) { should be_true }
|
|
13
|
+
its(:vertex_mixin_method) { should be_true }
|
|
14
|
+
it 'should not include the Edge module' do
|
|
15
|
+
expect { subject.edge_mixin_method }.to raise_error(NoMethodError)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
shared_examples_for Pacer::GraphMixin do
|
|
20
|
+
let(:v0) { graph.create_vertex }
|
|
21
|
+
let(:v1) { graph.create_vertex }
|
|
22
|
+
let(:e0) { graph.create_edge nil, v0, v1, :links }
|
|
23
|
+
let(:e1) { graph.create_edge nil, v0, v1, :relinks }
|
|
24
|
+
before do
|
|
25
|
+
e0 # force edge and vertices to be created.
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe '#vertex' do
|
|
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 }
|
|
37
|
+
|
|
38
|
+
context 'with mixins' do
|
|
39
|
+
subject { graph.vertex v0.element_id, Tackle::SimpleMixin }
|
|
40
|
+
its(:element_id) { should == v0.element_id }
|
|
41
|
+
it_behaves_like 'a vertex with a mixin'
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
context 'with a wrapper' do
|
|
45
|
+
let(:wrapper) { Pacer.vertex_wrapper Tackle::SimpleMixin }
|
|
46
|
+
subject { graph.vertex v0.element_id, wrapper }
|
|
47
|
+
its(:element_id) { should == v0.element_id }
|
|
48
|
+
its(:class) { should == wrapper }
|
|
49
|
+
it_behaves_like 'a vertex with a mixin'
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context 'with a wrapper and a mixin' do
|
|
53
|
+
let(:orig_wrapper) { Pacer.vertex_wrapper Tackle::SimpleMixin }
|
|
54
|
+
let(:wrapper) { Pacer.vertex_wrapper Tackle::SimpleMixin, TP::Person }
|
|
55
|
+
subject { graph.vertex v0.element_id, TP::Person, orig_wrapper }
|
|
56
|
+
its(:element_id) { should == v0.element_id }
|
|
57
|
+
its(:class) { should_not == orig_wrapper }
|
|
58
|
+
its(:class) { should == wrapper }
|
|
59
|
+
it_behaves_like 'a vertex with a mixin'
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
describe '#edge' do
|
|
64
|
+
context 'not found' do
|
|
65
|
+
subject { graph.edge '-1' }
|
|
66
|
+
it { should be_nil }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
subject { graph.edge e0.element_id }
|
|
70
|
+
its(:element_id) { should == e0.element_id }
|
|
71
|
+
its(:graph) { should == graph }
|
|
72
|
+
|
|
73
|
+
context 'with mixins' do
|
|
74
|
+
subject { graph.edge e0.element_id, Tackle::SimpleMixin }
|
|
75
|
+
its(:element_id) { should == e0.element_id }
|
|
76
|
+
it_behaves_like 'an edge with a mixin'
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
context 'with a wrapper' do
|
|
80
|
+
let(:wrapper) { Pacer.edge_wrapper Tackle::SimpleMixin }
|
|
81
|
+
subject { graph.edge e0.element_id, wrapper }
|
|
82
|
+
its(:element_id) { should == e0.element_id }
|
|
83
|
+
its(:class) { should == wrapper }
|
|
84
|
+
it_behaves_like 'an edge with a mixin'
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
context 'with a wrapper and a mixin' do
|
|
88
|
+
let(:orig_wrapper) { Pacer.edge_wrapper Tackle::SimpleMixin }
|
|
89
|
+
let(:wrapper) { Pacer.edge_wrapper Tackle::SimpleMixin, TP::Wrote }
|
|
90
|
+
subject { graph.edge e0.element_id, orig_wrapper, TP::Wrote }
|
|
91
|
+
its(:element_id) { should == e0.element_id }
|
|
92
|
+
its(:class) { should_not == orig_wrapper }
|
|
93
|
+
its(:class) { should == wrapper }
|
|
94
|
+
it_behaves_like 'an edge with a mixin'
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
describe '#create_vertex' do
|
|
99
|
+
context 'existing' do
|
|
100
|
+
it 'should raise an exception' do
|
|
101
|
+
if graph.supports_custom_element_ids?
|
|
102
|
+
expect { graph.create_vertex v0.element_id }.to raise_error(Pacer::ElementExists)
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
context 'with properties' do
|
|
108
|
+
subject { graph.create_vertex :name => 'Frank' }
|
|
109
|
+
it { subject[:name].should == 'Frank' }
|
|
110
|
+
its(:element_id) { should_not be_nil }
|
|
111
|
+
|
|
112
|
+
context 'and an id' do
|
|
113
|
+
subject { graph.create_vertex 1234, :name => 'Steve' }
|
|
114
|
+
it { subject[:name].should == 'Steve' }
|
|
115
|
+
its('element_id.to_s') do
|
|
116
|
+
if graph.respond_to? :id_prefix
|
|
117
|
+
should == graph.id_prefix + '1234'
|
|
118
|
+
elsif graph.supports_custom_element_ids?
|
|
119
|
+
should == '1234'
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
context 'and mixins' do
|
|
124
|
+
subject { graph.create_vertex 1234, Tackle::SimpleMixin, :name => 'John' }
|
|
125
|
+
it { subject[:name].should == 'John' }
|
|
126
|
+
its('element_id.to_s') do
|
|
127
|
+
if graph.respond_to? :id_prefix
|
|
128
|
+
should == graph.id_prefix + '1234'
|
|
129
|
+
elsif graph.supports_custom_element_ids?
|
|
130
|
+
should == '1234'
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
it_behaves_like 'a vertex with a mixin'
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
context 'with an id' do
|
|
139
|
+
subject { graph.create_vertex 1234 }
|
|
140
|
+
its('element_id.to_s') do
|
|
141
|
+
if graph.respond_to? :id_prefix
|
|
142
|
+
should == graph.id_prefix + '1234'
|
|
143
|
+
elsif graph.supports_custom_element_ids?
|
|
144
|
+
should == '1234'
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
context 'and mixins' do
|
|
149
|
+
subject { graph.create_vertex 1234, Tackle::SimpleMixin }
|
|
150
|
+
its('element_id.to_s') do
|
|
151
|
+
if graph.respond_to? :id_prefix
|
|
152
|
+
should == graph.id_prefix + '1234'
|
|
153
|
+
elsif graph.supports_custom_element_ids?
|
|
154
|
+
should == '1234'
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
it_behaves_like 'a vertex with a mixin'
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
context 'with mixins' do
|
|
162
|
+
subject { graph.create_vertex Tackle::SimpleMixin }
|
|
163
|
+
it_behaves_like 'a vertex with a mixin'
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
describe '#create_edge' do
|
|
169
|
+
let(:from) { graph.vertex v0.element_id }
|
|
170
|
+
let(:to) { graph.vertex v1.element_id }
|
|
171
|
+
|
|
172
|
+
context 'existing' do
|
|
173
|
+
it 'should raise an exception' do
|
|
174
|
+
if graph.supports_custom_element_ids?
|
|
175
|
+
expect { graph.create_edge e0.element_id, from, to, :connects }.to raise_error(Pacer::ElementExists)
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
context 'with properties' do
|
|
181
|
+
subject { graph.create_edge nil, from, to, :connects, :name => 'Frank' }
|
|
182
|
+
it { subject[:name].should == 'Frank' }
|
|
183
|
+
its(:label) { should == 'connects' }
|
|
184
|
+
its(:element_id) { should_not be_nil }
|
|
185
|
+
|
|
186
|
+
context 'and an id' do
|
|
187
|
+
subject { graph.create_edge 1234, from, to, :connects, :name => 'Steve' }
|
|
188
|
+
it { subject[:name].should == 'Steve' }
|
|
189
|
+
its(:label) { should == 'connects' }
|
|
190
|
+
its('element_id.to_i') { should == 1234 if graph.supports_custom_element_ids? }
|
|
191
|
+
|
|
192
|
+
context 'and mixins' do
|
|
193
|
+
subject { graph.create_edge 1234, from, to, :connects, Tackle::SimpleMixin, :name => 'John' }
|
|
194
|
+
it { subject[:name].should == 'John' }
|
|
195
|
+
its(:label) { should == 'connects' }
|
|
196
|
+
its('element_id.to_i') { should == 1234 if graph.supports_custom_element_ids? }
|
|
197
|
+
it_behaves_like 'an edge with a mixin'
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
context 'with an id' do
|
|
203
|
+
subject { graph.create_edge 1234, from, to, :connects }
|
|
204
|
+
its(:label) { should == 'connects' }
|
|
205
|
+
its('element_id.to_i') { should == 1234 if graph.supports_custom_element_ids? }
|
|
206
|
+
|
|
207
|
+
context 'and mixins' do
|
|
208
|
+
subject { graph.create_edge 1234, from, to, :connects, Tackle::SimpleMixin }
|
|
209
|
+
its(:label) { should == 'connects' }
|
|
210
|
+
its('element_id.to_i') { should == 1234 if graph.supports_custom_element_ids? }
|
|
211
|
+
it_behaves_like 'an edge with a mixin'
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
context 'with mixins' do
|
|
216
|
+
subject { graph.create_edge nil, from, to, :connects, Tackle::SimpleMixin }
|
|
217
|
+
its(:label) { should == 'connects' }
|
|
218
|
+
it_behaves_like 'an edge with a mixin'
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
describe '#bulk_job_size' do
|
|
223
|
+
subject { graph.bulk_job_size }
|
|
224
|
+
describe 'default' do
|
|
225
|
+
it { should == 5000 }
|
|
226
|
+
end
|
|
227
|
+
describe 'custom' do
|
|
228
|
+
before { graph.bulk_job_size = 12 }
|
|
229
|
+
it { should == 12 }
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
describe '#in_bulk_job?' do
|
|
234
|
+
subject { graph.in_bulk_job? }
|
|
235
|
+
it { should be_false }
|
|
236
|
+
|
|
237
|
+
context 'in bulk job' do
|
|
238
|
+
around do |spec|
|
|
239
|
+
graph.v[0].bulk_job do
|
|
240
|
+
spec.call
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
it { should be_true }
|
|
244
|
+
end
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
describe '#load_vertices' do
|
|
248
|
+
context 'invalid' do
|
|
249
|
+
subject { graph.load_vertices [v0.element_id, nil, v0.element_id, 'missing'] }
|
|
250
|
+
it { should == [v0, v0] }
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
context 'valid' do
|
|
254
|
+
subject { graph.load_vertices [v0.element_id, v1.element_id] }
|
|
255
|
+
it { should == [v0, v1] }
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
describe '#load_edges' do
|
|
260
|
+
before { graph.checkpoint }
|
|
261
|
+
context 'invalid' do
|
|
262
|
+
subject { graph.load_edges [e0.element_id, nil, e0.element_id, 'missing'] }
|
|
263
|
+
it { should == [e0, e0] }
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
context 'valid' do
|
|
267
|
+
subject { graph.load_edges [e0.element_id] }
|
|
268
|
+
it { should == [e0] }
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
|
|
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
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
context 'missing' do
|
|
314
|
+
around { |spec| spec.run if graph.supports_manual_indices? }
|
|
315
|
+
subject { graph.index_name 'invalid' }
|
|
316
|
+
it { should be_nil }
|
|
317
|
+
context 'edge' do
|
|
318
|
+
before do
|
|
319
|
+
graph.drop_index 'missing_edge' rescue nil
|
|
320
|
+
graph.index_name('missing_edge').should be_nil
|
|
321
|
+
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) }
|
|
326
|
+
after do
|
|
327
|
+
graph.transaction do
|
|
328
|
+
graph.drop_index 'missing_edge'
|
|
329
|
+
end
|
|
330
|
+
end
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
context 'vertex' do
|
|
334
|
+
before do
|
|
335
|
+
graph.drop_index 'missing_vertex' rescue nil
|
|
336
|
+
graph.index_name('missing_vertex').should be_nil
|
|
337
|
+
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) }
|
|
342
|
+
after do
|
|
343
|
+
graph.transaction do
|
|
344
|
+
graph.drop_index 'missing_vertex'
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
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
|
+
end
|
|
356
|
+
|
|
357
|
+
describe '#graph' do
|
|
358
|
+
subject { graph.graph }
|
|
359
|
+
it { should == graph }
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
describe '#vertex_name' do
|
|
363
|
+
before { graph.vertex_name = :some_proc }
|
|
364
|
+
subject { graph.vertex_name }
|
|
365
|
+
it { should == :some_proc }
|
|
366
|
+
after { graph.vertex_name = nil }
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
describe '#edge_name' do
|
|
370
|
+
before { graph.edge_name = :some_proc }
|
|
371
|
+
subject { graph.edge_name }
|
|
372
|
+
it { should == :some_proc }
|
|
373
|
+
after { graph.edge_name = nil }
|
|
374
|
+
end
|
|
375
|
+
|
|
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
|
+
describe '#import' do
|
|
389
|
+
before { pending 'create a fresh graph for these tests' if graph.is_a? Pacer::DexGraph }
|
|
390
|
+
|
|
391
|
+
it 'should load the data into an empty graph' do
|
|
392
|
+
graph2.v.count.should == 0
|
|
393
|
+
graph2.import 'spec/data/pacer.graphml'
|
|
394
|
+
graph2.v.count.should == 7
|
|
395
|
+
graph2.e.count.should == 14
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
it 'should not load the data into a graph with conflicting vertex ids' do
|
|
399
|
+
if graph.supports_custom_element_ids?
|
|
400
|
+
graph.create_vertex '0' unless graph.vertex '0'
|
|
401
|
+
expect { graph.import 'spec/data/pacer.graphml' }.to raise_error(Pacer::ElementExists)
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
describe '#export' do
|
|
407
|
+
before { pending 'create a fresh graph for these tests' if graph.is_a? Pacer::DexGraph }
|
|
408
|
+
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
|
|
413
|
+
end
|
|
414
|
+
end
|
|
415
|
+
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
Run.all :read_only, false do
|
|
420
|
+
around do |spec|
|
|
421
|
+
spec.run if graph
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
let(:v0) { graph.create_vertex }
|
|
425
|
+
let(:v1) { graph.create_vertex }
|
|
426
|
+
let(:e0) { graph.create_edge nil, v0, v1, :links }
|
|
427
|
+
let(:e1) { graph.create_edge nil, v0, v1, :relinks }
|
|
428
|
+
|
|
429
|
+
describe Pacer::GraphMixin do
|
|
430
|
+
before do
|
|
431
|
+
e0 # force edge and vertices to be created.
|
|
432
|
+
end
|
|
433
|
+
|
|
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
|
|
442
|
+
|
|
443
|
+
after do
|
|
444
|
+
graph.drop_index :vertices
|
|
445
|
+
graph.v.delete!
|
|
446
|
+
end
|
|
447
|
+
|
|
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
|
|
460
|
+
end
|
|
461
|
+
end
|
|
462
|
+
|
|
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
|
|
472
|
+
|
|
473
|
+
after do
|
|
474
|
+
graph.drop_index :edges
|
|
475
|
+
graph.v.delete!
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
|
|
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
|
|
491
|
+
end
|
|
492
|
+
end
|
|
493
|
+
end
|
|
494
|
+
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
|
+
end
|
|
521
|
+
|
|
522
|
+
Run.all do
|
|
523
|
+
it_uses Pacer::GraphMixin
|
|
524
|
+
end
|
|
525
|
+
|
|
526
|
+
Run.neo4j do
|
|
527
|
+
describe '#vertex' do
|
|
528
|
+
it 'should not raise an exception for invalid key type' do
|
|
529
|
+
graph.vertex('bad id').should be_nil
|
|
530
|
+
end
|
|
531
|
+
end
|
|
532
|
+
|
|
533
|
+
describe '#edge' do
|
|
534
|
+
it 'should not raise an exception for invalid key type' do
|
|
535
|
+
graph.edge('bad id').should be_nil
|
|
536
|
+
end
|
|
537
|
+
end
|
|
538
|
+
end
|
|
File without changes
|