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,96 @@
|
|
1
|
+
module Pacer::Core::Graph
|
2
|
+
|
3
|
+
# Basic methods for routes that may contain both vertices and edges. That can
|
4
|
+
# happen as the result of a branched route, for example.
|
5
|
+
module MixedRoute
|
6
|
+
include ElementRoute
|
7
|
+
|
8
|
+
# Pass through only vertices.
|
9
|
+
def v(*args, &block)
|
10
|
+
route = chain_route :element_type => :vertex,
|
11
|
+
:pipe_class => Pacer::Pipes::TypeFilterPipe,
|
12
|
+
:pipe_args => Pacer::VertexMixin,
|
13
|
+
:wrapper => wrapper,
|
14
|
+
:extensions => extensions
|
15
|
+
Pacer::Route.property_filter(route, args, block)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Pass through only edges.
|
19
|
+
def e(*args, &block)
|
20
|
+
route = chain_route :element_type => :edge,
|
21
|
+
:pipe_class => Pacer::Pipes::TypeFilterPipe,
|
22
|
+
:pipe_args => Pacer::EdgeMixin,
|
23
|
+
:wrapper => wrapper,
|
24
|
+
:extensions => extensions
|
25
|
+
Pacer::Route.property_filter(route, args, block)
|
26
|
+
end
|
27
|
+
|
28
|
+
def filter(*args, &block)
|
29
|
+
mixed(*args, &block)
|
30
|
+
end
|
31
|
+
|
32
|
+
def mixed(*args, &block)
|
33
|
+
route = chain_route :pipe_class => Pacer::Pipes::IdentityPipe
|
34
|
+
Pacer::Route.property_filter(route, args, block)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Out edges from matching vertices.
|
38
|
+
def out_e(*args, &block)
|
39
|
+
v.out_e(*args, &block)
|
40
|
+
end
|
41
|
+
|
42
|
+
# In edges from matching vertices.
|
43
|
+
def in_e(*args, &block)
|
44
|
+
v.in_e(*args, &block)
|
45
|
+
end
|
46
|
+
|
47
|
+
# All edges from matching vertices.
|
48
|
+
def both_e(*args, &block)
|
49
|
+
v.both_e(*args, &block)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Out vertices from matching edges.
|
53
|
+
def out_v(*args, &block)
|
54
|
+
e.out_v(*args, &block)
|
55
|
+
end
|
56
|
+
|
57
|
+
# In vertices from matching edges.
|
58
|
+
def in_v(*args, &block)
|
59
|
+
e.in_v(*args, &block)
|
60
|
+
end
|
61
|
+
|
62
|
+
# All vertices from matching edges.
|
63
|
+
def both_v(*args, &block)
|
64
|
+
e.both_v(*args, &block)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Return an iterator of or yield all labels on matching edges.
|
68
|
+
def labels(&block)
|
69
|
+
e.labels(&block)
|
70
|
+
end
|
71
|
+
|
72
|
+
def element_type
|
73
|
+
graph.element_type(:mixed)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Calculate and save result.
|
77
|
+
def result(name = nil)
|
78
|
+
ids = collect do |element|
|
79
|
+
if element.is_a? Pacer::VertexMixin
|
80
|
+
[:vertex, element.element_id]
|
81
|
+
else
|
82
|
+
[:edge, element.element_id]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
args = {
|
86
|
+
:graph => graph,
|
87
|
+
:element_type => :mixed,
|
88
|
+
:extensions => extensions,
|
89
|
+
:info => [name, info].compact.join(':')
|
90
|
+
}
|
91
|
+
ids.to_route(:info => "#{ ids.count } ids").map(args) do |method, id|
|
92
|
+
graph.send(method, id)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,220 @@
|
|
1
|
+
module Pacer::Core::Graph
|
2
|
+
|
3
|
+
# Basic methods for routes that contain only vertices.
|
4
|
+
module VerticesRoute
|
5
|
+
import com.tinkerpop.pipes.transform.OutEdgesPipe
|
6
|
+
import com.tinkerpop.pipes.transform.OutPipe
|
7
|
+
import com.tinkerpop.pipes.transform.InEdgesPipe
|
8
|
+
import com.tinkerpop.pipes.transform.InPipe
|
9
|
+
import com.tinkerpop.pipes.transform.BothEdgesPipe
|
10
|
+
import com.tinkerpop.pipes.transform.BothPipe
|
11
|
+
|
12
|
+
include ElementRoute
|
13
|
+
|
14
|
+
# Extends the route with out edges from this route's matching vertices.
|
15
|
+
#
|
16
|
+
# @param [Array<Hash, String, Symbol, extension>, Hash, String, Symbol, extension] filter see {Pacer::Route#property_filter}
|
17
|
+
# If string(s) or symbol(s) are given, they will be treated as edge
|
18
|
+
# labels. Unlike other property filters which all must be matched, an
|
19
|
+
# edge will pass the filter if it matches any of the given labels.
|
20
|
+
# @yield [EdgeMixin(Extensions::BlockFilterElement)] filter proc, see {Pacer::Route#property_filter}
|
21
|
+
# @return [EdgesRoute]
|
22
|
+
def out_e(*filters, &block)
|
23
|
+
filters = extract_labels(filters)
|
24
|
+
Pacer::Route.property_filter(chain_route(:element_type => :edge,
|
25
|
+
:pipe_class => OutEdgesPipe,
|
26
|
+
:pipe_args => route_labels,
|
27
|
+
:route_name => edge_route_name('outE')),
|
28
|
+
filters, block)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Extends the route with vertices via the out edges from this route's matching vertices.
|
32
|
+
#
|
33
|
+
# @param [Array<Hash, String, Symbol, extension>, Hash, String, Symbol, extension] filter see {Pacer::Route#property_filter}
|
34
|
+
# If string(s) or symbol(s) are given, they will be treated as edge
|
35
|
+
# labels. Unlike other property filters which all must be matched, an
|
36
|
+
# edge will pass the filter if it matches any of the given labels.
|
37
|
+
# @yield [VertexMixin(Extensions::BlockFilterElement)] filter proc, see {Pacer::Route#property_filter}
|
38
|
+
# @return [VerticesRoute]
|
39
|
+
def out(*filters, &block)
|
40
|
+
filters = extract_labels(filters)
|
41
|
+
Pacer::Route.property_filter(chain_route(:element_type => :vertex,
|
42
|
+
:pipe_class => OutPipe,
|
43
|
+
:pipe_args => route_labels,
|
44
|
+
:route_name => edge_route_name('out')),
|
45
|
+
filters, block)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Extends the route with in edges from this route's matching vertices.
|
49
|
+
#
|
50
|
+
# @param [Array<Hash, String, Symbol, extension>, Hash, String, Symbol, extension] filter see {Pacer::Route#property_filter}
|
51
|
+
# If string(s) or symbol(s) are given, they will be treated as edge
|
52
|
+
# labels. Unlike other property filters which all must be matched, an
|
53
|
+
# edge will pass the filter if it matches any of the given labels.
|
54
|
+
# @yield [EdgeMixin(Extensions::BlockFilterElement)] filter proc, see {Pacer::Route#property_filter}
|
55
|
+
# @return [EdgesRoute]
|
56
|
+
def in_e(*filters, &block)
|
57
|
+
filters = extract_labels(filters)
|
58
|
+
Pacer::Route.property_filter(chain_route(:element_type => :edge,
|
59
|
+
:pipe_class => InEdgesPipe,
|
60
|
+
:pipe_args => route_labels,
|
61
|
+
:route_name => edge_route_name('inE')),
|
62
|
+
filters, block)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Extends the route with vertices via the in edges from this route's matching vertices.
|
66
|
+
#
|
67
|
+
# @param [Array<Hash, String, Symbol, extension>, Hash, String, Symbol, extension] filter see {Pacer::Route#property_filter}
|
68
|
+
# If string(s) or symbol(s) are given, they will be treated as edge
|
69
|
+
# labels. Unlike other property filters which all must be matched, an
|
70
|
+
# edge will pass the filter if it matches any of the given labels.
|
71
|
+
# @yield [VertexMixin(Extensions::BlockFilterElement)] filter proc, see {Pacer::Route#property_filter}
|
72
|
+
# @return [VerticesRoute]
|
73
|
+
def in(*filters, &block)
|
74
|
+
filters = extract_labels(filters)
|
75
|
+
Pacer::Route.property_filter(chain_route(:element_type => :vertex,
|
76
|
+
:pipe_class => InPipe,
|
77
|
+
:pipe_args => route_labels,
|
78
|
+
:route_name => edge_route_name('in')),
|
79
|
+
filters, block)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Extends the route with all edges from this route's matching vertices.
|
83
|
+
#
|
84
|
+
# @param [Array<Hash, String, Symbol, extension>, Hash, String, Symbol, extension] filter see {Pacer::Route#property_filter}
|
85
|
+
# If string(s) or symbol(s) are given, they will be treated as edge
|
86
|
+
# labels. Unlike other property filters which all must be matched, an
|
87
|
+
# edge will pass the filter if it matches any of the given labels.
|
88
|
+
# @yield [EdgeMixin(Extensions::BlockFilterElement)] filter proc, see {Pacer::Route#property_filter}
|
89
|
+
# @return [EdgesRoute]
|
90
|
+
def both_e(*filters, &block)
|
91
|
+
filters = extract_labels(filters)
|
92
|
+
Pacer::Route.property_filter(chain_route(:element_type => :edge,
|
93
|
+
:pipe_class => BothEdgesPipe,
|
94
|
+
:pipe_args => route_labels,
|
95
|
+
:route_name => edge_route_name('bothE')),
|
96
|
+
filters, block)
|
97
|
+
end
|
98
|
+
|
99
|
+
# Extends the route with vertices via all edges from this route's matching vertices.
|
100
|
+
#
|
101
|
+
# @param [Array<Hash, String, Symbol, extension>, Hash, String, Symbol, extension] filter see {Pacer::Route#property_filter}
|
102
|
+
# If string(s) or symbol(s) are given, they will be treated as edge
|
103
|
+
# labels. Unlike other property filters which all must be matched, an
|
104
|
+
# edge will pass the filter if it matches any of the given labels.
|
105
|
+
# @yield [VertexMixin(Extensions::BlockFilterElement)] filter proc, see {Pacer::Route#property_filter}
|
106
|
+
# @return [VerticesRoute]
|
107
|
+
def both(*filters, &block)
|
108
|
+
filters = extract_labels(filters)
|
109
|
+
Pacer::Route.property_filter(chain_route(:element_type => :vertex,
|
110
|
+
:pipe_class => BothPipe,
|
111
|
+
:pipe_args => route_labels,
|
112
|
+
:route_name => edge_route_name('both')),
|
113
|
+
filters, block)
|
114
|
+
end
|
115
|
+
|
116
|
+
# Extend route with the additional vertex property and block filters.
|
117
|
+
#
|
118
|
+
# @param [Array<Hash, String, Symbol, extension>, Hash, String, Symbol, extension] filter see {Pacer::Route#property_filter}
|
119
|
+
# If string(s) or symbol(s) are given, they will be treated as edge
|
120
|
+
# labels. Unlike other property filters which all must be matched, an
|
121
|
+
# edge will pass the filter if it matches any of the given labels.
|
122
|
+
# @yield [VertexMixin(Extensions::BlockFilterElement)] filter proc, see {Pacer::Route#property_filter}
|
123
|
+
# @return [VerticesRoute]
|
124
|
+
def v(*filters, &block)
|
125
|
+
filter(*filters, &block)
|
126
|
+
end
|
127
|
+
|
128
|
+
# The element type of this route for this graph implementation.
|
129
|
+
#
|
130
|
+
# @return [element_type(:vertex)] The actual type varies based on
|
131
|
+
# which graph is in use.
|
132
|
+
def element_type
|
133
|
+
graph.element_type(:vertex)
|
134
|
+
end
|
135
|
+
|
136
|
+
# Delete all matching vertices and all edges which link to this
|
137
|
+
# vertex.
|
138
|
+
def delete!
|
139
|
+
uniq.both_e.uniq.bulk_job { |e| e.delete! }
|
140
|
+
uniq.bulk_job { |e| e.delete! }
|
141
|
+
end
|
142
|
+
|
143
|
+
# Create associations with the given label from all vertices
|
144
|
+
# matching this route to all vertices matching the given
|
145
|
+
# to_route. If any properties are given, they will be applied
|
146
|
+
# to each created edge.
|
147
|
+
#
|
148
|
+
# If this route emits more than one element and the to_vertices
|
149
|
+
# param also emits (or contains) more than one element, the
|
150
|
+
# resulting edges will represent a cross-product between the two
|
151
|
+
# collections.
|
152
|
+
#
|
153
|
+
# If a vertex appears in either the this route or in to_vertices,
|
154
|
+
# it will be linked once for each time it appears.
|
155
|
+
#
|
156
|
+
# @param [#to_s] label the label to use for the new edges
|
157
|
+
# @param [VerticesRoute, Enumerable, java.util.Iterator] to_vertices
|
158
|
+
# collection of vertices that should have edges connecting them
|
159
|
+
# from the source edges.
|
160
|
+
# @param optional [Hash] props properties that should be set for
|
161
|
+
# each created edge
|
162
|
+
# @return [EdgesRoute, nil] includes all created edges or nil if no
|
163
|
+
# edges were created
|
164
|
+
def add_edges_to(label, to_vertices, props = {})
|
165
|
+
case to_vertices
|
166
|
+
when Pacer::Core::Route, Enumerable, java.util.Iterator
|
167
|
+
else
|
168
|
+
to_vertices = [to_vertices].compact
|
169
|
+
end
|
170
|
+
graph = self.graph
|
171
|
+
|
172
|
+
has_props = !props.empty?
|
173
|
+
edge_ids = []
|
174
|
+
counter = 0
|
175
|
+
graph.managed_transactions do
|
176
|
+
graph.managed_transaction do
|
177
|
+
each do |from_v|
|
178
|
+
to_vertices.each do |to_v|
|
179
|
+
counter += 1
|
180
|
+
graph.managed_checkpoint if counter % graph.bulk_job_size == 0
|
181
|
+
begin
|
182
|
+
edge = graph.create_edge(nil, from_v, to_v, label.to_s, props)
|
183
|
+
edge_ids << edge.element_id
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
if edge_ids.any?
|
190
|
+
edge_ids.id_to_element_route(:based_on => graph.e)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def route_labels
|
195
|
+
@route_labels
|
196
|
+
end
|
197
|
+
|
198
|
+
protected
|
199
|
+
|
200
|
+
def edge_route_name(prefix)
|
201
|
+
if route_labels.any?
|
202
|
+
"#{prefix}(#{route_labels.map { |l| l.to_sym.inspect }.join ', '})"
|
203
|
+
else
|
204
|
+
prefix
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
def extract_labels(filters)
|
209
|
+
filters = Pacer::Route.edge_filters(filters)
|
210
|
+
@route_labels = filters.labels
|
211
|
+
filters.labels = []
|
212
|
+
filters
|
213
|
+
end
|
214
|
+
|
215
|
+
# TODO: move id_pipe_class into the element_type object
|
216
|
+
def id_pipe_class
|
217
|
+
com.tinkerpop.pipes.transform.IdVertexPipe
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Pacer
|
2
|
+
module Core
|
3
|
+
module Graph
|
4
|
+
end
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'pacer/core/graph/graph_route'
|
9
|
+
require 'pacer/core/graph/graph_index_route'
|
10
|
+
require 'pacer/core/graph/element_route'
|
11
|
+
require 'pacer/core/graph/edges_route'
|
12
|
+
require 'pacer/core/graph/vertices_route'
|
13
|
+
require 'pacer/core/graph/mixed_route'
|