pacer 1.0.3-java → 1.1.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/Gemfile +1 -6
- data/lib/{pacer-1.0.3-standalone.jar → pacer-1.1.0-standalone.jar} +0 -0
- data/lib/pacer.rb +4 -0
- data/lib/pacer/blueprints/payload_elements.rb +44 -0
- data/lib/pacer/core/graph.rb +1 -0
- data/lib/pacer/core/graph/element_route.rb +3 -2
- data/lib/pacer/core/graph/path_route.rb +138 -0
- data/lib/pacer/core/route.rb +145 -1
- data/lib/pacer/filter/empty_filter.rb +2 -0
- data/lib/pacer/filter/loop_filter.rb +85 -0
- data/lib/pacer/filter/property_filter/filters.rb +6 -1
- data/lib/pacer/graph/graph_transactions_mixin.rb +6 -1
- data/lib/pacer/graph/pacer_graph.rb +47 -30
- data/lib/pacer/graph/yaml_encoder.rb +2 -0
- data/lib/pacer/loader.rb +9 -0
- data/lib/pacer/pipe/block_filter_pipe.rb +3 -2
- data/lib/pacer/pipe/loop_pipe.rb +23 -17
- data/lib/pacer/pipe/multi_pipe.rb +40 -0
- data/lib/pacer/pipe/naked_pipe.rb +21 -0
- data/lib/pacer/pipe/unwrapping_pipe.rb +4 -0
- data/lib/pacer/pipe/wrapping_pipe.rb +4 -0
- data/lib/pacer/pipes.rb +2 -1
- data/lib/pacer/route/mixin/route_operations.rb +15 -0
- data/lib/pacer/route_builder.rb +8 -11
- data/lib/pacer/side_effect/counted.rb +1 -0
- data/lib/pacer/side_effect/group_count.rb +1 -1
- data/lib/pacer/support/array.rb +18 -0
- data/lib/pacer/support/enumerable.rb +4 -0
- data/lib/pacer/transform/cap.rb +31 -0
- data/lib/pacer/transform/flat_map.rb +9 -0
- data/lib/pacer/transform/make_pairs.rb +29 -0
- data/lib/pacer/transform/map.rb +50 -2
- data/lib/pacer/transform/path.rb +27 -42
- data/lib/pacer/transform/path_tree.rb +111 -0
- data/lib/pacer/transform/payload.rb +50 -0
- data/lib/pacer/transform/process.rb +15 -0
- data/lib/pacer/transform/wrapped_path.rb +23 -0
- data/lib/pacer/utils/graph_analysis.rb +21 -7
- data/lib/pacer/version.rb +1 -1
- data/lib/pacer/wrappers/edge_wrapper.rb +18 -7
- data/lib/pacer/wrappers/element_wrapper.rb +4 -0
- data/lib/pacer/wrappers/index_wrapper.rb +1 -1
- data/lib/pacer/wrappers/path_wrapping_pipe_function.rb +85 -0
- data/lib/pacer/wrappers/vertex_wrapper.rb +33 -3
- data/pom.xml +1 -1
- data/spec/pacer/filter/property_filter/edge_filters_spec.rb +63 -0
- data/spec/pacer/filter/property_filter/filters_spec.rb +17 -7
- data/spec/pacer/transform/join_spec.rb +0 -1
- data/spec/pacer/transform/path_tree_spec.rb +97 -0
- data/spec/spec_helper.rb +2 -2
- metadata +18 -3
@@ -89,6 +89,11 @@ module Pacer
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
+
def remove_property_keys(keys)
|
93
|
+
properties.delete_if { |a| keys.include? a.first }
|
94
|
+
non_ext_props.delete_if { |a| keys.include? a.first }
|
95
|
+
end
|
96
|
+
|
92
97
|
# Set which indices are available to be used to determine the
|
93
98
|
# best_index.
|
94
99
|
#
|
@@ -225,7 +230,7 @@ module Pacer
|
|
225
230
|
return nil if avail.empty?
|
226
231
|
index_options = []
|
227
232
|
properties.each do |k, v|
|
228
|
-
if index_for_property(avail, index_options, k, v)
|
233
|
+
if v and index_for_property(avail, index_options, k, v)
|
229
234
|
return @best_index
|
230
235
|
end
|
231
236
|
end
|
@@ -47,6 +47,11 @@ module Pacer
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
+
# Set this to true if you don't want to use transactions.
|
51
|
+
#
|
52
|
+
# By default, transactions are enabled.
|
53
|
+
attr_accessor :disable_transactions
|
54
|
+
|
50
55
|
private
|
51
56
|
|
52
57
|
def threadlocal_graph_info
|
@@ -58,7 +63,7 @@ module Pacer
|
|
58
63
|
tgi = threadlocal_graph_info
|
59
64
|
tx_depth = tgi[:tx_depth] ||= 0
|
60
65
|
tgi[:tx_depth] += 1
|
61
|
-
if blueprints_graph.is_a? TransactionalGraph
|
66
|
+
if (not disable_transactions) and blueprints_graph.is_a? TransactionalGraph
|
62
67
|
if tx_depth == 0
|
63
68
|
base_tx_finalizers
|
64
69
|
elsif opts[:nesting] == true
|
@@ -26,13 +26,18 @@ module Pacer
|
|
26
26
|
self
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
30
|
-
|
31
|
-
if
|
32
|
-
|
29
|
+
def vendor(full = false)
|
30
|
+
g = blueprints_graph
|
31
|
+
g = g.raw_graph if g.respond_to? :raw_graph
|
32
|
+
if full
|
33
|
+
g.java_class.name
|
33
34
|
else
|
34
|
-
|
35
|
+
g.java_class.name.split('.')[1]
|
35
36
|
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def reopen
|
40
|
+
@blueprints_graph = unwrap_graph @reopen.call
|
36
41
|
self
|
37
42
|
end
|
38
43
|
|
@@ -42,6 +47,17 @@ module Pacer
|
|
42
47
|
self
|
43
48
|
end
|
44
49
|
|
50
|
+
def use_wrapper(klass)
|
51
|
+
reopen = proc do
|
52
|
+
klass.new unwrap_graph(@reopen.call)
|
53
|
+
end
|
54
|
+
PacerGraph.new encoder, reopen, @shutdown
|
55
|
+
end
|
56
|
+
|
57
|
+
def use_encoder(encoder)
|
58
|
+
PacerGraph.new encoder, @reopen, @shutdown
|
59
|
+
end
|
60
|
+
|
45
61
|
def graph_id
|
46
62
|
blueprints_graph.object_id
|
47
63
|
end
|
@@ -187,6 +203,26 @@ module Pacer
|
|
187
203
|
blueprints_graph.features
|
188
204
|
end
|
189
205
|
|
206
|
+
def inspect
|
207
|
+
"#<PacerGraph #{ blueprints_graph.to_s }"
|
208
|
+
end
|
209
|
+
|
210
|
+
|
211
|
+
private
|
212
|
+
|
213
|
+
def unwrap_graph(graph)
|
214
|
+
if graph.is_a? PacerGraph
|
215
|
+
graph.blueprints_graph
|
216
|
+
else
|
217
|
+
graph
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
public
|
225
|
+
|
190
226
|
module Encoding
|
191
227
|
def encode_property(value)
|
192
228
|
encoder.encode_property value
|
@@ -201,35 +237,16 @@ module Pacer
|
|
201
237
|
module Naming
|
202
238
|
# The proc used to name vertices.
|
203
239
|
#
|
204
|
-
# @return [Proc]
|
205
|
-
|
206
|
-
@vertex_name if defined? @vertex_name
|
207
|
-
end
|
208
|
-
|
209
|
-
# Set the proc used to name vertices.
|
210
|
-
#
|
211
|
-
# @param [Proc(vertex)] a_proc returns a string given a vertex
|
212
|
-
def vertex_name=(a_proc)
|
213
|
-
@vertex_name = a_proc
|
214
|
-
end
|
240
|
+
# @return [Proc] returns a string given a vertex
|
241
|
+
attr_accessor :vertex_name
|
215
242
|
|
216
243
|
# The proc used to name edges.
|
217
244
|
#
|
218
|
-
# @return [Proc]
|
219
|
-
|
220
|
-
@edge_name if defined? @edge_name
|
221
|
-
end
|
222
|
-
|
223
|
-
# Set the proc used to name edges.
|
224
|
-
#
|
225
|
-
# @param [Proc(edge)] a_proc returns a string given an edge
|
226
|
-
def edge_name=(a_proc)
|
227
|
-
@edge_name = a_proc
|
228
|
-
end
|
245
|
+
# @return [Proc] returns a string given an edge
|
246
|
+
attr_accessor :edge_name
|
229
247
|
end
|
230
248
|
include Naming
|
231
249
|
|
232
|
-
|
233
250
|
module BulkJob
|
234
251
|
attr_accessor :in_bulk_job
|
235
252
|
|
@@ -346,9 +363,9 @@ module Pacer
|
|
346
363
|
def create_key_index(name, type)
|
347
364
|
if features.supportsKeyIndices
|
348
365
|
if element_type(type) == :vertex and features.supportsVertexKeyIndex
|
349
|
-
blueprints_graph.createKeyIndex name, index_class(:vertex)
|
366
|
+
blueprints_graph.createKeyIndex name.to_s, index_class(:vertex)
|
350
367
|
elsif element_type(type) == :edge and features.supportsEdgeKeyIndex
|
351
|
-
blueprints_graph.createKeyIndex name, index_class(:edge)
|
368
|
+
blueprints_graph.createKeyIndex name.to_s, index_class(:edge)
|
352
369
|
end
|
353
370
|
end
|
354
371
|
end
|
data/lib/pacer/loader.rb
CHANGED
@@ -39,6 +39,7 @@ require 'pacer/wrappers/edge_wrapper'
|
|
39
39
|
require 'pacer/wrappers/index_wrapper'
|
40
40
|
require 'pacer/wrappers/wrapper_selector'
|
41
41
|
require 'pacer/wrappers/wrapping_pipe_function'
|
42
|
+
require 'pacer/wrappers/path_wrapping_pipe_function'
|
42
43
|
|
43
44
|
require 'pacer/route_builder'
|
44
45
|
require 'pacer/function_resolver'
|
@@ -48,6 +49,9 @@ require 'pacer/blueprints/tg'
|
|
48
49
|
require 'pacer/blueprints/ruby_graph'
|
49
50
|
require 'pacer/blueprints/multi_graph'
|
50
51
|
|
52
|
+
require 'pacer/blueprints/payload_elements'
|
53
|
+
|
54
|
+
require 'pacer/support/array'
|
51
55
|
require 'pacer/support/array_list'
|
52
56
|
require 'pacer/support/enumerable'
|
53
57
|
require 'pacer/support/proc'
|
@@ -78,12 +82,17 @@ require 'pacer/transform/stream_sort'
|
|
78
82
|
require 'pacer/transform/stream_uniq'
|
79
83
|
require 'pacer/transform/gather'
|
80
84
|
require 'pacer/transform/map'
|
85
|
+
require 'pacer/transform/flat_map'
|
86
|
+
require 'pacer/transform/make_pairs'
|
81
87
|
require 'pacer/transform/process'
|
82
88
|
require 'pacer/transform/join'
|
83
89
|
require 'pacer/transform/path'
|
90
|
+
require 'pacer/transform/path_tree'
|
91
|
+
require 'pacer/transform/wrapped_path'
|
84
92
|
require 'pacer/transform/scatter'
|
85
93
|
require 'pacer/transform/has_count_cap'
|
86
94
|
require 'pacer/transform/sort_section'
|
95
|
+
require 'pacer/transform/payload'
|
87
96
|
|
88
97
|
require 'pacer/side_effect/aggregate'
|
89
98
|
require 'pacer/side_effect/as'
|
@@ -2,17 +2,18 @@ module Pacer::Pipes
|
|
2
2
|
class BlockFilterPipe < AbstractPipe
|
3
3
|
field_reader :starts
|
4
4
|
|
5
|
-
attr_reader :block
|
5
|
+
attr_reader :block, :invert
|
6
6
|
|
7
7
|
def initialize(back, block, invert = false)
|
8
8
|
super()
|
9
|
+
@invert = invert
|
9
10
|
@block = Pacer::Wrappers::WrappingPipeFunction.new back, block
|
10
11
|
end
|
11
12
|
|
12
13
|
def processNextStart()
|
13
14
|
while raw_element = starts.next
|
14
15
|
ok = block.call raw_element
|
15
|
-
ok = !ok if
|
16
|
+
ok = !ok if invert
|
16
17
|
return raw_element if ok
|
17
18
|
end
|
18
19
|
raise EmptyPipe.instance
|
data/lib/pacer/pipe/loop_pipe.rb
CHANGED
@@ -12,17 +12,17 @@ module Pacer::Pipes
|
|
12
12
|
empty = ArrayList.new
|
13
13
|
@expando.setStarts empty.iterator
|
14
14
|
looping_pipe.setStarts(@expando)
|
15
|
-
|
15
|
+
if control_block.arity < 0 or control_block.arity > 2
|
16
16
|
@yield_paths = true
|
17
17
|
looping_pipe.enablePath true
|
18
|
-
|
18
|
+
end
|
19
19
|
@looping_pipe = looping_pipe
|
20
20
|
end
|
21
21
|
|
22
22
|
def next
|
23
23
|
super
|
24
24
|
ensure
|
25
|
-
@path =
|
25
|
+
@path = next_path
|
26
26
|
end
|
27
27
|
|
28
28
|
def setStarts(starts)
|
@@ -30,9 +30,15 @@ module Pacer::Pipes
|
|
30
30
|
enablePath true if yield_paths
|
31
31
|
end
|
32
32
|
|
33
|
+
def enablePath(b)
|
34
|
+
super
|
35
|
+
looping_pipe.enablePath true if b and not yield_paths
|
36
|
+
end
|
37
|
+
|
33
38
|
protected
|
34
39
|
|
35
40
|
attr_reader :wrapper, :control_block, :expando, :looping_pipe, :graph, :yield_paths
|
41
|
+
attr_accessor :next_path
|
36
42
|
|
37
43
|
def processNextStart
|
38
44
|
while true
|
@@ -41,32 +47,32 @@ module Pacer::Pipes
|
|
41
47
|
if has_next
|
42
48
|
element = looping_pipe.next
|
43
49
|
depth = (expando.metadata || 0) + 1
|
44
|
-
|
50
|
+
self.next_path = looping_pipe.getCurrentPath if pathEnabled
|
45
51
|
else
|
46
52
|
element = starts.next
|
47
|
-
if pathEnabled
|
48
|
-
@next_path = starts.getCurrentPath
|
49
|
-
else
|
50
|
-
@next_path = ArrayList.new
|
51
|
-
@next_path.add element
|
52
|
-
end
|
53
|
+
self.next_path = starts.getCurrentPath if pathEnabled
|
53
54
|
depth = 0
|
54
55
|
end
|
55
56
|
wrapped = wrapper.new(graph, element)
|
56
|
-
|
57
|
-
|
57
|
+
if pathEnabled
|
58
|
+
path = next_path.map do |e|
|
59
|
+
wrapper.new graph, e
|
60
|
+
end
|
61
|
+
control = control_block.call wrapped, depth, path
|
62
|
+
else
|
63
|
+
control = control_block.call wrapped, depth
|
58
64
|
end
|
59
|
-
case
|
65
|
+
case control
|
60
66
|
when :loop
|
61
|
-
expando.add element, depth,
|
67
|
+
expando.add element, depth, next_path
|
62
68
|
when :emit
|
63
69
|
return element
|
64
70
|
when :emit_and_loop, :loop_and_emit
|
65
|
-
expando.add element, depth,
|
71
|
+
expando.add element, depth, next_path
|
66
72
|
return element
|
67
|
-
when false, nil
|
73
|
+
when false, nil, :discard
|
68
74
|
else
|
69
|
-
expando.add element, depth,
|
75
|
+
expando.add element, depth, next_path
|
70
76
|
return element
|
71
77
|
end
|
72
78
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Pacer::Pipes
|
2
|
+
class MultiPipe < RubyPipe
|
3
|
+
import com.tinkerpop.pipes.util.iterators.MultiIterator
|
4
|
+
import com.tinkerpop.pipes.Pipe
|
5
|
+
|
6
|
+
attr_reader :pipes
|
7
|
+
|
8
|
+
def initialize(enums)
|
9
|
+
super()
|
10
|
+
@pipes = enums.map do |e|
|
11
|
+
if e.is_a? Pipe
|
12
|
+
e
|
13
|
+
else
|
14
|
+
e.to_iterable
|
15
|
+
end
|
16
|
+
end
|
17
|
+
setStarts MultiIterator.new(*pipes)
|
18
|
+
end
|
19
|
+
|
20
|
+
def +(enum)
|
21
|
+
MultiPipe.new(pipes + [enum])
|
22
|
+
end
|
23
|
+
|
24
|
+
def -(enum)
|
25
|
+
MultiPipe.new(pipes - [enum])
|
26
|
+
end
|
27
|
+
|
28
|
+
def getCurrentPath
|
29
|
+
starts.getCurrentPath
|
30
|
+
end
|
31
|
+
|
32
|
+
def processNextStart
|
33
|
+
starts.next
|
34
|
+
end
|
35
|
+
|
36
|
+
def inspect
|
37
|
+
"#<MultiPipe #{ pipes.count } sources>"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Pacer
|
2
|
+
module Pipes
|
3
|
+
class NakedPipe < RubyPipe
|
4
|
+
def getCurrentPath
|
5
|
+
starts.getCurrentPath
|
6
|
+
end
|
7
|
+
|
8
|
+
def processNextStart
|
9
|
+
e = starts.next
|
10
|
+
e = e.element if e.respond_to? :element
|
11
|
+
if e.respond_to? :raw_vertex
|
12
|
+
e.raw_vertex
|
13
|
+
elsif e.respond_to? :raw_edge
|
14
|
+
e.raw_edge
|
15
|
+
else
|
16
|
+
e
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/pacer/pipes.rb
CHANGED
@@ -5,7 +5,6 @@ module Pacer
|
|
5
5
|
import com.tinkerpop.pipes.AbstractPipe
|
6
6
|
import com.tinkerpop.pipes.transform.IdentityPipe
|
7
7
|
import com.tinkerpop.pipes.util.Pipeline
|
8
|
-
import com.tinkerpop.pipes.util.iterators.MultiIterator
|
9
8
|
import com.tinkerpop.pipes.util.PipeHelper
|
10
9
|
|
11
10
|
import com.tinkerpop.pipes.filter.RandomFilterPipe
|
@@ -37,6 +36,7 @@ require 'pacer/pipe/vertices_pipe'
|
|
37
36
|
require 'pacer/pipe/edges_pipe'
|
38
37
|
|
39
38
|
require 'pacer/pipe/never_pipe'
|
39
|
+
require 'pacer/pipe/multi_pipe'
|
40
40
|
require 'pacer/pipe/block_filter_pipe'
|
41
41
|
require 'pacer/pipe/collection_filter_pipe'
|
42
42
|
require 'pacer/pipe/enumerable_pipe'
|
@@ -64,3 +64,4 @@ require 'pacer/pipe/cross_product_transform_pipe'
|
|
64
64
|
require 'pacer/pipe/wrapping_pipe'
|
65
65
|
require 'pacer/pipe/path_wrapping_pipe'
|
66
66
|
require 'pacer/pipe/unwrapping_pipe'
|
67
|
+
require 'pacer/pipe/naked_pipe'
|
@@ -39,6 +39,19 @@ module Pacer::Routes
|
|
39
39
|
end
|
40
40
|
result
|
41
41
|
end
|
42
|
+
alias frequencies group_count
|
43
|
+
|
44
|
+
def frequency_groups(*props)
|
45
|
+
result = Hash.new { |h, k| h[k] = [] }
|
46
|
+
group_count(*props).each { |k, v| result[v] << k }
|
47
|
+
result
|
48
|
+
end
|
49
|
+
|
50
|
+
def frequency_counts(*props)
|
51
|
+
result = Hash.new 0
|
52
|
+
group_count(*props).each { |k, v| result[v] += 1 }
|
53
|
+
result
|
54
|
+
end
|
42
55
|
|
43
56
|
def most_frequent(range = 0, include_counts = false)
|
44
57
|
if include_counts
|
@@ -104,6 +117,8 @@ module Pacer::Routes
|
|
104
117
|
'Obj'
|
105
118
|
when :mixed
|
106
119
|
'Elem'
|
120
|
+
else
|
121
|
+
element_type.to_s.capitalize
|
107
122
|
end
|
108
123
|
s = "#{s}-#{function.name.split('::').last.sub(/Filter|Route$/, '')}" if function
|
109
124
|
s = "#{s} #{ @info }" if @info
|