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
@@ -7,7 +7,7 @@ Run.all do
|
|
7
7
|
subject { graph.v.send(:build_pipeline) }
|
8
8
|
it { should be_a(Array) }
|
9
9
|
its(:count) { should == 2 }
|
10
|
-
its(:first) { should be_a(
|
10
|
+
its(:first) { should be_a(Pacer::Pipes::VerticesPipe) }
|
11
11
|
specify { subject.first.should equal(subject.last) }
|
12
12
|
end
|
13
13
|
|
@@ -29,19 +29,19 @@ Run.all do
|
|
29
29
|
subject { route }
|
30
30
|
|
31
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)>"
|
32
|
+
should be_one_of "#<V-Index(name: \"gremlin\") -> V-Section -> :grem -> inE(:wrote)>",
|
33
|
+
"#<GraphV -> V-Property(name==\"gremlin\") -> V-Section -> :grem -> inE(:wrote)>"
|
34
34
|
end
|
35
35
|
its(:out_v) { should_not be_nil }
|
36
36
|
end
|
37
37
|
|
38
|
-
context "graph.v
|
38
|
+
context "graph.v.in_e.out_v(Tackle::SimpleMixin)" do
|
39
39
|
let(:route) { graph.v.in_e.out_v(Tackle::SimpleMixin) }
|
40
40
|
subject { route }
|
41
41
|
|
42
42
|
its(:in_e) { should_not be_nil }
|
43
43
|
its(:to_a) { should == [] }
|
44
|
-
its(:extensions) { should ==
|
44
|
+
its(:extensions) { should == [Tackle::SimpleMixin] }
|
45
45
|
end
|
46
46
|
|
47
47
|
context "graph.v(:name => 'darrick')" do
|
@@ -49,7 +49,8 @@ Run.all do
|
|
49
49
|
before { setup_data }
|
50
50
|
subject { graph.v(:name => 'darrick') }
|
51
51
|
|
52
|
-
|
52
|
+
# iterator is a protected method... It is the raw iterator before wrapping stuff is added.
|
53
|
+
its('iterator.next') { should == v1.element }
|
53
54
|
its(:to_a) { should == [v1] }
|
54
55
|
end
|
55
56
|
|
@@ -58,7 +59,7 @@ Run.all do
|
|
58
59
|
subject { graph.v.element_ids.send(:build_pipeline) }
|
59
60
|
it { should be_a(Array) }
|
60
61
|
its(:count) { should == 2 }
|
61
|
-
its(:first) { should be_a(
|
62
|
+
its(:first) { should be_a(Pacer::Pipes::VerticesPipe) }
|
62
63
|
its(:last) { should be_a(Pacer::Pipes::IdPipe) }
|
63
64
|
end
|
64
65
|
|
@@ -74,8 +75,9 @@ Run.all do
|
|
74
75
|
begin
|
75
76
|
subject.next
|
76
77
|
fail 'expected exception to be raised'
|
77
|
-
rescue
|
78
|
-
|
78
|
+
rescue Pacer::EmptyPipe, java.util.NoSuchElementException
|
79
|
+
else
|
80
|
+
'Got the wrong kind of exception.'.should be_false
|
79
81
|
end
|
80
82
|
end
|
81
83
|
end
|
@@ -84,7 +86,7 @@ Run.all do
|
|
84
86
|
use_simple_graph_data
|
85
87
|
before { setup_data }
|
86
88
|
subject { graph.v.element_ids.to_a }
|
87
|
-
its(:sort) { should == [v0
|
89
|
+
its(:sort) { should == [v0, v1].to_route(based_on: graph.v).element_ids.to_a.sort }
|
88
90
|
end
|
89
91
|
end
|
90
92
|
end
|
@@ -103,16 +105,14 @@ Run.all(:read_only) do
|
|
103
105
|
r = r.out_e(:wrote) { |e| true }
|
104
106
|
r = r.in_v
|
105
107
|
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
|
+
r.inspect.should be_one_of "#<V-Index(name: \"gremlin\") -> V-Section -> :grem -> inE(:wrote) -> outV -> outE(:wrote) -> E-Property(&block) -> inV -> V-Property(&block)>",
|
109
|
+
"#<GraphV -> V-Property(name==\"gremlin\") -> V-Section -> :grem -> inE(:wrote) -> outV -> outE(:wrote) -> E-Property(&block) -> inV -> V-Property(&block)>"
|
108
110
|
end
|
109
111
|
end
|
110
112
|
|
111
113
|
describe '#to_a' do
|
112
|
-
it { Set[*graph.v].should == Set[*graph.getVertices] }
|
113
|
-
it { Set[*
|
114
|
-
it { Set[*graph.e].should == Set[*graph.getEdges] }
|
115
|
-
it { Set[*(graph.e.to_a)].should == Set[*graph.getEdges] }
|
114
|
+
it { Set[*graph.v.collect(&:element)].should == Set[*graph.blueprints_graph.getVertices] }
|
115
|
+
it { Set[*graph.e.collect(&:element)].should == Set[*graph.blueprints_graph.getEdges] }
|
116
116
|
end
|
117
117
|
|
118
118
|
describe '#root?' do
|
@@ -131,6 +131,7 @@ Run.all(:read_only) do
|
|
131
131
|
describe 'block filter' do
|
132
132
|
it { graph.v { false }.count.should == 0 }
|
133
133
|
it { graph.v { true }.count.should == graph.v.count }
|
134
|
+
it { graph.v { |v| v.graph.should == graph }.first }
|
134
135
|
it { graph.v { |v| v.out_e.none? }[:name].to_a.should == ['blueprints'] }
|
135
136
|
|
136
137
|
it 'should work with paths' do
|
@@ -185,7 +186,7 @@ shared_examples_for Pacer::Core::Route do
|
|
185
186
|
let(:result_type) { raise 'specify :vertex, :edge, :mixed or :object' }
|
186
187
|
let(:back) { nil }
|
187
188
|
let(:info) { nil }
|
188
|
-
let(:route_extensions) {
|
189
|
+
let(:route_extensions) { [] }
|
189
190
|
|
190
191
|
context 'without data' do
|
191
192
|
subject { route }
|
@@ -211,7 +212,10 @@ shared_examples_for Pacer::Core::Route do
|
|
211
212
|
end
|
212
213
|
|
213
214
|
describe '#result' do
|
214
|
-
before
|
215
|
+
before do
|
216
|
+
c = example.metadata[:graph_commit]
|
217
|
+
c.call if c
|
218
|
+
end
|
215
219
|
subject { route.result }
|
216
220
|
its(:element_type) { should == route.element_type }
|
217
221
|
end
|
@@ -337,33 +341,30 @@ shared_examples_for Pacer::Core::Route do
|
|
337
341
|
its(:element_type) { should == graph.element_type(result_type) }
|
338
342
|
end
|
339
343
|
|
340
|
-
describe '#
|
344
|
+
describe '#add_extensions' do
|
341
345
|
# Note that this mixin doesn't need to include
|
342
346
|
# versions of each test with extensions applied because
|
343
347
|
context '(SimpleMixin)' do
|
344
|
-
|
345
|
-
|
346
|
-
r = route.add_extension Tackle::SimpleMixin
|
347
|
-
r.should equal(route)
|
348
|
+
subject do
|
349
|
+
route.add_extensions [Tackle::SimpleMixin]
|
348
350
|
end
|
351
|
+
its(:back) { should equal(route) }
|
349
352
|
its(:extensions) { should include(Tackle::SimpleMixin) }
|
350
353
|
it { should respond_to(:route_mixin_method) }
|
351
354
|
end
|
352
355
|
|
353
356
|
context '(Object)' do
|
354
|
-
|
355
|
-
|
356
|
-
route.add_extension Object
|
357
|
+
subject do
|
358
|
+
route.add_extensions [Object]
|
357
359
|
end
|
358
|
-
its(:extensions) {
|
360
|
+
its(:extensions) { should include(Object) }
|
359
361
|
end
|
360
362
|
|
361
|
-
context '(invalid)' do
|
362
|
-
|
363
|
-
|
364
|
-
route.add_extension :invalid
|
363
|
+
context '(:invalid)' do
|
364
|
+
subject do
|
365
|
+
route.add_extensions [:invalid]
|
365
366
|
end
|
366
|
-
its(:extensions) {
|
367
|
+
its(:extensions) { should include(:invalid) }
|
367
368
|
end
|
368
369
|
end
|
369
370
|
|
@@ -388,11 +389,11 @@ Run.all(:read_only) do
|
|
388
389
|
use_pacer_graphml_data(:read_only)
|
389
390
|
context 'vertices with extension' do
|
390
391
|
it_uses Pacer::Core::Route do
|
391
|
-
let(:back) {
|
392
|
-
let(:route) {
|
392
|
+
let(:back) { graph.v }
|
393
|
+
let(:route) { back.filter(Tackle::SimpleMixin) }
|
393
394
|
let(:number_of_results) { 7 }
|
394
395
|
let(:result_type) { :vertex }
|
395
|
-
let(:route_extensions) {
|
396
|
+
let(:route_extensions) { [Tackle::SimpleMixin] }
|
396
397
|
end
|
397
398
|
end
|
398
399
|
end
|
@@ -24,7 +24,7 @@ Run.tg(:read_only) do
|
|
24
24
|
context '(0..1)' do
|
25
25
|
subject { graph.v[:type].most_frequent(0..1) }
|
26
26
|
it { should be_a Pacer::Core::Route }
|
27
|
-
its(:element_type) { should ==
|
27
|
+
its(:element_type) { should == :object }
|
28
28
|
its(:to_a) { should == ['project', 'person'] }
|
29
29
|
end
|
30
30
|
|
@@ -60,14 +60,14 @@ Run.tg do
|
|
60
60
|
count = 0
|
61
61
|
index = graph.v.build_index('new_index', 'k', 'name')
|
62
62
|
index.should_not be_nil
|
63
|
-
index.
|
63
|
+
index.all('k', 'pangloss').count.should == 1
|
64
64
|
end
|
65
65
|
|
66
66
|
it 'should build the index with wrapped elements' do
|
67
67
|
count = 0
|
68
68
|
index = graph.v(TP::Person).build_index('new_index', 'k', 'name')
|
69
69
|
index.should_not be_nil
|
70
|
-
index.
|
70
|
+
index.all('k', 'pangloss').count.should == 1
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'should do nothing if there are no elements' do
|
@@ -77,51 +77,9 @@ Run.tg do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
after do
|
80
|
-
graph.
|
80
|
+
graph.drop_index 'new_index'
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
86
|
-
|
87
|
-
|
88
|
-
# Modernize these old tests:
|
89
|
-
describe RouteOperations do
|
90
|
-
before :all do
|
91
|
-
@g = Pacer.tg 'spec/data/pacer.graphml'
|
92
|
-
end
|
93
|
-
|
94
|
-
describe '#as' do
|
95
|
-
it 'should set the variable to the correct node' do
|
96
|
-
vars = Set[]
|
97
|
-
@g.v.as(:a_vertex).in_e(:wrote) { |edge| vars << edge.vars[:a_vertex] }.count
|
98
|
-
vars.should == Set[*@g.e.e(:wrote).in_v]
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'should not break path generation (simple)' do
|
102
|
-
who = nil
|
103
|
-
r = @g.v.as(:who).in_e(:wrote).out_v.v { |v|
|
104
|
-
who = v.vars[:who]
|
105
|
-
}.paths
|
106
|
-
r.each do |path|
|
107
|
-
path.to_a[0].should == @g
|
108
|
-
path.to_a[1].should == who
|
109
|
-
path.length.should == 4
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'should not break path generation' do
|
114
|
-
who_wrote_what = nil
|
115
|
-
r = @g.v.as(:who).in_e(:wrote).as(:wrote).out_v.as(:what).v { |v|
|
116
|
-
who_wrote_what = [@g, v.vars[:who], v.vars[:wrote], v.vars[:what]]
|
117
|
-
}.paths
|
118
|
-
r.each do |path|
|
119
|
-
path.to_a.should == who_wrote_what
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
describe :delete! do
|
125
|
-
it 'should not try to delete an element twice'
|
126
|
-
end
|
127
|
-
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
Run.all(:read_only) do
|
4
|
+
use_pacer_graphml_data(:read_only)
|
5
|
+
|
6
|
+
describe '#as' do
|
7
|
+
it 'should set the variable to the correct node' do
|
8
|
+
vars = Set[]
|
9
|
+
graph.v.as(:a_vertex).in_e(:wrote) { |edge| vars << edge.vars[:a_vertex] }.count
|
10
|
+
vars.should == Set[*graph.e.e(:wrote).in_v]
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should not break path generation (simple)' do
|
14
|
+
who = nil
|
15
|
+
r = graph.v.as(:who).in_e(:wrote).out_v.v { |v|
|
16
|
+
who = v.vars[:who]
|
17
|
+
}.paths
|
18
|
+
r.each do |path|
|
19
|
+
path.to_a[0].should == who
|
20
|
+
path.length.should == 3
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should not break path generation' do
|
25
|
+
who_wrote_what = nil
|
26
|
+
r = graph.v.as(:who).in_e(:wrote).as(:wrote).out_v.as(:what).v { |v|
|
27
|
+
who_wrote_what = [v.vars[:who], v.vars[:wrote], v.vars[:what]]
|
28
|
+
}.paths
|
29
|
+
r.each do |path|
|
30
|
+
path.to_a.should == who_wrote_what
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -74,22 +74,22 @@ describe Enumerable do
|
|
74
74
|
context 'with no arguments' do
|
75
75
|
subject { [1, 'a'].to_route }
|
76
76
|
it { should be_a Pacer::Core::Route }
|
77
|
-
its(:element_type) { should ==
|
77
|
+
its(:element_type) { should == :object }
|
78
78
|
its(:to_a) { should == [1, 'a'] }
|
79
79
|
end
|
80
80
|
|
81
81
|
context 'based on an object route' do
|
82
82
|
subject { [1, 'a'].to_route(:based_on => graph.v[:name]) }
|
83
83
|
it { should be_a Pacer::Core::Route }
|
84
|
-
its(:element_type) { should ==
|
84
|
+
its(:element_type) { should == :object }
|
85
85
|
its(:to_a) { should == [1, 'a'] }
|
86
86
|
end
|
87
87
|
|
88
88
|
context 'based on an object route with an extension' do
|
89
|
-
subject { [1, 'a'].to_route(:based_on => graph.v[:name].
|
89
|
+
subject { [1, 'a'].to_route(:based_on => graph.v[:name].add_extensions([Tackle::SimpleMixin])) }
|
90
90
|
it { should be_a Pacer::Core::Route }
|
91
|
-
its(:extensions) { should ==
|
92
|
-
its(:element_type) { should ==
|
91
|
+
its(:extensions) { should == [Tackle::SimpleMixin] }
|
92
|
+
its(:element_type) { should == :object }
|
93
93
|
its(:to_a) { should == [1, 'a'] }
|
94
94
|
end
|
95
95
|
end
|
@@ -105,7 +105,7 @@ describe Enumerable do
|
|
105
105
|
|
106
106
|
context 'based on an extended element route' do
|
107
107
|
subject { elements.to_route(:based_on => graph.v(Tackle::SimpleMixin)) }
|
108
|
-
its(:extensions) { should ==
|
108
|
+
its(:extensions) { should == [Tackle::SimpleMixin] }
|
109
109
|
its(:element_type) { should == graph.element_type(:vertex) }
|
110
110
|
its(:to_a) { should == elements }
|
111
111
|
end
|
@@ -9,7 +9,7 @@ Run.tg :read_only do
|
|
9
9
|
its(:count) { should == 7 }
|
10
10
|
specify 'each element should be a node' do
|
11
11
|
subject.each do |group|
|
12
|
-
group[:key].should be_a
|
12
|
+
group[:key].should be_a Pacer::Vertex
|
13
13
|
group.property_keys.to_a.should == ['key']
|
14
14
|
end
|
15
15
|
end
|
@@ -42,7 +42,8 @@ Run.tg :read_only do
|
|
42
42
|
|
43
43
|
context '#multigraph' do
|
44
44
|
subject { route.multigraph }
|
45
|
-
it { should be_a Pacer::
|
45
|
+
it { should be_a Pacer::PacerGraph }
|
46
|
+
its(:blueprints_graph) { should be_a Pacer::MultiGraph }
|
46
47
|
|
47
48
|
its('v.count') { should == 3 }
|
48
49
|
|
@@ -127,10 +128,11 @@ Run.tg :read_only do
|
|
127
128
|
"group" => {"projects" => 3, "member" => 1}}
|
128
129
|
end
|
129
130
|
|
130
|
-
its(:inspect) { should == "#<
|
131
|
-
|
131
|
+
its(:inspect) { should == "#<PacerGraph>" }
|
132
|
+
its(:blueprints_graph) { should be_a Pacer::MultiGraph }
|
133
|
+
|
132
134
|
specify do
|
133
|
-
counted_group.inspect.should ==
|
135
|
+
counted_group.inspect.should ==
|
134
136
|
"#<GraphV -> V-Join(#<V -> Obj(type)>: {:count=>#<V -> outE -> Obj-Cap(E-Counted)>, :out_e=>#<V -> outE>})>"
|
135
137
|
end
|
136
138
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
shared_examples_for '#map' do
|
4
|
+
describe 'simple element route' do
|
5
|
+
subject do
|
6
|
+
c = 0
|
7
|
+
source.map { c += 1 }
|
8
|
+
end
|
9
|
+
its(:first) { should == 1 }
|
10
|
+
its(:element_type) { should == :object }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'with extensions' do
|
14
|
+
let(:extended) { source.add_extensions([Tackle::SimpleMixin]) }
|
15
|
+
|
16
|
+
subject { extended.map { |v| v.extensions } }
|
17
|
+
|
18
|
+
its(:first) { should == [Tackle::SimpleMixin, Pacer::Extensions::BlockFilterElement] }
|
19
|
+
its(:element_type) { should == :object }
|
20
|
+
|
21
|
+
context 'with vertex result type' do
|
22
|
+
subject { extended.map(element_type: :vertex) { |v| v } }
|
23
|
+
its(:element_type) { should == :vertex }
|
24
|
+
its(:extensions) { should == [] }
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'with extended vertex result type' do
|
28
|
+
let(:exts) { [] }
|
29
|
+
subject { extended.map(element_type: :vertex, extensions: TP::Person) { |v| exts << v.extensions; v } }
|
30
|
+
its(:element_type) { should == :vertex }
|
31
|
+
its(:extensions) { should == [TP::Person] }
|
32
|
+
it 'should use the source - not the result - extension in the block' do
|
33
|
+
v = subject.first
|
34
|
+
v.extensions.should == [TP::Person]
|
35
|
+
exts.first.should == [Tackle::SimpleMixin, Pacer::Extensions::BlockFilterElement]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
Run.tg :read_only do
|
42
|
+
use_pacer_graphml_data :read_only
|
43
|
+
|
44
|
+
context 'on route' do
|
45
|
+
it_uses '#map' do
|
46
|
+
let(:source) { graph.v }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'on element' do
|
51
|
+
it_uses '#map' do
|
52
|
+
let(:source) { pangloss }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -2,7 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Pacer::Transform::Path do
|
4
4
|
before :all do
|
5
|
-
@g = Pacer.tg
|
5
|
+
@g = Pacer.tg
|
6
|
+
Pacer::GraphML.import @g, 'spec/data/pacer.graphml'
|
6
7
|
end
|
7
8
|
|
8
9
|
describe '#paths' do
|
@@ -16,11 +17,13 @@ describe Pacer::Transform::Path do
|
|
16
17
|
|
17
18
|
it 'should include all elements traversed' do
|
18
19
|
@g.v.out_e.in_v.paths.each do |path|
|
19
|
-
path[0].should
|
20
|
-
path[1].should be_a(Pacer::
|
21
|
-
path[2].should be_a(Pacer::
|
22
|
-
path[
|
23
|
-
path.
|
20
|
+
path[0].should be_a(Pacer::Wrappers::VertexWrapper)
|
21
|
+
path[1].should be_a(Pacer::Wrappers::EdgeWrapper)
|
22
|
+
path[2].should be_a(Pacer::Wrappers::VertexWrapper)
|
23
|
+
path[0].element.should be_a(com.tinkerpop.blueprints.impls.tg.TinkerVertex)
|
24
|
+
path[1].element.should be_a(com.tinkerpop.blueprints.impls.tg.TinkerEdge)
|
25
|
+
path[2].element.should be_a(com.tinkerpop.blueprints.impls.tg.TinkerVertex)
|
26
|
+
path.length.should == 3
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
@@ -37,18 +40,30 @@ describe Pacer::Transform::Path do
|
|
37
40
|
end
|
38
41
|
|
39
42
|
describe '#subgraph' do
|
40
|
-
|
41
|
-
|
43
|
+
context 'original' do
|
44
|
+
before do
|
45
|
+
@sg = @g.v(:type => 'person').out_e.in_v(:type => 'project').subgraph
|
42
46
|
|
43
|
-
|
44
|
-
|
47
|
+
@vertices = @g.v(:type => 'person').to_a + @g.v(:type => 'project').to_a
|
48
|
+
@edges = @g.v(:type => 'person').out_e(:wrote)
|
49
|
+
end
|
50
|
+
|
51
|
+
it { Set[*@sg.v.element_ids].should == Set[*@vertices.collect { |v| v.element_id }] }
|
52
|
+
it { Set[*@sg.e.element_ids].should == Set[*@edges.collect { |e| e.element_id }] }
|
53
|
+
|
54
|
+
it { @sg.e.labels.uniq.to_a.should == ['wrote'] }
|
55
|
+
it { Set[*@sg.v.collect { |v| v.properties }].should == Set[*@vertices.collect { |v| v.properties }] }
|
45
56
|
end
|
46
57
|
|
47
|
-
|
48
|
-
|
58
|
+
context 'with both_v' do
|
59
|
+
before do
|
60
|
+
@sg = @g.v(:type => 'person').in_e.both_v.subgraph
|
61
|
+
@vertices = [@g.vertex(5), @g.vertex(6)]
|
62
|
+
@edges = [@g.edge(11)]
|
63
|
+
end
|
49
64
|
|
50
|
-
|
51
|
-
|
65
|
+
it { Set[*@sg.v.element_ids].should == Set[*@vertices.collect { |v| v.element_id }] }
|
66
|
+
it { Set[*@sg.e.element_ids].should == Set[*@edges.collect { |e| e.element_id }] }
|
67
|
+
end
|
52
68
|
end
|
53
69
|
end
|
54
|
-
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
shared_examples_for '#process' do
|
4
|
+
describe 'simple element route' do
|
5
|
+
subject do
|
6
|
+
c = 0
|
7
|
+
source.process { c += 1 }
|
8
|
+
end
|
9
|
+
its(:first) { should == source.first }
|
10
|
+
its(:element_type) { should == :vertex }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'with extensions' do
|
14
|
+
let(:extended) { source.add_extensions([Tackle::SimpleMixin]) }
|
15
|
+
let(:exts) { Set[] }
|
16
|
+
|
17
|
+
subject { extended.process { |v| exts << v.extensions } }
|
18
|
+
|
19
|
+
its('first.extensions') { should == [Tackle::SimpleMixin] }
|
20
|
+
|
21
|
+
it 'should have the right extensions in the block' do
|
22
|
+
subject.first
|
23
|
+
exts.first.should == [Tackle::SimpleMixin, Pacer::Extensions::BlockFilterElement]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Run.tg :read_only do
|
29
|
+
use_pacer_graphml_data :read_only
|
30
|
+
|
31
|
+
context 'on route' do
|
32
|
+
it_uses '#process' do
|
33
|
+
let(:source) { graph.v }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'on element' do
|
38
|
+
it_uses '#process' do
|
39
|
+
let(:source) { pangloss }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
Run.tg :read_only do
|
4
|
+
use_pacer_graphml_data :read_only
|
5
|
+
|
6
|
+
let(:unsorted) { graph.v.out.out }
|
7
|
+
|
8
|
+
describe 'sort by name' do
|
9
|
+
let(:by_name) do
|
10
|
+
graph.v.section(:x).out.out.sort_section(:x) { |v| v[:name] }
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should have the same elements' do
|
14
|
+
by_name.group_count.should == unsorted.group_count
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have 3 elements in the path' do
|
18
|
+
by_name.paths.each do |path|
|
19
|
+
path.length.should == 3
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'sort with more info' do
|
25
|
+
let(:unsorted) { graph.v.out.out }
|
26
|
+
let(:with_path) do
|
27
|
+
graph.v.section(:x).out.out.sort_section(:x) do |v, section, path|
|
28
|
+
[path[-2][:name], v[:name]]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should have the same elements' do
|
33
|
+
with_path.group_count.should == unsorted.group_count
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should have 3 elements in the path' do
|
37
|
+
with_path.paths.each do |path|
|
38
|
+
path.length.should == 3
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should yield' do
|
43
|
+
yielded = false
|
44
|
+
graph.v.section(:x).out_e.in_v.sort_section(:x) do |v, section, path|
|
45
|
+
yielded = true
|
46
|
+
path.should be_a Array
|
47
|
+
path.length.should == 3
|
48
|
+
a, b, c = path
|
49
|
+
path.each { |e| e.graph.should_not be_nil }
|
50
|
+
section.graph.should_not be_nil
|
51
|
+
a.should == section
|
52
|
+
a.should be_a Pacer::Wrappers::VertexWrapper
|
53
|
+
b.should be_a Pacer::Wrappers::EdgeWrapper
|
54
|
+
c.should == v
|
55
|
+
c.should be_a Pacer::Wrappers::VertexWrapper
|
56
|
+
end.first
|
57
|
+
yielded.should be_true
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'sort by values' do
|
62
|
+
let :by_value do
|
63
|
+
graph.v.section(:x).out.out.element_ids.sort_section(:x)
|
64
|
+
end
|
65
|
+
it 'should work with no block' do
|
66
|
+
by_value.to_a.should_not be_empty
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should put groups into the correct order' do
|
71
|
+
# depends on the order of graph.v(type: 'project') ...
|
72
|
+
route = graph.v(type: 'project').section(:proj).out[:name].sort_section(:proj)
|
73
|
+
route.to_a.should == %w[
|
74
|
+
blueprints
|
75
|
+
blueprints
|
76
|
+
gremlin
|
77
|
+
pipes
|
78
|
+
blueprints
|
79
|
+
pipes
|
80
|
+
]
|
81
|
+
end
|
82
|
+
end
|