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,192 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
shared_examples_for Pacer::VertexMixin do
|
|
4
|
+
use_simple_graph_data
|
|
5
|
+
|
|
6
|
+
describe '#v' do
|
|
7
|
+
subject { v0.v }
|
|
8
|
+
it { should be_a_vertices_route }
|
|
9
|
+
it { should_not be_a(graph.element_type(:vertex)) }
|
|
10
|
+
it { should_not be_an_instance_of(graph.element_type(:vertex)) }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe '#add_extensions' do
|
|
14
|
+
context 'no extensions' do
|
|
15
|
+
subject { v0.add_extensions([]) }
|
|
16
|
+
its('extensions.to_a') { should == [] }
|
|
17
|
+
it { should_not be_a(Pacer::Wrappers::ElementWrapper) }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context 'with extensions' do
|
|
21
|
+
subject { v0.add_extensions([Tackle::SimpleMixin]) }
|
|
22
|
+
its('extensions.to_a') { should == [Tackle::SimpleMixin] }
|
|
23
|
+
it { should be_a(Pacer::Wrappers::ElementWrapper) }
|
|
24
|
+
it { should be_a(Pacer::Wrappers::VertexWrapper) }
|
|
25
|
+
it { should_not be_a(Pacer::Wrappers::EdgeWrapper) }
|
|
26
|
+
|
|
27
|
+
describe '#v' do
|
|
28
|
+
subject { v0.add_extensions([Tackle::SimpleMixin]).v }
|
|
29
|
+
its('extensions.to_a') { should == [Tackle::SimpleMixin] }
|
|
30
|
+
it { should be_a_vertices_route }
|
|
31
|
+
it { should be_a(Tackle::SimpleMixin::Route) }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe '#delete!' do
|
|
37
|
+
before do
|
|
38
|
+
@vertex_id = v0.element_id
|
|
39
|
+
v0.delete!
|
|
40
|
+
graph.checkpoint # deleted edges in neo may otherwise still be looked up during the transaction
|
|
41
|
+
end
|
|
42
|
+
it 'should be removed' do
|
|
43
|
+
graph.vertex(@vertex_id).should be_nil
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
contexts(
|
|
48
|
+
'into new tg' => proc {
|
|
49
|
+
let(:dest) { Pacer.tg }
|
|
50
|
+
},
|
|
51
|
+
'into graph2' => proc {
|
|
52
|
+
before { pending 'support temporary hash indices for clone/copy' unless graph.supports_manual_indices? }
|
|
53
|
+
let(:dest) { graph2 }
|
|
54
|
+
}) do
|
|
55
|
+
describe '#clone_into', :transactions => false do
|
|
56
|
+
subject { v0.clone_into(dest) }
|
|
57
|
+
its(:properties) { should == { 'name' => 'eliza' } }
|
|
58
|
+
its(:graph) { should equal(dest) }
|
|
59
|
+
its('element_id.to_s') { should == v0.element_id.to_s if graph.supports_custom_element_ids? }
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe '#copy_into', :transaction => false do
|
|
63
|
+
subject { v1.copy_into(dest) }
|
|
64
|
+
its(:properties) { should == { 'name' => 'darrick' } }
|
|
65
|
+
its(:graph) { should equal(dest) }
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
subject { v0 }
|
|
70
|
+
its(:graph) { should equal(graph) }
|
|
71
|
+
its(:display_name) { should be_nil }
|
|
72
|
+
its(:inspect) { should =~ /#<[VM]\[#{v0.element_id}\]>/ }
|
|
73
|
+
context 'with label proc' do
|
|
74
|
+
before do
|
|
75
|
+
graph.vertex_name = proc { |e| "some name" }
|
|
76
|
+
end
|
|
77
|
+
its(:display_name) { should == "some name" }
|
|
78
|
+
its(:inspect) { should =~ /#<[VM]\[#{ v0.element_id }\] some name>/ }
|
|
79
|
+
end
|
|
80
|
+
it { should_not == v1 }
|
|
81
|
+
it { should == v0 }
|
|
82
|
+
context 'edge with same element id', :transactions => false do
|
|
83
|
+
it { should_not == e0 }
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
context 'with more data' do
|
|
87
|
+
let(:from_v) { graph.create_vertex }
|
|
88
|
+
let(:to_v) { graph.create_vertex }
|
|
89
|
+
|
|
90
|
+
before do
|
|
91
|
+
%w[ a a a b b c ].each do |label|
|
|
92
|
+
v = graph.create_vertex
|
|
93
|
+
graph.create_edge nil, from_v, v, label
|
|
94
|
+
graph.create_edge nil, v, to_v, label
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
describe '#in_edges' do
|
|
99
|
+
specify 'to_v should have 6 in edges' do
|
|
100
|
+
to_v.in_edges.count.should == 6
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
specify 'to_v should have 3 in edges with label a' do
|
|
104
|
+
to_v.in_edges('a').count.should == 3
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
specify 'to_v should have 4 in edges with label a or c' do
|
|
108
|
+
to_v.in_edges('a', 'c').count.should == 4
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
it 'should add an extension' do
|
|
112
|
+
edge = to_v.in_edges(Tackle::SimpleMixin).first
|
|
113
|
+
edge.should be_a(Pacer::EdgeMixin)
|
|
114
|
+
edge.extensions.should include(Tackle::SimpleMixin)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it 'should be able to mix labels and mixins as arguments' do
|
|
118
|
+
edge = to_v.in_edges('a', Tackle::SimpleMixin, 'b').first
|
|
119
|
+
edge.should be_a(Pacer::EdgeMixin)
|
|
120
|
+
edge.extensions.should include(Tackle::SimpleMixin)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it 'should filter correctly with a mix of labels and mixins as arguments' do
|
|
124
|
+
to_v.in_edges('a', Tackle::SimpleMixin, 'b').count.should == 5
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
describe '#out_edges' do
|
|
129
|
+
specify 'from_v should have 6 out edges' do
|
|
130
|
+
from_v.out_edges.count.should == 6
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
specify 'from_v should have 3 out edges with label a' do
|
|
134
|
+
from_v.out_edges('a').count.should == 3
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
specify 'from_v should have 4 out edges with label a or c' do
|
|
138
|
+
from_v.out_edges('a', 'c').count.should == 4
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
it 'should add an extension' do
|
|
142
|
+
edge = from_v.out_edges(Tackle::SimpleMixin).first
|
|
143
|
+
edge.should be_a(Pacer::EdgeMixin)
|
|
144
|
+
edge.extensions.should include(Tackle::SimpleMixin)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it 'should be able to mix labels and mixins as arguments' do
|
|
148
|
+
edge = from_v.out_edges('a', Tackle::SimpleMixin, 'b').first
|
|
149
|
+
edge.should be_a(Pacer::EdgeMixin)
|
|
150
|
+
edge.extensions.should include(Tackle::SimpleMixin)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
it 'should filter correctly with a mix of labels and mixins as arguments' do
|
|
154
|
+
from_v.out_edges('a', Tackle::SimpleMixin, 'b').count.should == 5
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
describe '#both_edges' do
|
|
159
|
+
specify 'from_v should have 6 edges' do
|
|
160
|
+
from_v.both_edges.count.should == 6
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
specify 'from_v should have 3 edges with label a' do
|
|
164
|
+
from_v.both_edges('a').count.should == 3
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
specify 'from_v should have 4 edges with label a or c' do
|
|
168
|
+
from_v.both_edges('a', 'c').count.should == 4
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it 'should add an extension' do
|
|
172
|
+
edge = from_v.both_edges(Tackle::SimpleMixin).first
|
|
173
|
+
edge.should be_a(Pacer::EdgeMixin)
|
|
174
|
+
edge.extensions.should include(Tackle::SimpleMixin)
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
it 'should be able to mix labels and mixins as arguments' do
|
|
178
|
+
edge = from_v.both_edges('a', Tackle::SimpleMixin, 'b').first
|
|
179
|
+
edge.should be_a(Pacer::EdgeMixin)
|
|
180
|
+
edge.extensions.should include(Tackle::SimpleMixin)
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
it 'should filter correctly with a mix of labels and mixins as arguments' do
|
|
184
|
+
from_v.both_edges('a', Tackle::SimpleMixin, 'b').count.should == 5
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
Run.all do
|
|
191
|
+
it_uses Pacer::VertexMixin
|
|
192
|
+
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
Run.all do
|
|
4
|
+
describe Pacer::Core::Route, 'pipe creation internals' do
|
|
5
|
+
context "graph.v" do
|
|
6
|
+
describe '#build_pipeline' do
|
|
7
|
+
subject { graph.v.send(:build_pipeline) }
|
|
8
|
+
it { should be_a(Array) }
|
|
9
|
+
its(:count) { should == 2 }
|
|
10
|
+
its(:first) { should be_a(com.tinkerpop.pipes.transform.VerticesPipe) }
|
|
11
|
+
specify { subject.first.should equal(subject.last) }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe '#pipe_source' do
|
|
15
|
+
subject { graph.v.send(:pipe_source) }
|
|
16
|
+
it { should be_nil }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe '#iterator' do
|
|
20
|
+
use_simple_graph_data
|
|
21
|
+
before { setup_data }
|
|
22
|
+
subject { graph.v.send(:iterator) }
|
|
23
|
+
its(:next) { should_not be_nil }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
context "graph.v(:name => 'gremlin').as(:grem).in_e(:wrote)" do
|
|
28
|
+
let(:route) { graph.v(:name => 'gremlin').as(:grem).in_e(:wrote) }
|
|
29
|
+
subject { route }
|
|
30
|
+
|
|
31
|
+
its(:inspect) do
|
|
32
|
+
should be_one_of "#<V-Index(name: \"gremlin\") -> :grem -> inE(:wrote)>",
|
|
33
|
+
"#<GraphV -> V-Property(name==\"gremlin\") -> :grem -> inE(:wrote)>"
|
|
34
|
+
end
|
|
35
|
+
its(:out_v) { should_not be_nil }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context "graph.v(:name => 'gremlin').as(:grem).in_e(:wrote)" do
|
|
39
|
+
let(:route) { graph.v.in_e.out_v(Tackle::SimpleMixin) }
|
|
40
|
+
subject { route }
|
|
41
|
+
|
|
42
|
+
its(:in_e) { should_not be_nil }
|
|
43
|
+
its(:to_a) { should == [] }
|
|
44
|
+
its(:extensions) { should == Set[Tackle::SimpleMixin] }
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context "graph.v(:name => 'darrick')" do
|
|
48
|
+
use_simple_graph_data
|
|
49
|
+
before { setup_data }
|
|
50
|
+
subject { graph.v(:name => 'darrick') }
|
|
51
|
+
|
|
52
|
+
its('iterator.next') { should == v1 }
|
|
53
|
+
its(:to_a) { should == [v1] }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context 'graph.v.element_ids' do
|
|
57
|
+
describe '#build_pipeline' do
|
|
58
|
+
subject { graph.v.element_ids.send(:build_pipeline) }
|
|
59
|
+
it { should be_a(Array) }
|
|
60
|
+
its(:count) { should == 2 }
|
|
61
|
+
its(:first) { should be_a(com.tinkerpop.pipes.transform.VerticesPipe) }
|
|
62
|
+
its(:last) { should be_a(Pacer::Pipes::IdPipe) }
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
describe '#iterator' do
|
|
66
|
+
use_simple_graph_data
|
|
67
|
+
before { setup_data }
|
|
68
|
+
subject { graph.v.element_ids.send(:iterator) }
|
|
69
|
+
its(:next) { should_not be_nil }
|
|
70
|
+
it 'should iterate twice then raise an exception' do
|
|
71
|
+
2.times {
|
|
72
|
+
[v0.element_id, v1.element_id].should include(subject.next)
|
|
73
|
+
}
|
|
74
|
+
begin
|
|
75
|
+
subject.next
|
|
76
|
+
fail 'expected exception to be raised'
|
|
77
|
+
rescue NativeException => e
|
|
78
|
+
e.cause.inspect.should == 'java.util.NoSuchElementException'
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe '#to_a' do
|
|
84
|
+
use_simple_graph_data
|
|
85
|
+
before { setup_data }
|
|
86
|
+
subject { graph.v.element_ids.to_a }
|
|
87
|
+
its(:sort) { should == [v0.element_id, v1.element_id].sort }
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
Run.all(:read_only) do
|
|
94
|
+
describe Pacer::Core::Route do
|
|
95
|
+
use_pacer_graphml_data(:read_only)
|
|
96
|
+
before { setup_data }
|
|
97
|
+
describe '#inspect' do
|
|
98
|
+
it 'should show the path in the resulting string' do
|
|
99
|
+
r = graph.v(:name => 'gremlin')
|
|
100
|
+
r = r.as(:grem)
|
|
101
|
+
r = r.in_e(:wrote)
|
|
102
|
+
r = r.out_v
|
|
103
|
+
r = r.out_e(:wrote) { |e| true }
|
|
104
|
+
r = r.in_v
|
|
105
|
+
r = r.is_not(:grem)
|
|
106
|
+
r.inspect.should be_one_of "#<V-Index(name: \"gremlin\") -> :grem -> inE(:wrote) -> outV -> outE(:wrote) -> E-Property(&block) -> inV -> V-Property(&block)>",
|
|
107
|
+
"#<GraphV -> V-Property(name==\"gremlin\") -> :grem -> inE(:wrote) -> outV -> outE(:wrote) -> E-Property(&block) -> inV -> V-Property(&block)>"
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
describe '#to_a' do
|
|
112
|
+
it { Set[*graph.v].should == Set[*graph.getVertices] }
|
|
113
|
+
it { Set[*(graph.v.to_a)].should == Set[*graph.getVertices] }
|
|
114
|
+
it { Set[*graph.e].should == Set[*graph.getEdges] }
|
|
115
|
+
it { Set[*(graph.e.to_a)].should == Set[*graph.getEdges] }
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
describe '#root?' do
|
|
119
|
+
it { graph.should be_root }
|
|
120
|
+
it { graph.v.should be_root }
|
|
121
|
+
it { graph.v[3].should_not be_root }
|
|
122
|
+
it { graph.v.out_e.should_not be_root }
|
|
123
|
+
it { graph.v.out_e.in_v.should_not be_root }
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
describe 'property filter' do
|
|
127
|
+
it { graph.v(:name => 'pacer').to_a.should == [pacer] }
|
|
128
|
+
it { graph.v(:name => 'pacer').count.should == 1 }
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
describe 'block filter' do
|
|
132
|
+
it { graph.v { false }.count.should == 0 }
|
|
133
|
+
it { graph.v { true }.count.should == graph.v.count }
|
|
134
|
+
it { graph.v { |v| v.out_e.none? }[:name].to_a.should == ['blueprints'] }
|
|
135
|
+
|
|
136
|
+
it 'should work with paths' do
|
|
137
|
+
paths = graph.v.out_e(:wrote).in_v.paths.collect(&:to_a)
|
|
138
|
+
filtered_paths = graph.v { true }.out_e(:wrote).e { true }.in_v.paths.collect(&:to_a)
|
|
139
|
+
filtered_paths.should == paths
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
describe '#==' do
|
|
144
|
+
specify { graph.v.should == graph.v }
|
|
145
|
+
specify { graph.v.should_not == graph.v { true } }
|
|
146
|
+
specify { graph.v.should_not == graph.v(:x => 1) }
|
|
147
|
+
specify { graph.e.should == graph.e }
|
|
148
|
+
specify { graph.v.should_not == graph.e }
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
describe '#result' do
|
|
152
|
+
context 'no matching vertices' do
|
|
153
|
+
subject { graph.v(:name => 'missing').result }
|
|
154
|
+
it { should be_a(Pacer::Core::Graph::VerticesRoute) }
|
|
155
|
+
its(:count) { should == 0 }
|
|
156
|
+
its(:empty?) { should be_true }
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it 'should not be nil when no matching vertices' do
|
|
160
|
+
empty = graph.v(:name => 'missing').result
|
|
161
|
+
empty.should be_a(Pacer::Core::Graph::VerticesRoute)
|
|
162
|
+
empty.count.should == 0
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
it 'should not be nil when no matching edges' do
|
|
166
|
+
empty = graph.e(:missing).result
|
|
167
|
+
empty.should be_a(Pacer::Core::Graph::EdgesRoute)
|
|
168
|
+
empty.count.should == 0
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it 'should not be nil when no matching mixed results' do
|
|
172
|
+
empty = [].to_route(:graph => graph, :element_type => :mixed)
|
|
173
|
+
empty.should be_a(Pacer::Core::Graph::MixedRoute)
|
|
174
|
+
empty.count.should == 0
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# These specs are :read_only
|
|
181
|
+
shared_examples_for Pacer::Core::Route do
|
|
182
|
+
# defaults -- you
|
|
183
|
+
let(:route) { raise 'define a route' }
|
|
184
|
+
let(:number_of_results) { raise 'how many results are expected' }
|
|
185
|
+
let(:result_type) { raise 'specify :vertex, :edge, :mixed or :object' }
|
|
186
|
+
let(:back) { nil }
|
|
187
|
+
let(:info) { nil }
|
|
188
|
+
let(:route_extensions) { Set[] }
|
|
189
|
+
|
|
190
|
+
context 'without data' do
|
|
191
|
+
subject { route }
|
|
192
|
+
it { should be_a(Pacer::Core::Route) }
|
|
193
|
+
its(:graph) { should equal(graph) }
|
|
194
|
+
its(:back) { should equal(back) }
|
|
195
|
+
its(:info) { should == info }
|
|
196
|
+
context 'with info' do
|
|
197
|
+
before { route.info = 'some info' }
|
|
198
|
+
its(:info) { should == 'some info' }
|
|
199
|
+
after { route.info = nil }
|
|
200
|
+
end
|
|
201
|
+
its(:vars) { should be_a(Hash) }
|
|
202
|
+
|
|
203
|
+
describe '#from_graph?' do
|
|
204
|
+
subject { route }
|
|
205
|
+
it { should be_from_graph graph }
|
|
206
|
+
it { should_not be_from_graph graph2 }
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
describe '#each' do
|
|
210
|
+
it { route.each.should be_a(java.util.Iterator) }
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
describe '#result' do
|
|
214
|
+
before { graph.checkpoint }
|
|
215
|
+
subject { route.result }
|
|
216
|
+
its(:element_type) { should == route.element_type }
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
context 'with data' do
|
|
222
|
+
around do |spec|
|
|
223
|
+
if number_of_results > 0
|
|
224
|
+
setup_data
|
|
225
|
+
spec.run
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
let(:first_element) { route.first }
|
|
230
|
+
let(:all_elements) { route.to_a }
|
|
231
|
+
|
|
232
|
+
subject { route }
|
|
233
|
+
|
|
234
|
+
its(:extensions) { should == route_extensions }
|
|
235
|
+
|
|
236
|
+
describe '#[Fixnum]' do
|
|
237
|
+
subject { route[number_of_results - 1] }
|
|
238
|
+
it { should be_a(Pacer::Core::Route) }
|
|
239
|
+
its(:count) { should == 1 }
|
|
240
|
+
its(:result) { should be_a(Pacer::Core::Route) }
|
|
241
|
+
its(:extensions) { should == route.extensions }
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
describe '#result' do
|
|
245
|
+
subject { route.result }
|
|
246
|
+
it { should be_a(Pacer::Core::Route) }
|
|
247
|
+
its(:count) { should == number_of_results }
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
describe '#route' do
|
|
251
|
+
subject { route.route }
|
|
252
|
+
its(:hide_elements) { should be_true }
|
|
253
|
+
it { should equal(route) }
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
describe '#first' do
|
|
257
|
+
subject { route.first }
|
|
258
|
+
it { should_not be_nil }
|
|
259
|
+
its(:graph) { should equal(graph) }
|
|
260
|
+
its('extensions.to_a') { should == route.extensions.to_a }
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
describe '#to_a' do
|
|
264
|
+
subject { route.to_a }
|
|
265
|
+
its(:count) { should == number_of_results }
|
|
266
|
+
it { should be_a(Array) }
|
|
267
|
+
its('first.extensions.to_a') { should == route.extensions.to_a }
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
describe '#except' do
|
|
271
|
+
context '(first_element)' do
|
|
272
|
+
subject { route.except(first_element) }
|
|
273
|
+
its(:to_a) { should_not include(first_element) }
|
|
274
|
+
its('first.class') { should == first_element.class }
|
|
275
|
+
its(:extensions) { should == route.extensions }
|
|
276
|
+
end
|
|
277
|
+
context '(all_elements)' do
|
|
278
|
+
subject { route.except(all_elements) }
|
|
279
|
+
its(:count) { should == 0 }
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
describe '#only' do
|
|
284
|
+
subject { route.only(first_element).uniq }
|
|
285
|
+
its(:to_a) { should == [first_element] }
|
|
286
|
+
its('first.class') { should == first_element.class }
|
|
287
|
+
its(:extensions) { should == route.extensions }
|
|
288
|
+
|
|
289
|
+
context 'for non-elements' do
|
|
290
|
+
subject { route.element_ids.only(first_element.element_id).uniq }
|
|
291
|
+
its(:to_a) { should == [first_element.element_id] }
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
context 'without data' do
|
|
297
|
+
around do |spec|
|
|
298
|
+
if number_of_results == 0
|
|
299
|
+
setup_data
|
|
300
|
+
spec.run
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
subject { route }
|
|
305
|
+
|
|
306
|
+
describe '#[Fixnum]' do
|
|
307
|
+
subject { route[0] }
|
|
308
|
+
it { should be_a(Pacer::Core::Route) }
|
|
309
|
+
its(:count) { should == 0 }
|
|
310
|
+
its(:result) { should be_a(Pacer::Core::Route) }
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
describe '#result' do
|
|
314
|
+
subject { route.result }
|
|
315
|
+
it { should be_a(Pacer::Core::Route) }
|
|
316
|
+
its(:count) { should == number_of_results }
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
describe '#route' do
|
|
320
|
+
subject { route.route }
|
|
321
|
+
its(:hide_elements) { should be_true }
|
|
322
|
+
it { should equal(route) }
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
describe '#first' do
|
|
326
|
+
subject { route.first }
|
|
327
|
+
it { should be_nil }
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
describe '#to_a' do
|
|
331
|
+
subject { route.to_a }
|
|
332
|
+
its(:count) { should == number_of_results }
|
|
333
|
+
it { should be_a(Array) }
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
describe '#element_type' do
|
|
337
|
+
its(:element_type) { should == graph.element_type(result_type) }
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
describe '#add_extension' do
|
|
341
|
+
# Note that this mixin doesn't need to include
|
|
342
|
+
# versions of each test with extensions applied because
|
|
343
|
+
context '(SimpleMixin)' do
|
|
344
|
+
before do
|
|
345
|
+
@orig_ancestors = route.class.ancestors
|
|
346
|
+
r = route.add_extension Tackle::SimpleMixin
|
|
347
|
+
r.should equal(route)
|
|
348
|
+
end
|
|
349
|
+
its(:extensions) { should include(Tackle::SimpleMixin) }
|
|
350
|
+
it { should respond_to(:route_mixin_method) }
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
context '(Object)' do
|
|
354
|
+
before do
|
|
355
|
+
@orig_ancestors = route.class.ancestors
|
|
356
|
+
route.add_extension Object
|
|
357
|
+
end
|
|
358
|
+
its(:extensions) { should_not include(Object) }
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
context '(invalid)' do
|
|
362
|
+
before do
|
|
363
|
+
@orig_ancestors = route.class.ancestors
|
|
364
|
+
route.add_extension :invalid
|
|
365
|
+
end
|
|
366
|
+
its(:extensions) { should_not include(:invalid) }
|
|
367
|
+
end
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
describe '#add_extensions' do
|
|
371
|
+
subject { route.add_extensions([Tackle::SimpleMixin, Object, :invalid]) }
|
|
372
|
+
its(:extensions) { should include(Tackle::SimpleMixin) }
|
|
373
|
+
end
|
|
374
|
+
end
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
Run.all(:read_only) do
|
|
378
|
+
use_pacer_graphml_data(:read_only)
|
|
379
|
+
context 'vertices' do
|
|
380
|
+
it_uses Pacer::Core::Route do
|
|
381
|
+
let(:route) { graph.v }
|
|
382
|
+
let(:number_of_results) { 7 }
|
|
383
|
+
let(:result_type) { :vertex }
|
|
384
|
+
end
|
|
385
|
+
end
|
|
386
|
+
end
|
|
387
|
+
Run.all(:read_only) do
|
|
388
|
+
use_pacer_graphml_data(:read_only)
|
|
389
|
+
context 'vertices with extension' do
|
|
390
|
+
it_uses Pacer::Core::Route do
|
|
391
|
+
let(:back) { nil }
|
|
392
|
+
let(:route) { graph.v.filter(Tackle::SimpleMixin) }
|
|
393
|
+
let(:number_of_results) { 7 }
|
|
394
|
+
let(:result_type) { :vertex }
|
|
395
|
+
let(:route_extensions) { Set[Tackle::SimpleMixin] }
|
|
396
|
+
end
|
|
397
|
+
end
|
|
398
|
+
end
|
|
399
|
+
Run.all(:read_only) do
|
|
400
|
+
use_pacer_graphml_data(:read_only)
|
|
401
|
+
context 'no vertices' do
|
|
402
|
+
it_uses Pacer::Core::Route do
|
|
403
|
+
let(:back) { graph.v }
|
|
404
|
+
let(:route) { back.filter(:something => 'missing') }
|
|
405
|
+
let(:number_of_results) { 0 }
|
|
406
|
+
let(:result_type) { :vertex }
|
|
407
|
+
end
|
|
408
|
+
end
|
|
409
|
+
end
|
|
410
|
+
Run.all(:read_only) do
|
|
411
|
+
use_pacer_graphml_data(:read_only)
|
|
412
|
+
context 'edges' do
|
|
413
|
+
it_uses Pacer::Core::Route do
|
|
414
|
+
let(:route) { graph.e }
|
|
415
|
+
let(:number_of_results) { 14 }
|
|
416
|
+
let(:result_type) { :edge }
|
|
417
|
+
end
|
|
418
|
+
end
|
|
419
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
Run.all do
|
|
4
|
+
use_pacer_graphml_data
|
|
5
|
+
|
|
6
|
+
describe RouteOperations, :transactions => false do
|
|
7
|
+
before { setup_data }
|
|
8
|
+
|
|
9
|
+
describe '#bulk_job', :transactions => false do
|
|
10
|
+
context 'commit every 2nd record, updating all vertices' do
|
|
11
|
+
context 'with wrapped elements' do
|
|
12
|
+
it 'should update all records' do
|
|
13
|
+
graph.v(Tackle::SimpleMixin).bulk_job(2) do |v|
|
|
14
|
+
v[:updated] = 'yes'
|
|
15
|
+
end
|
|
16
|
+
graph.v(:updated => 'yes').count.should == 7
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'should update all records' do
|
|
21
|
+
graph.v.bulk_job(2) do |v|
|
|
22
|
+
v[:updated] = 'yup'
|
|
23
|
+
end
|
|
24
|
+
graph.v(:updated => 'yup').count.should == 7
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|