pacer 0.9.1.1-java → 1.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -3,11 +3,14 @@ module Pacer::Core::Graph
|
|
3
3
|
# Basic methods for routes shared between all route types that emit
|
4
4
|
# routes: {VerticesRoute}, {EdgesRoute} and {MixedRoute}
|
5
5
|
module ElementRoute
|
6
|
+
def graph
|
7
|
+
config[:graph]
|
8
|
+
end
|
6
9
|
|
7
10
|
# Attach a filter to the current route.
|
8
11
|
#
|
9
12
|
# @param [Array<Hash, extension>, Hash, extension] filter see {Pacer::Route#property_filter}
|
10
|
-
# @yield [
|
13
|
+
# @yield [ElementWrapper(Extensions::BlockFilterElement)] filter proc, see {Pacer::Route#property_filter}
|
11
14
|
# @return [ElementRoute] the same type and extensions as the source route.
|
12
15
|
def filter(*filters, &block)
|
13
16
|
Pacer::Route.property_filter(self, filters, block)
|
@@ -37,8 +40,8 @@ module Pacer::Core::Graph
|
|
37
40
|
# Create a new TinkerGraph based on the paths of all matching elements.
|
38
41
|
#
|
39
42
|
# @return [TinkerGraph] the subgraph
|
40
|
-
def subgraph
|
41
|
-
paths.subgraph
|
43
|
+
def subgraph opts = {}
|
44
|
+
paths.subgraph nil, opts
|
42
45
|
end
|
43
46
|
|
44
47
|
# Delete all matching elements.
|
@@ -118,14 +121,14 @@ module Pacer::Core::Graph
|
|
118
121
|
|
119
122
|
def build_index(index, index_key = nil, property = nil, create = true)
|
120
123
|
index_name = index
|
121
|
-
unless index.is_a? com.tinkerpop.blueprints.
|
122
|
-
index = graph.
|
124
|
+
unless index.is_a? com.tinkerpop.blueprints.Index
|
125
|
+
index = graph.index index.to_s
|
123
126
|
end
|
124
127
|
sample_element = first
|
125
128
|
unless index
|
126
129
|
if sample_element
|
127
130
|
if create
|
128
|
-
index = graph.
|
131
|
+
index = graph.index index_name, graph.element_type(sample_element), create: true
|
129
132
|
else
|
130
133
|
raise "No index found for #{ index } on #{ graph }" unless index
|
131
134
|
end
|
@@ -133,7 +136,7 @@ module Pacer::Core::Graph
|
|
133
136
|
return nil
|
134
137
|
end
|
135
138
|
end
|
136
|
-
index_key ||= index.
|
139
|
+
index_key ||= index.name
|
137
140
|
property ||= index_key
|
138
141
|
if block_given?
|
139
142
|
bulk_job do |element|
|
@@ -151,21 +154,11 @@ module Pacer::Core::Graph
|
|
151
154
|
|
152
155
|
protected
|
153
156
|
|
154
|
-
# Determines which iterator mixin is applied to the iterator when #each is called
|
155
157
|
def configure_iterator(iter)
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
iter.graph = graph
|
161
|
-
elsif extensions and extensions.any?
|
162
|
-
iter.extend Pacer::Core::Route::IteratorExtensionsMixin
|
163
|
-
iter.extensions = extensions
|
164
|
-
iter.graph = graph
|
165
|
-
else
|
166
|
-
iter.extend Pacer::Core::Route::IteratorMixin
|
167
|
-
iter.graph = graph
|
168
|
-
end
|
158
|
+
pipe = Pacer::Pipes::WrappingPipe.new graph, element_type, extensions
|
159
|
+
pipe.wrapper = wrapper if wrapper
|
160
|
+
pipe.setStarts iter
|
161
|
+
pipe
|
169
162
|
end
|
170
163
|
end
|
171
164
|
end
|
@@ -4,9 +4,11 @@ module Pacer::Core::Graph
|
|
4
4
|
# blueprints library.
|
5
5
|
module GraphIndexRoute
|
6
6
|
# Returns a new route to all graph vertices. Standard filter options.
|
7
|
-
def v(*
|
8
|
-
filters = Pacer::Route.filters(
|
9
|
-
|
7
|
+
def v(*args, &block)
|
8
|
+
filters = Pacer::Route.filters(args)
|
9
|
+
if features.supportsIndices
|
10
|
+
route = indexed_route(:vertex, filters, block)
|
11
|
+
end
|
10
12
|
if route
|
11
13
|
route
|
12
14
|
else
|
@@ -15,9 +17,11 @@ module Pacer::Core::Graph
|
|
15
17
|
end
|
16
18
|
|
17
19
|
# Returns a new route to all graph edges. Standard filter options.
|
18
|
-
def e(*
|
19
|
-
filters = Pacer::Route.edge_filters(
|
20
|
-
|
20
|
+
def e(*args, &block)
|
21
|
+
filters = Pacer::Route.edge_filters(args)
|
22
|
+
if features.supportsIndices
|
23
|
+
route = indexed_route(:edge, filters, block)
|
24
|
+
end
|
21
25
|
if route
|
22
26
|
route
|
23
27
|
else
|
@@ -28,11 +32,11 @@ module Pacer::Core::Graph
|
|
28
32
|
attr_accessor :choose_best_index
|
29
33
|
attr_accessor :search_manual_indices
|
30
34
|
|
31
|
-
|
35
|
+
private
|
32
36
|
|
33
37
|
def indexed_route(element_type, filters, block)
|
34
38
|
filters.graph = self
|
35
|
-
filters.indices = graph.
|
39
|
+
filters.indices = graph.indices
|
36
40
|
filters.choose_best_index = choose_best_index != false
|
37
41
|
filters.search_manual_indices = search_manual_indices
|
38
42
|
idx, key, value = filters.best_index(element_type)
|
@@ -3,14 +3,11 @@ module Pacer::Core::Graph
|
|
3
3
|
# This module adds route methods to the basic graph classes returned from the
|
4
4
|
# blueprints library.
|
5
5
|
module GraphRoute
|
6
|
-
import com.tinkerpop.pipes.transform.VerticesPipe
|
7
|
-
import com.tinkerpop.pipes.transform.EdgesPipe
|
8
|
-
|
9
6
|
# Returns a new route to all graph vertices. Standard filter options.
|
10
7
|
def v(*filters, &block)
|
11
8
|
filters = Pacer::Route.filters(filters)
|
12
9
|
route = chain_route :element_type => :vertex,
|
13
|
-
:pipe_class => VerticesPipe,
|
10
|
+
:pipe_class => Pacer::Pipes::VerticesPipe,
|
14
11
|
:route_name => 'GraphV'
|
15
12
|
Pacer::Route.property_filter(route, filters, block)
|
16
13
|
end
|
@@ -19,7 +16,7 @@ module Pacer::Core::Graph
|
|
19
16
|
def e(*filters, &block)
|
20
17
|
filters = Pacer::Route.edge_filters(filters)
|
21
18
|
route = chain_route :element_type => :edge,
|
22
|
-
:pipe_class => EdgesPipe,
|
19
|
+
:pipe_class => Pacer::Pipes::EdgesPipe,
|
23
20
|
:route_name => 'GraphE'
|
24
21
|
Pacer::Route.property_filter(route, filters, block)
|
25
22
|
end
|
@@ -3,13 +3,11 @@ module Pacer::Core::Graph
|
|
3
3
|
# Basic methods for routes that may contain both vertices and edges. That can
|
4
4
|
# happen as the result of a branched route, for example.
|
5
5
|
module MixedRoute
|
6
|
-
include ElementRoute
|
7
|
-
|
8
6
|
# Pass through only vertices.
|
9
7
|
def v(*args, &block)
|
10
8
|
route = chain_route :element_type => :vertex,
|
11
9
|
:pipe_class => Pacer::Pipes::TypeFilterPipe,
|
12
|
-
:pipe_args => Pacer::
|
10
|
+
:pipe_args => Pacer::Wrappers::VertexWrapper,
|
13
11
|
:wrapper => wrapper,
|
14
12
|
:extensions => extensions
|
15
13
|
Pacer::Route.property_filter(route, args, block)
|
@@ -19,7 +17,7 @@ module Pacer::Core::Graph
|
|
19
17
|
def e(*args, &block)
|
20
18
|
route = chain_route :element_type => :edge,
|
21
19
|
:pipe_class => Pacer::Pipes::TypeFilterPipe,
|
22
|
-
:pipe_args => Pacer::
|
20
|
+
:pipe_args => Pacer::Wrappers::EdgeWrapper,
|
23
21
|
:wrapper => wrapper,
|
24
22
|
:extensions => extensions
|
25
23
|
Pacer::Route.property_filter(route, args, block)
|
@@ -76,7 +74,7 @@ module Pacer::Core::Graph
|
|
76
74
|
# Calculate and save result.
|
77
75
|
def result(name = nil)
|
78
76
|
ids = collect do |element|
|
79
|
-
if element.is_a? Pacer::
|
77
|
+
if element.is_a? Pacer::Wrappers::VertexWrapper
|
80
78
|
[:vertex, element.element_id]
|
81
79
|
else
|
82
80
|
[:edge, element.element_id]
|
@@ -2,14 +2,12 @@ module Pacer::Core::Graph
|
|
2
2
|
|
3
3
|
# Basic methods for routes that contain only vertices.
|
4
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
|
5
|
+
import com.tinkerpop.gremlin.pipes.transform.OutEdgesPipe
|
6
|
+
import com.tinkerpop.gremlin.pipes.transform.OutPipe
|
7
|
+
import com.tinkerpop.gremlin.pipes.transform.InEdgesPipe
|
8
|
+
import com.tinkerpop.gremlin.pipes.transform.InPipe
|
9
|
+
import com.tinkerpop.gremlin.pipes.transform.BothEdgesPipe
|
10
|
+
import com.tinkerpop.gremlin.pipes.transform.BothPipe
|
13
11
|
|
14
12
|
# Extends the route with out edges from this route's matching vertices.
|
15
13
|
#
|
@@ -17,7 +15,7 @@ module Pacer::Core::Graph
|
|
17
15
|
# If string(s) or symbol(s) are given, they will be treated as edge
|
18
16
|
# labels. Unlike other property filters which all must be matched, an
|
19
17
|
# edge will pass the filter if it matches any of the given labels.
|
20
|
-
# @yield [
|
18
|
+
# @yield [EdgeWrapper(Extensions::BlockFilterElement)] filter proc, see {Pacer::Route#property_filter}
|
21
19
|
# @return [EdgesRoute]
|
22
20
|
def out_e(*filters, &block)
|
23
21
|
filters = extract_labels(filters)
|
@@ -34,7 +32,7 @@ module Pacer::Core::Graph
|
|
34
32
|
# If string(s) or symbol(s) are given, they will be treated as edge
|
35
33
|
# labels. Unlike other property filters which all must be matched, an
|
36
34
|
# edge will pass the filter if it matches any of the given labels.
|
37
|
-
# @yield [
|
35
|
+
# @yield [VertexWrapper(Extensions::BlockFilterElement)] filter proc, see {Pacer::Route#property_filter}
|
38
36
|
# @return [VerticesRoute]
|
39
37
|
def out(*filters, &block)
|
40
38
|
filters = extract_labels(filters)
|
@@ -51,7 +49,7 @@ module Pacer::Core::Graph
|
|
51
49
|
# If string(s) or symbol(s) are given, they will be treated as edge
|
52
50
|
# labels. Unlike other property filters which all must be matched, an
|
53
51
|
# edge will pass the filter if it matches any of the given labels.
|
54
|
-
# @yield [
|
52
|
+
# @yield [EdgeWrapper(Extensions::BlockFilterElement)] filter proc, see {Pacer::Route#property_filter}
|
55
53
|
# @return [EdgesRoute]
|
56
54
|
def in_e(*filters, &block)
|
57
55
|
filters = extract_labels(filters)
|
@@ -68,7 +66,7 @@ module Pacer::Core::Graph
|
|
68
66
|
# If string(s) or symbol(s) are given, they will be treated as edge
|
69
67
|
# labels. Unlike other property filters which all must be matched, an
|
70
68
|
# edge will pass the filter if it matches any of the given labels.
|
71
|
-
# @yield [
|
69
|
+
# @yield [VertexWrapper(Extensions::BlockFilterElement)] filter proc, see {Pacer::Route#property_filter}
|
72
70
|
# @return [VerticesRoute]
|
73
71
|
def in(*filters, &block)
|
74
72
|
filters = extract_labels(filters)
|
@@ -85,7 +83,7 @@ module Pacer::Core::Graph
|
|
85
83
|
# If string(s) or symbol(s) are given, they will be treated as edge
|
86
84
|
# labels. Unlike other property filters which all must be matched, an
|
87
85
|
# edge will pass the filter if it matches any of the given labels.
|
88
|
-
# @yield [
|
86
|
+
# @yield [EdgeWrapper(Extensions::BlockFilterElement)] filter proc, see {Pacer::Route#property_filter}
|
89
87
|
# @return [EdgesRoute]
|
90
88
|
def both_e(*filters, &block)
|
91
89
|
filters = extract_labels(filters)
|
@@ -102,7 +100,7 @@ module Pacer::Core::Graph
|
|
102
100
|
# If string(s) or symbol(s) are given, they will be treated as edge
|
103
101
|
# labels. Unlike other property filters which all must be matched, an
|
104
102
|
# edge will pass the filter if it matches any of the given labels.
|
105
|
-
# @yield [
|
103
|
+
# @yield [VertexWrapper(Extensions::BlockFilterElement)] filter proc, see {Pacer::Route#property_filter}
|
106
104
|
# @return [VerticesRoute]
|
107
105
|
def both(*filters, &block)
|
108
106
|
filters = extract_labels(filters)
|
@@ -119,7 +117,7 @@ module Pacer::Core::Graph
|
|
119
117
|
# If string(s) or symbol(s) are given, they will be treated as edge
|
120
118
|
# labels. Unlike other property filters which all must be matched, an
|
121
119
|
# edge will pass the filter if it matches any of the given labels.
|
122
|
-
# @yield [
|
120
|
+
# @yield [VertexWrapper(Extensions::BlockFilterElement)] filter proc, see {Pacer::Route#property_filter}
|
123
121
|
# @return [VerticesRoute]
|
124
122
|
def v(*filters, &block)
|
125
123
|
filter(*filters, &block)
|
@@ -130,7 +128,7 @@ module Pacer::Core::Graph
|
|
130
128
|
# @return [element_type(:vertex)] The actual type varies based on
|
131
129
|
# which graph is in use.
|
132
130
|
def element_type
|
133
|
-
|
131
|
+
:vertex
|
134
132
|
end
|
135
133
|
|
136
134
|
# Delete all matching vertices and all edges which link to this
|
@@ -172,16 +170,17 @@ module Pacer::Core::Graph
|
|
172
170
|
has_props = !props.empty?
|
173
171
|
edge_ids = []
|
174
172
|
counter = 0
|
175
|
-
graph.
|
176
|
-
|
177
|
-
each do |
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
173
|
+
graph.transaction do |commit, rollback|
|
174
|
+
v.each do |from_v|
|
175
|
+
to_vertices.each do |to_v|
|
176
|
+
counter += 1
|
177
|
+
if counter == graph.bulk_job_size
|
178
|
+
commit.call
|
179
|
+
counter = 0
|
180
|
+
end
|
181
|
+
begin
|
182
|
+
edge = graph.create_edge(nil, from_v, to_v, label.to_s, props)
|
183
|
+
edge_ids << edge.element_id
|
185
184
|
end
|
186
185
|
end
|
187
186
|
end
|
@@ -214,7 +213,7 @@ module Pacer::Core::Graph
|
|
214
213
|
|
215
214
|
# TODO: move id_pipe_class into the element_type object
|
216
215
|
def id_pipe_class
|
217
|
-
com.tinkerpop.pipes.transform.IdVertexPipe
|
216
|
+
com.tinkerpop.gremlin.pipes.transform.IdVertexPipe
|
218
217
|
end
|
219
218
|
end
|
220
219
|
end
|
data/lib/pacer/core/route.rb
CHANGED
@@ -35,7 +35,7 @@ module Pacer
|
|
35
35
|
#
|
36
36
|
# @todo move this to graph routes.
|
37
37
|
#
|
38
|
-
# @return [
|
38
|
+
# @return [PacerGraph]
|
39
39
|
def graph
|
40
40
|
@graph = nil unless defined? @graph
|
41
41
|
@graph ||= (@back || @source).graph rescue nil
|
@@ -109,7 +109,7 @@ module Pacer
|
|
109
109
|
# @return [Enumerator] if no block is given
|
110
110
|
def each
|
111
111
|
iter = iterator
|
112
|
-
configure_iterator(iter)
|
112
|
+
iter = configure_iterator(iter)
|
113
113
|
if block_given?
|
114
114
|
while true
|
115
115
|
yield iter.next
|
@@ -117,7 +117,7 @@ module Pacer
|
|
117
117
|
else
|
118
118
|
iter
|
119
119
|
end
|
120
|
-
rescue java.util.NoSuchElementException
|
120
|
+
rescue Pacer::EmptyPipe, java.util.NoSuchElementException
|
121
121
|
self
|
122
122
|
end
|
123
123
|
|
@@ -127,10 +127,17 @@ module Pacer
|
|
127
127
|
# @return [java.util.Iterator] the pipe.
|
128
128
|
def pipe
|
129
129
|
iterator = each
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
130
|
+
if block_given?
|
131
|
+
yield iterator if block_given?
|
132
|
+
else
|
133
|
+
iterator
|
134
|
+
end
|
135
|
+
rescue Pacer::EmptyPipe, java.util.NoSuchElementException
|
136
|
+
nil
|
137
|
+
end
|
138
|
+
|
139
|
+
def description(join = ' -> ')
|
140
|
+
"#<#{inspect_strings.join(join)}>"
|
134
141
|
end
|
135
142
|
|
136
143
|
# Returns a string representation of the route definition. If there are
|
@@ -142,7 +149,7 @@ module Pacer
|
|
142
149
|
# @return [String]
|
143
150
|
def inspect(limit = nil)
|
144
151
|
if Pacer.hide_route_elements or hide_elements or source_iterator.nil?
|
145
|
-
|
152
|
+
description
|
146
153
|
else
|
147
154
|
Pacer.hide_route_elements do
|
148
155
|
count = 0
|
@@ -169,7 +176,7 @@ module Pacer
|
|
169
176
|
end
|
170
177
|
end
|
171
178
|
puts "Total: #{ count }"
|
172
|
-
|
179
|
+
description
|
173
180
|
end
|
174
181
|
end
|
175
182
|
end
|
@@ -192,54 +199,14 @@ module Pacer
|
|
192
199
|
none?
|
193
200
|
end
|
194
201
|
|
195
|
-
# Add an extension to the route.
|
196
|
-
#
|
197
|
-
# If the extension has a Route module inside it, this route will
|
198
|
-
# be extended with the extension's Route module.
|
199
|
-
#
|
200
|
-
# If the extension has a Vertex or Edge module inside it, any vertices
|
201
|
-
# or edges emitted from this route will be extended with with the
|
202
|
-
# extension as well.
|
203
|
-
#
|
204
|
-
# @see VertexMixin#add_extensions
|
205
|
-
# @see EdgeMixin#add_extensions
|
206
|
-
#
|
207
|
-
# @return [self]
|
208
|
-
def add_extension(mod, add_to_list = true)
|
209
|
-
return self unless mod.respond_to?(:const_defined?)
|
210
|
-
is_extension = false
|
211
|
-
if mod.const_defined? :Route
|
212
|
-
is_extension = true
|
213
|
-
extend mod::Route
|
214
|
-
end
|
215
|
-
if add_to_list and (is_extension or mod.const_defined? :Vertex or mod.const_defined? :Edge)
|
216
|
-
@extensions << mod
|
217
|
-
end
|
218
|
-
self
|
219
|
-
end
|
220
|
-
|
221
202
|
def set_wrapper(wrapper)
|
222
|
-
|
223
|
-
wrapper.extensions.each do |ext|
|
224
|
-
add_extension ext, false
|
225
|
-
end
|
226
|
-
end
|
227
|
-
@wrapper = wrapper
|
228
|
-
self
|
203
|
+
chain_route wrapper: wrapper
|
229
204
|
end
|
230
|
-
alias wrapper= set_wrapper
|
231
205
|
|
232
206
|
def wrapper
|
233
207
|
@wrapper
|
234
208
|
end
|
235
209
|
|
236
|
-
# Add extensions to this route.
|
237
|
-
#
|
238
|
-
# @see #add_extension
|
239
|
-
def extensions=(exts)
|
240
|
-
add_extensions Set[*exts]
|
241
|
-
end
|
242
|
-
|
243
210
|
# Get the set of extensions currently on this route.
|
244
211
|
#
|
245
212
|
# The order of extensions for custom defined wrappers are
|
@@ -248,31 +215,32 @@ module Pacer
|
|
248
215
|
# extensions in order followed by any additional extensions in
|
249
216
|
# undefined order.
|
250
217
|
#
|
251
|
-
#
|
218
|
+
# Returns an Array
|
252
219
|
#
|
253
|
-
# @return [
|
254
|
-
|
220
|
+
# @return [Array[extension]]
|
221
|
+
attr_reader :extensions
|
222
|
+
|
223
|
+
def all_extensions
|
255
224
|
if wrapper
|
256
|
-
wrapper.extensions +
|
225
|
+
wrapper.extensions + extensions
|
257
226
|
else
|
258
|
-
|
227
|
+
extensions
|
259
228
|
end
|
260
229
|
end
|
261
230
|
|
262
231
|
# If any objects in the given array are modules that contain a Route
|
263
232
|
# submodule, extend this route with the Route module.
|
264
|
-
# @see #add_extension
|
265
233
|
# @return [self]
|
266
234
|
def add_extensions(exts)
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
235
|
+
chain_route extensions: (extensions - exts) + exts
|
236
|
+
end
|
237
|
+
|
238
|
+
def set_extensions(exts)
|
239
|
+
chain_route extensions: exts, wrapper: nil
|
272
240
|
end
|
273
241
|
|
274
242
|
def no_extensions
|
275
|
-
chain_route(:extensions =>
|
243
|
+
chain_route(:extensions => [], :wrapper => nil)
|
276
244
|
end
|
277
245
|
|
278
246
|
# Change the source of this route.
|
@@ -293,9 +261,10 @@ module Pacer
|
|
293
261
|
|
294
262
|
# Set the previous route in the chain.
|
295
263
|
def back=(back)
|
296
|
-
if back.is_a? Route and not back.is_a?
|
264
|
+
if back.is_a? Route and not back.is_a? PacerGraph
|
297
265
|
@back = back
|
298
266
|
else
|
267
|
+
@back = nil
|
299
268
|
@source = back
|
300
269
|
end
|
301
270
|
end
|
@@ -316,6 +285,7 @@ module Pacer
|
|
316
285
|
# Overridden to extend the iterator to apply mixins
|
317
286
|
# or wrap elements
|
318
287
|
def configure_iterator(iter)
|
288
|
+
iter
|
319
289
|
end
|
320
290
|
|
321
291
|
def get_section_route(name)
|
@@ -363,9 +333,9 @@ module Pacer
|
|
363
333
|
|
364
334
|
# Return an iterator for a variety of source object types.
|
365
335
|
def iterator_from_source(src)
|
366
|
-
if src.is_a?
|
336
|
+
if src.is_a? PacerGraph
|
367
337
|
al = java.util.ArrayList.new
|
368
|
-
al << src
|
338
|
+
al << src.blueprints_graph
|
369
339
|
al.iterator
|
370
340
|
elsif src.is_a? Pacer::Wrappers::ElementWrapper
|
371
341
|
Pacer::Pipes::EnumerablePipe.new src.element
|
@@ -496,7 +466,6 @@ module Pacer
|
|
496
466
|
s = "#{s} #{ info }" if info
|
497
467
|
s
|
498
468
|
end
|
499
|
-
|
500
469
|
end
|
501
470
|
end
|
502
471
|
end
|
data/lib/pacer/exceptions.rb
CHANGED
@@ -1,11 +1,18 @@
|
|
1
1
|
module Pacer
|
2
|
-
class
|
3
|
-
|
2
|
+
class Error < StandardError; end
|
3
|
+
class UserError < Error; end
|
4
|
+
class ElementNotFound < UserError; end
|
5
|
+
class ElementExists < UserError; end
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
+
class LogicError < Error; end
|
8
|
+
class ClientError < LogicError; end
|
9
|
+
class TransactionConcludedError < ClientError; end
|
10
|
+
class NestedTransactionRollback < ClientError; end
|
11
|
+
class NestedMockTransactionRollback < NestedTransactionRollback; end
|
12
|
+
class MockTransactionRollback < ClientError; end
|
13
|
+
class UnsupportedOperation < ClientError; end
|
7
14
|
|
8
|
-
|
9
|
-
|
15
|
+
class InternalError < LogicError; end
|
16
|
+
class TransientError < Error; end
|
10
17
|
end
|
11
18
|
|
@@ -27,6 +27,8 @@ module Pacer
|
|
27
27
|
module CollectionFilter
|
28
28
|
import java.util.HashSet
|
29
29
|
|
30
|
+
include Pacer::Visitors::VisitsSection
|
31
|
+
|
30
32
|
attr_reader :var, :comparison, :ids, :objects
|
31
33
|
|
32
34
|
def except=(collection)
|
@@ -36,6 +38,7 @@ module Pacer
|
|
36
38
|
|
37
39
|
def except_var=(var)
|
38
40
|
@var = var
|
41
|
+
self.section = var
|
39
42
|
@comparison = Pacer::Pipes::NOT_EQUAL
|
40
43
|
end
|
41
44
|
|
@@ -46,6 +49,7 @@ module Pacer
|
|
46
49
|
|
47
50
|
def only_var=(var)
|
48
51
|
@var = var
|
52
|
+
self.section = var
|
49
53
|
@comparison = Pacer::Pipes::EQUAL
|
50
54
|
end
|
51
55
|
|
@@ -73,8 +77,11 @@ module Pacer
|
|
73
77
|
end
|
74
78
|
|
75
79
|
def attach_pipe(end_pipe)
|
76
|
-
if
|
77
|
-
|
80
|
+
if section_visitor_target
|
81
|
+
element = section_visitor_target.new
|
82
|
+
# Will cause section_visitor to call the #on_element and #reset methods.
|
83
|
+
section_visitor.visitor = element
|
84
|
+
pipe = Pacer::Pipes::CollectionFilterPipe.new(element, comparison)
|
78
85
|
elsif ids
|
79
86
|
pipe = Pacer::Pipes::IdCollectionFilterPipe.new(ids, comparison)
|
80
87
|
else
|
@@ -13,7 +13,7 @@ module Pacer
|
|
13
13
|
# @param [Route] back the route the new route is based on.
|
14
14
|
# @return [Route]
|
15
15
|
def empty(back)
|
16
|
-
|
16
|
+
back.chain_route :filter => :empty
|
17
17
|
end
|
18
18
|
|
19
19
|
def block_branch(back, block, branch_start = nil)
|
@@ -21,7 +21,7 @@ module Pacer
|
|
21
21
|
route = block.call rescue nil
|
22
22
|
else
|
23
23
|
unless branch_start
|
24
|
-
if back.is_a? Pacer::Graph
|
24
|
+
if back.is_a? Pacer::Graph
|
25
25
|
branch_start = back
|
26
26
|
else
|
27
27
|
branch_start = Pacer::Route.empty(back)
|
@@ -61,7 +61,16 @@ module Pacer
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def inspect_class_name
|
64
|
-
s =
|
64
|
+
s = case element_type
|
65
|
+
when :vertex
|
66
|
+
'V'
|
67
|
+
when :edge
|
68
|
+
'E'
|
69
|
+
when :object
|
70
|
+
'Obj'
|
71
|
+
when :mixed
|
72
|
+
'Elem'
|
73
|
+
end
|
65
74
|
s = "#{s} #{ @info }" if @info
|
66
75
|
s
|
67
76
|
end
|
@@ -18,11 +18,11 @@ module Pacer
|
|
18
18
|
attr_accessor :min, :max
|
19
19
|
|
20
20
|
def block=(block)
|
21
|
-
@future_filter = [block,
|
21
|
+
@future_filter = [block, false]
|
22
22
|
end
|
23
23
|
|
24
24
|
def neg_block=(block)
|
25
|
-
@future_filter = [block,
|
25
|
+
@future_filter = [block, true]
|
26
26
|
end
|
27
27
|
|
28
28
|
protected
|
@@ -41,14 +41,14 @@ module Pacer
|
|
41
41
|
|
42
42
|
def lookahead_route
|
43
43
|
if @future_filter
|
44
|
-
block,
|
44
|
+
block, negate = @future_filter
|
45
45
|
@future_filter = nil
|
46
46
|
route = block.call(Pacer::Route.empty(self))
|
47
47
|
if min or max
|
48
48
|
route = route.has_count_route(:min => min, :max => max).is(true)
|
49
49
|
end
|
50
|
-
|
51
|
-
route = route.chain_route(:
|
50
|
+
if negate
|
51
|
+
route = route.chain_route(pipe_class: Pacer::Pipes::IsEmptyPipe, :route_name => 'negate')
|
52
52
|
end
|
53
53
|
@route = route
|
54
54
|
elsif @route
|