pacer 0.9.1.1-java
Sign up to get free protection for your applications and to get access to all the features.
- 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,177 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
Run.neo4j do
|
4
|
+
describe Pacer::Neo4jGraph do
|
5
|
+
let(:v0) { graph.create_vertex }
|
6
|
+
let(:v1) { graph.create_vertex }
|
7
|
+
let(:e0) { graph.create_edge '0', v0, v1, :default }
|
8
|
+
|
9
|
+
describe '#element_type' do
|
10
|
+
context 'invalid' do
|
11
|
+
it { expect { graph.element_type(:nothing) }.to raise_error(ArgumentError) }
|
12
|
+
end
|
13
|
+
|
14
|
+
context ':vertex' do
|
15
|
+
subject { graph.element_type(:vertex) }
|
16
|
+
it { should == com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'a vertex' do
|
20
|
+
subject { graph.element_type(v0) }
|
21
|
+
it { should == com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex }
|
22
|
+
end
|
23
|
+
|
24
|
+
context ':edge' do
|
25
|
+
subject { graph.element_type(:edge) }
|
26
|
+
it { should == com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jEdge }
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'an edge' do
|
30
|
+
subject { graph.element_type(e0) }
|
31
|
+
it { should == com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jEdge }
|
32
|
+
end
|
33
|
+
|
34
|
+
context ':mixed' do
|
35
|
+
subject { graph.element_type(:mixed) }
|
36
|
+
it { should == com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jElement }
|
37
|
+
end
|
38
|
+
|
39
|
+
context ':object' do
|
40
|
+
subject { graph.element_type(:object) }
|
41
|
+
it { should == Object }
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'from element_type' do
|
45
|
+
context ':vertex' do
|
46
|
+
subject { graph.element_type(graph.element_type :vertex) }
|
47
|
+
it { should == com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex }
|
48
|
+
end
|
49
|
+
|
50
|
+
context ':edge' do
|
51
|
+
subject { graph.element_type(graph.element_type :edge) }
|
52
|
+
it { should == com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jEdge }
|
53
|
+
end
|
54
|
+
|
55
|
+
context ':mixed' do
|
56
|
+
subject { graph.element_type(graph.element_type :mixed) }
|
57
|
+
it { should == com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jElement }
|
58
|
+
end
|
59
|
+
|
60
|
+
context ':object' do
|
61
|
+
subject { graph.element_type(graph.element_type :object) }
|
62
|
+
it { should == Object }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'from index_class' do
|
67
|
+
context ':vertex' do
|
68
|
+
subject { graph.element_type(graph.index_class :vertex) }
|
69
|
+
it { should == com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex }
|
70
|
+
end
|
71
|
+
|
72
|
+
context ':edge' do
|
73
|
+
subject { graph.element_type(graph.index_class :edge) }
|
74
|
+
it { should == com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jEdge }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#indices' do
|
80
|
+
subject { graph.indices.to_a }
|
81
|
+
its(:count) { should == 2 }
|
82
|
+
end
|
83
|
+
|
84
|
+
describe '#sanitize_properties' do
|
85
|
+
let(:original) do
|
86
|
+
{ :string => ' bob ',
|
87
|
+
:symbol => :abba,
|
88
|
+
:empty => '',
|
89
|
+
:integer => 121,
|
90
|
+
:float => 100.001,
|
91
|
+
:time => Time.utc(1999, 11, 9, 9, 9, 1),
|
92
|
+
:object => { :a => 1, 1 => :a },
|
93
|
+
99 => 'numeric key',
|
94
|
+
'string key' => 'string value'
|
95
|
+
}
|
96
|
+
end
|
97
|
+
|
98
|
+
subject { graph.sanitize_properties original }
|
99
|
+
|
100
|
+
it { should_not equal(original) }
|
101
|
+
specify 'original should be unchanged' do
|
102
|
+
original.should == {
|
103
|
+
:string => ' bob ',
|
104
|
+
:symbol => :abba,
|
105
|
+
:empty => '',
|
106
|
+
:integer => 121,
|
107
|
+
:float => 100.001,
|
108
|
+
:time => Time.utc(1999, 11, 9, 9, 9, 1),
|
109
|
+
:object => { :a => 1, 1 => :a },
|
110
|
+
99 => 'numeric key',
|
111
|
+
'string key' => 'string value'
|
112
|
+
}
|
113
|
+
end
|
114
|
+
|
115
|
+
specify 'string should be stripped' do
|
116
|
+
subject[:string].should == 'bob'
|
117
|
+
end
|
118
|
+
|
119
|
+
specify 'empty string becomes nil' do
|
120
|
+
subject[:empty].should be_nil
|
121
|
+
end
|
122
|
+
|
123
|
+
specify 'numbers should be unmodified' do
|
124
|
+
subject[:integer].should == 121
|
125
|
+
subject[:float].should == 100.001
|
126
|
+
end
|
127
|
+
|
128
|
+
specify 'everything else should be yaml' do
|
129
|
+
subject[:time].should == YAML.dump(Time.utc(1999, 11, 9, 9, 9, 1))
|
130
|
+
end
|
131
|
+
|
132
|
+
its(:keys) { should == original.keys }
|
133
|
+
end
|
134
|
+
|
135
|
+
describe '#in_vertex' do
|
136
|
+
it 'should wrap the vertex' do
|
137
|
+
v = e0.in_vertex(Tackle::SimpleMixin)
|
138
|
+
v.should == v1
|
139
|
+
v.extensions.should include(Tackle::SimpleMixin)
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'should wrap the vertex 2' do
|
143
|
+
v = e0.in_vertex([Tackle::SimpleMixin])
|
144
|
+
v.should == v1
|
145
|
+
v.extensions.should include(Tackle::SimpleMixin)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
describe '#out_vertex' do
|
150
|
+
it 'should wrap the vertex' do
|
151
|
+
v = e0.out_vertex(Tackle::SimpleMixin)
|
152
|
+
v.should == v0
|
153
|
+
v.extensions.should include(Tackle::SimpleMixin)
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'should wrap the vertex 2' do
|
157
|
+
v = e0.out_vertex([Tackle::SimpleMixin])
|
158
|
+
v.should == v0
|
159
|
+
v.extensions.should include(Tackle::SimpleMixin)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe '#get_vertices' do
|
164
|
+
before { e0 }
|
165
|
+
subject { graph.get_vertices }
|
166
|
+
it { should be_a(Pacer::Core::Route) }
|
167
|
+
its(:count) { should == 2 }
|
168
|
+
end
|
169
|
+
|
170
|
+
describe '#get_edges' do
|
171
|
+
before { e0 }
|
172
|
+
subject { graph.get_edges }
|
173
|
+
it { should be_a(Pacer::Core::Route) }
|
174
|
+
its(:count) { should == 1 }
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
Run.tg do
|
4
|
+
describe Pacer::TinkerGraph do
|
5
|
+
let(:v0) { graph.create_vertex }
|
6
|
+
let(:v1) { graph.create_vertex }
|
7
|
+
let(:e0) { graph.create_edge '0', v0, v1, :default }
|
8
|
+
|
9
|
+
describe '#element_type' do
|
10
|
+
context 'invalid' do
|
11
|
+
it { expect { graph.element_type(:nothing) }.to raise_error(ArgumentError) }
|
12
|
+
end
|
13
|
+
|
14
|
+
context ':vertex' do
|
15
|
+
subject { Pacer.tg.element_type(:vertex) }
|
16
|
+
it { should == com.tinkerpop.blueprints.pgm.impls.tg.TinkerVertex }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'a vertex' do
|
20
|
+
subject { graph.element_type(v0) }
|
21
|
+
it { should == com.tinkerpop.blueprints.pgm.impls.tg.TinkerVertex }
|
22
|
+
end
|
23
|
+
|
24
|
+
context ':edge' do
|
25
|
+
subject { graph.element_type(:edge) }
|
26
|
+
it { should == com.tinkerpop.blueprints.pgm.impls.tg.TinkerEdge }
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'an edge' do
|
30
|
+
subject { graph.element_type(e0) }
|
31
|
+
it { should == com.tinkerpop.blueprints.pgm.impls.tg.TinkerEdge }
|
32
|
+
end
|
33
|
+
|
34
|
+
context ':mixed' do
|
35
|
+
subject { graph.element_type(:mixed) }
|
36
|
+
it { should == com.tinkerpop.blueprints.pgm.impls.tg.TinkerElement }
|
37
|
+
end
|
38
|
+
|
39
|
+
context ':object' do
|
40
|
+
subject { graph.element_type(:object) }
|
41
|
+
it { should == Object }
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'from result' do
|
45
|
+
context ':vertex' do
|
46
|
+
subject { Pacer.tg.element_type(Pacer.tg.element_type :vertex) }
|
47
|
+
it { should == com.tinkerpop.blueprints.pgm.impls.tg.TinkerVertex }
|
48
|
+
end
|
49
|
+
|
50
|
+
context ':edge' do
|
51
|
+
subject { graph.element_type(Pacer.tg.element_type :edge) }
|
52
|
+
it { should == com.tinkerpop.blueprints.pgm.impls.tg.TinkerEdge }
|
53
|
+
end
|
54
|
+
|
55
|
+
context ':mixed' do
|
56
|
+
subject { graph.element_type(Pacer.tg.element_type :mixed) }
|
57
|
+
it { should == com.tinkerpop.blueprints.pgm.impls.tg.TinkerElement }
|
58
|
+
end
|
59
|
+
|
60
|
+
context ':object' do
|
61
|
+
subject { graph.element_type(Pacer.tg.element_type :object) }
|
62
|
+
it { should == Object }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'from index_class' do
|
67
|
+
context ':vertex' do
|
68
|
+
subject { graph.element_type(graph.index_class :vertex) }
|
69
|
+
it { should == com.tinkerpop.blueprints.pgm.impls.tg.TinkerVertex }
|
70
|
+
end
|
71
|
+
|
72
|
+
context ':edge' do
|
73
|
+
subject { graph.element_type(graph.index_class :edge) }
|
74
|
+
it { should == com.tinkerpop.blueprints.pgm.impls.tg.TinkerEdge }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#sanitize_properties' do
|
80
|
+
specify 'returns its argument' do
|
81
|
+
arg = { :a => 1 }
|
82
|
+
graph.sanitize_properties(arg).should equal(arg)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#in_vertex' do
|
87
|
+
it 'should wrap the vertex' do
|
88
|
+
v = e0.in_vertex(Tackle::SimpleMixin)
|
89
|
+
v.should == v1
|
90
|
+
v.extensions.should include(Tackle::SimpleMixin)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should wrap the vertex 2' do
|
94
|
+
v = e0.in_vertex([Tackle::SimpleMixin])
|
95
|
+
v.should == v1
|
96
|
+
v.extensions.should include(Tackle::SimpleMixin)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#out_vertex' do
|
101
|
+
it 'should wrap the vertex' do
|
102
|
+
v = e0.out_vertex(Tackle::SimpleMixin)
|
103
|
+
v.should == v0
|
104
|
+
v.extensions.should include(Tackle::SimpleMixin)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should wrap the vertex 2' do
|
108
|
+
v = e0.out_vertex([Tackle::SimpleMixin])
|
109
|
+
v.should == v0
|
110
|
+
v.extensions.should include(Tackle::SimpleMixin)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe '#get_vertices' do
|
115
|
+
before { e0 }
|
116
|
+
subject { graph.get_vertices }
|
117
|
+
it { should be_a(Pacer::Core::Route) }
|
118
|
+
its(:count) { should == 2 }
|
119
|
+
end
|
120
|
+
|
121
|
+
describe '#get_edges' do
|
122
|
+
before { e0 }
|
123
|
+
subject { graph.get_edges }
|
124
|
+
it { should be_a(Pacer::Core::Route) }
|
125
|
+
its(:count) { should == 1 }
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
Run.all(:read_only) do
|
4
|
+
use_pacer_graphml_data(:read_only)
|
5
|
+
|
6
|
+
context Pacer::Core::Graph::EdgesRoute do
|
7
|
+
subject { graph.e }
|
8
|
+
it { should be_a Pacer::Core::Graph::EdgesRoute }
|
9
|
+
its(:count) { should == 14 }
|
10
|
+
|
11
|
+
describe '#out_v' do
|
12
|
+
subject { graph.e.out_v }
|
13
|
+
it { should be_a Pacer::Core::Graph::VerticesRoute }
|
14
|
+
its(:count) { should == 14 }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#in_v' do
|
18
|
+
subject { graph.e.in_v }
|
19
|
+
it { should be_a Pacer::Core::Graph::VerticesRoute }
|
20
|
+
its(:count) { should == 14 }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#both_v' do
|
24
|
+
subject { graph.e.both_v }
|
25
|
+
it { should be_a Pacer::Core::Graph::VerticesRoute }
|
26
|
+
its(:count) { should == 28 }
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#e' do
|
30
|
+
subject { graph.e.e }
|
31
|
+
it { should be_a Pacer::Core::Graph::EdgesRoute }
|
32
|
+
its(:count) { should == 14 }
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#labels' do
|
36
|
+
subject { graph.e.labels }
|
37
|
+
it { should be_a Pacer::Core::Route }
|
38
|
+
its(:element_type) { should == Object }
|
39
|
+
its(:count) { should == 14 }
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#to_h' do
|
43
|
+
subject { graph.e.to_h }
|
44
|
+
let(:okram) { graph.v(:name => 'okram').first }
|
45
|
+
|
46
|
+
it { should be_a Hash }
|
47
|
+
specify 'okram key has all outward related vertices in an array as the value' do
|
48
|
+
subject[okram].sort_by { |v| v.element_id }.should == okram.out_e.in_v.to_a.sort_by { |v| v.element_id }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
shared_examples_for Pacer::Core::Graph::ElementRoute do
|
4
|
+
describe '#properties' do
|
5
|
+
subject { r.properties }
|
6
|
+
its(:count) { should == r.count }
|
7
|
+
its(:element_type) { should == Object }
|
8
|
+
specify 'should all be hashes' do
|
9
|
+
props = subject.each
|
10
|
+
elements = r.each
|
11
|
+
elements.zip(props.to_a).each do |e, p|
|
12
|
+
e.properties.should == p
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'with extensions' do
|
18
|
+
let(:route) { r.add_extension(Tackle::SimpleMixin) }
|
19
|
+
describe '#each without a block' do
|
20
|
+
subject { route.each }
|
21
|
+
specify 'elements should be wrapped' do
|
22
|
+
subject.first.extensions.should include(Tackle::SimpleMixin)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Run.all(:read_only) do
|
29
|
+
use_pacer_graphml_data(:read_only)
|
30
|
+
|
31
|
+
context Pacer::Core::Graph::EdgesRoute, '2' do
|
32
|
+
it_uses Pacer::Core::Graph::ElementRoute do
|
33
|
+
def r
|
34
|
+
graph.e
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context Pacer::Core::Graph::VerticesRoute, '2' do
|
40
|
+
it_uses Pacer::Core::Graph::ElementRoute do
|
41
|
+
def r
|
42
|
+
graph.v
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
Run.all(:read_only, false) do
|
4
|
+
around { |spec| spec.run if graph }
|
5
|
+
use_pacer_graphml_data(:read_only)
|
6
|
+
|
7
|
+
context Pacer::Core::Graph::GraphRoute do
|
8
|
+
describe '#v' do
|
9
|
+
subject { graph.v }
|
10
|
+
it { should be_a_vertices_route }
|
11
|
+
its(:to_a) { should_not be_empty }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#e' do
|
15
|
+
subject { graph.e }
|
16
|
+
it { should be_an_edges_route }
|
17
|
+
its(:to_a) { should_not be_empty }
|
18
|
+
end
|
19
|
+
|
20
|
+
subject { graph }
|
21
|
+
it { should_not be_a(Pacer::Routes::RouteOperations) }
|
22
|
+
|
23
|
+
describe '#filter' do
|
24
|
+
it 'is not implemented' do
|
25
|
+
expect { graph.filter(:a => 'b') }.to raise_error
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
its(:result) { should == graph }
|
30
|
+
its(:hide_elements) { should == true }
|
31
|
+
|
32
|
+
context 'with vertex name indexed' do
|
33
|
+
before :all do
|
34
|
+
graph.v.build_index :name if graph
|
35
|
+
graph.search_manual_indices = true if graph
|
36
|
+
end
|
37
|
+
|
38
|
+
after :all do
|
39
|
+
graph.drop_index :name if graph
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'basic search' do
|
43
|
+
subject { graph.v(:name => 'pangloss') }
|
44
|
+
it { should be_a(Pacer::Filter::IndexFilter) }
|
45
|
+
its(:to_a) { should_not be_empty }
|
46
|
+
its(:count) { should == 1 }
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'basic search 2' do
|
50
|
+
subject { graph.v([{ :name => 'pangloss' }]) }
|
51
|
+
it { should be_a(Pacer::Filter::IndexFilter) }
|
52
|
+
its(:to_a) { should_not be_empty }
|
53
|
+
its(:count) { should == 1 }
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'basic search 3' do
|
57
|
+
subject { graph.v({ :name => 'pangloss' }, { :type => 'person' } ) }
|
58
|
+
its(:inspect) { should == '#<V-Index(name: "pangloss") -> V-Property(type=="person")>' }
|
59
|
+
its(:to_a) { should_not be_empty }
|
60
|
+
its(:count) { should == 1 }
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'extension search' do
|
64
|
+
subject { graph.v(TP::Person, :name => { :name => 'pangloss' }) }
|
65
|
+
its(:inspect) { should == '#<V-Index(name: "pangloss") -> V-Property(TP::Person)>' }
|
66
|
+
its(:extensions) { should include(TP::Person) }
|
67
|
+
its(:to_a) { should_not be_empty }
|
68
|
+
its(:count) { should == 1 }
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'extension search 2' do
|
72
|
+
subject { graph.v(TP::Pangloss) }
|
73
|
+
it { should be_a(Pacer::Filter::IndexFilter) }
|
74
|
+
its(:to_a) { should_not be_empty }
|
75
|
+
its(:count) { should == 1 }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'with vertex auto index' do
|
80
|
+
before :all do
|
81
|
+
graph.build_automatic_index :v_auto, :vertex, [:type] if graph
|
82
|
+
end
|
83
|
+
|
84
|
+
after :all do
|
85
|
+
graph.drop_index :v_auto if graph
|
86
|
+
end
|
87
|
+
|
88
|
+
subject { graph.v(:type => 'person') }
|
89
|
+
it { should be_a(Pacer::Filter::IndexFilter) }
|
90
|
+
its(:to_a) { should_not be_empty }
|
91
|
+
its(:count) { should == 2 }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
Run.all(:read_only) do
|
4
|
+
use_pacer_graphml_data(:read_only)
|
5
|
+
|
6
|
+
context Pacer::Core::Graph::VerticesRoute do
|
7
|
+
subject { graph.v }
|
8
|
+
it { should be_a Pacer::Core::Graph::VerticesRoute }
|
9
|
+
its(:count) { should == 7 }
|
10
|
+
|
11
|
+
describe '#out_e' do
|
12
|
+
subject { graph.v.out_e }
|
13
|
+
it { should be_a Pacer::Core::Graph::EdgesRoute }
|
14
|
+
its(:count) { should == 14 }
|
15
|
+
|
16
|
+
describe '(:uses)' do
|
17
|
+
subject { graph.v.out_e(:uses) }
|
18
|
+
its(:count) { should == 5 }
|
19
|
+
it { subject.labels.to_a.should == ['uses'] * 5 }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '(:uses, :wrote)' do
|
23
|
+
subject { graph.v.out_e(:uses, :wrote) }
|
24
|
+
its(:count) { should == 9 }
|
25
|
+
it { Set[*subject.labels].should == Set['uses', 'wrote'] }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#out' do
|
30
|
+
subject { graph.v.out }
|
31
|
+
it { should be_a Pacer::Core::Graph::VerticesRoute }
|
32
|
+
its(:count) { should == 14 }
|
33
|
+
its(:to_a) { should == graph.v.out_e.in_v.to_a }
|
34
|
+
|
35
|
+
describe '(:uses, :wrote)' do
|
36
|
+
subject { graph.v.out(:uses, :wrote) }
|
37
|
+
its(:count) { should == 9 }
|
38
|
+
it { subject.to_a.should == graph.v.out_e(:uses, :wrote).in_v.to_a }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#in' do
|
43
|
+
subject { graph.v.in }
|
44
|
+
it { should be_a Pacer::Core::Graph::VerticesRoute }
|
45
|
+
its(:count) { should == 14 }
|
46
|
+
its(:to_a) { should == graph.v.in_e.out_v.to_a }
|
47
|
+
describe '(:uses, :wrote)' do
|
48
|
+
subject { graph.v.in(:uses, :wrote) }
|
49
|
+
its(:count) { should == 9 }
|
50
|
+
it { subject.to_a.should == graph.v.in_e(:uses, :wrote).out_v.to_a }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#both' do
|
55
|
+
subject { graph.v.both }
|
56
|
+
it { should be_a Pacer::Core::Graph::VerticesRoute }
|
57
|
+
its(:count) { should == 28 }
|
58
|
+
describe '(:wrote)' do
|
59
|
+
subject { graph.v.both(:wrote) }
|
60
|
+
its(:count) { should == 8 }
|
61
|
+
# These element ids only work under TinkerGraph:
|
62
|
+
#it { subject.element_ids.to_a.should == %w[5 5 0 1 4 2 3 5] }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
Run.tg(:read_only) do
|
69
|
+
context Pacer::Core::Graph::VerticesRoute do
|
70
|
+
use_pacer_graphml_data(:read_only)
|
71
|
+
|
72
|
+
describe '#out_e' do
|
73
|
+
it { graph.v.out_e.should be_an_edges_route }
|
74
|
+
it { graph.v.out_e(:label).should be_a(Pacer::Route) }
|
75
|
+
it { graph.v.out_e(:label) { |x| true }.should be_a(Pacer::Route) }
|
76
|
+
it { graph.v.out_e { |x| true }.should be_a(Pacer::Route) }
|
77
|
+
|
78
|
+
it { Set[*graph.v.out_e].should == Set[*graph.edges] }
|
79
|
+
|
80
|
+
it { graph.v.out_e.count.should >= 1 }
|
81
|
+
|
82
|
+
specify 'with label filter should work with path generation' do
|
83
|
+
r = graph.v.out_e.in_v.in_e { |e| e.label == 'wrote' }.out_v
|
84
|
+
paths = r.paths
|
85
|
+
paths.first.should_not be_nil
|
86
|
+
graph.v.out_e.in_v.in_e(:wrote).out_v.paths.collect(&:to_a).should == paths.collect(&:to_a)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
Run.tg do
|
93
|
+
use_pacer_graphml_data
|
94
|
+
|
95
|
+
context Pacer::Core::Graph::VerticesRoute do
|
96
|
+
describe :add_edges_to do
|
97
|
+
before do
|
98
|
+
setup_data
|
99
|
+
end
|
100
|
+
|
101
|
+
let(:pangloss) { graph.v(:name => 'pangloss') }
|
102
|
+
let(:pacer) { graph.v(:name => 'pacer') }
|
103
|
+
|
104
|
+
context '1 to 1' do
|
105
|
+
before do
|
106
|
+
@result = pangloss.add_edges_to(:likes, pacer, :pros => "it's fast", :cons => nil)
|
107
|
+
end
|
108
|
+
|
109
|
+
subject { @result.first }
|
110
|
+
|
111
|
+
it { should_not be_nil }
|
112
|
+
its(:out_vertex) { should == pangloss.first }
|
113
|
+
its(:in_vertex) { should == pacer.first }
|
114
|
+
its(:label) { should == 'likes' }
|
115
|
+
|
116
|
+
it 'should store properties' do
|
117
|
+
subject[:pros].should == "it's fast"
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should not add properties with null values' do
|
121
|
+
subject.getPropertyKeys.should_not include('cons')
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'many to many' do
|
126
|
+
let(:people) { graph.v(:type => 'person') }
|
127
|
+
let(:projects) { graph.v :type => 'project' }
|
128
|
+
|
129
|
+
subject { people.add_edges_to(:uses, projects) }
|
130
|
+
|
131
|
+
it { should be_a(Pacer::Core::Route) }
|
132
|
+
its(:element_type) { should == graph.element_type(:edge) }
|
133
|
+
its(:count) { should == 8 }
|
134
|
+
its('back.back.element_type') { should == Object }
|
135
|
+
its('back.count') { should == 8 }
|
136
|
+
|
137
|
+
specify 'all edges in rasge should exist' do
|
138
|
+
subject.each do |edge|
|
139
|
+
edge.should_not be_nil
|
140
|
+
edge.label.should == 'uses'
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
context 'edge cases' do
|
146
|
+
it 'should do nothing if there are no source vertices' do
|
147
|
+
result = graph.v(:name => 'no match').add_edges_to(:likes, pacer, :pros => "it's fast", :cons => nil)
|
148
|
+
result.should be_nil
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'should do nothing if there are no target vertices' do
|
152
|
+
result = pangloss.add_edges_to(:likes, graph.v(:name => 'I hate everytihng'))
|
153
|
+
result.should be_nil
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'should associate to a single element' do
|
157
|
+
result = pangloss.add_edges_to(:likes, pacer.first)
|
158
|
+
edge = result.first
|
159
|
+
edge.should_not be_nil
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'should do nothing if target is nil' do
|
163
|
+
result = pangloss.add_edges_to(:likes, nil)
|
164
|
+
result.should be_nil
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|