pacer 0.9.1.1-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.autotest +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,22 @@
|
|
|
1
|
+
class NativeException
|
|
2
|
+
def unravel
|
|
3
|
+
e = self
|
|
4
|
+
while e and e.respond_to? :cause
|
|
5
|
+
puts '--------------------'
|
|
6
|
+
puts e.class.to_s
|
|
7
|
+
puts e.message
|
|
8
|
+
pp e.backtrace.to_a
|
|
9
|
+
e = e.cause
|
|
10
|
+
end
|
|
11
|
+
puts '======================'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def root_cause
|
|
15
|
+
rc = e = self
|
|
16
|
+
while e and e.respond_to? :cause
|
|
17
|
+
rc = e
|
|
18
|
+
e = e.cause
|
|
19
|
+
end
|
|
20
|
+
rc
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class Proc
|
|
2
|
+
def to_route(opts = {})
|
|
3
|
+
based_on = opts[:based_on]
|
|
4
|
+
if opts[:unwrap] or based_on and based_on.extensions and based_on.graph
|
|
5
|
+
source = proc { self.call.map { |e| e.element } }
|
|
6
|
+
else
|
|
7
|
+
source = self
|
|
8
|
+
end
|
|
9
|
+
if based_on
|
|
10
|
+
Pacer::Route.new(:source => source, :element_type => :mixed, :graph => based_on.graph, :extensions => based_on.extensions, :info => based_on.info)
|
|
11
|
+
else
|
|
12
|
+
graph = opts[:graph] if opts[:graph]
|
|
13
|
+
Pacer::Route.new(:source => source, :element_type => (opts[:element_type] || :object), :graph => graph, :extensions => opts[:extensions], :info => opts[:info])
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
module Pacer
|
|
2
|
+
module Support
|
|
3
|
+
end
|
|
4
|
+
end
|
|
5
|
+
require 'pacer/support/iterator_mixins'
|
|
6
|
+
require 'pacer/support/array_list'
|
|
7
|
+
require 'pacer/support/enumerable'
|
|
8
|
+
require 'pacer/support/proc'
|
|
9
|
+
require 'pacer/support/hash'
|
|
10
|
+
require 'pacer/support/native_exception'
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
module Pacer
|
|
2
|
+
module Core::SideEffect
|
|
3
|
+
def cap
|
|
4
|
+
back.chain_route :transform => :cap, :with => self, :element_type => :object
|
|
5
|
+
end
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
module Transform
|
|
9
|
+
module Cap
|
|
10
|
+
import com.tinkerpop.pipes.transform.SideEffectCapPipe
|
|
11
|
+
|
|
12
|
+
def with=(route)
|
|
13
|
+
@side_effect = route
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
protected
|
|
17
|
+
|
|
18
|
+
def pipe_source
|
|
19
|
+
s, e = super
|
|
20
|
+
if not s and not e
|
|
21
|
+
s = e = Pacer::Pipes::IdentityPipe.new
|
|
22
|
+
end
|
|
23
|
+
[s, e]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def side_effect_pipe(end_pipe)
|
|
27
|
+
old_back = @side_effect.back
|
|
28
|
+
begin
|
|
29
|
+
empty = Pacer::Route.new :filter => :empty, :back => self
|
|
30
|
+
@side_effect.back = empty
|
|
31
|
+
_, side_effect_pipe = @side_effect.send :build_pipeline
|
|
32
|
+
side_effect_pipe.setStarts end_pipe if end_pipe
|
|
33
|
+
side_effect_pipe
|
|
34
|
+
ensure
|
|
35
|
+
@side_effect.back = old_back
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def attach_pipe(end_pipe)
|
|
40
|
+
pipe = SideEffectCapPipe.new side_effect_pipe(end_pipe)
|
|
41
|
+
pipe.setStarts end_pipe if end_pipe
|
|
42
|
+
pipe
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def inspect_string
|
|
46
|
+
"#{ inspect_class_name }(#{ @side_effect.send(:inspect_string) })"
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Pacer
|
|
2
|
+
module Routes
|
|
3
|
+
module RouteOperations
|
|
4
|
+
def has_count_route(opts = {})
|
|
5
|
+
chain_route({ :transform => :has_count_cap }.merge(opts))
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def has_count?(opts = {})
|
|
9
|
+
has_count_route(opts).first
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
module Transform
|
|
15
|
+
module HasCountCap
|
|
16
|
+
import com.tinkerpop.pipes.transform.HasCountPipe
|
|
17
|
+
|
|
18
|
+
attr_accessor :min, :max
|
|
19
|
+
|
|
20
|
+
protected
|
|
21
|
+
|
|
22
|
+
def attach_pipe(end_pipe)
|
|
23
|
+
pipe = HasCountPipe.new(min || -1, max || -1)
|
|
24
|
+
pipe.setStarts end_pipe if end_pipe
|
|
25
|
+
pipe
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def inspect_string
|
|
29
|
+
if min and max
|
|
30
|
+
"HasCount(#{ min }..#{max})"
|
|
31
|
+
elsif min
|
|
32
|
+
"HasCount(>= #{ min })"
|
|
33
|
+
elsif max
|
|
34
|
+
"HasCount(<= #{ max })"
|
|
35
|
+
else
|
|
36
|
+
"HasCount(...any...)"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
module Pacer
|
|
2
|
+
module Routes
|
|
3
|
+
module RouteOperations
|
|
4
|
+
def join(name = nil, options = {}, &block)
|
|
5
|
+
args = {
|
|
6
|
+
:transform => :join,
|
|
7
|
+
element_type: :vertex,
|
|
8
|
+
graph: options.fetch(:multi_graph, Pacer::MultiGraph.new),
|
|
9
|
+
from_graph: graph
|
|
10
|
+
}
|
|
11
|
+
args[:multi_graph] = options[:multi_graph] if options[:multi_graph]
|
|
12
|
+
route = chain_route(args)
|
|
13
|
+
route = route.key { |v| v } unless name == :key
|
|
14
|
+
if block and name == :key
|
|
15
|
+
route.key &block
|
|
16
|
+
elsif block
|
|
17
|
+
route.join(name || :values, &block)
|
|
18
|
+
else
|
|
19
|
+
route
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
module Transform
|
|
27
|
+
module Join
|
|
28
|
+
class CombinePipe < Pacer::Pipes::RubyPipe
|
|
29
|
+
import com.tinkerpop.pipes.sideeffect.SideEffectPipe
|
|
30
|
+
import java.util.ArrayList
|
|
31
|
+
import java.util.LinkedList
|
|
32
|
+
|
|
33
|
+
include SideEffectPipe rescue nil # may raise exception on reload.
|
|
34
|
+
|
|
35
|
+
attr_accessor :multi_graph, :current_keys, :current_values, :join_on
|
|
36
|
+
attr_reader :key_expando, :key_end, :values_pipes, :from_graph
|
|
37
|
+
|
|
38
|
+
def initialize(from_graph, multi_graph)
|
|
39
|
+
super()
|
|
40
|
+
@from_graph = from_graph
|
|
41
|
+
@multi_graph = multi_graph || Pacer::MultiGraph.new
|
|
42
|
+
@values_pipes = []
|
|
43
|
+
@current_keys = []
|
|
44
|
+
@current_values = []
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def setKeyPipe(from_pipe, to_pipe)
|
|
48
|
+
@key_expando, @key_end = prepare_aggregate_pipe(from_pipe, to_pipe)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def addValuesPipe(name, from_pipe, to_pipe)
|
|
52
|
+
values_pipes << [name, *prepare_aggregate_pipe(from_pipe, to_pipe)]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def getSideEffect
|
|
56
|
+
multi_graph
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
protected
|
|
60
|
+
|
|
61
|
+
def processNextStart
|
|
62
|
+
while true
|
|
63
|
+
if current_keys.empty?
|
|
64
|
+
element = starts.next
|
|
65
|
+
element.graph = from_graph if element.respond_to? :graph
|
|
66
|
+
self.current_keys = get_keys(element)
|
|
67
|
+
self.current_values = get_values(element) unless current_keys.empty?
|
|
68
|
+
else
|
|
69
|
+
key = current_keys.removeFirst
|
|
70
|
+
if key
|
|
71
|
+
combined = multi_graph.send(:getVertex, key) || multi_graph.send(:addVertex, key)
|
|
72
|
+
else
|
|
73
|
+
combined = multi_graph.send(:addVertex, nil)
|
|
74
|
+
end
|
|
75
|
+
combined.join_on join_on if join_on
|
|
76
|
+
combined[:key] = key
|
|
77
|
+
current_values.each do |key, values|
|
|
78
|
+
combined.append_property_array key, values
|
|
79
|
+
end
|
|
80
|
+
return combined
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
rescue NativeException => e
|
|
84
|
+
if e.cause.getClass == Pacer::NoSuchElementException.getClass
|
|
85
|
+
raise e.cause
|
|
86
|
+
else
|
|
87
|
+
raise e
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def get_keys(element)
|
|
92
|
+
array = LinkedList.new
|
|
93
|
+
if key_expando
|
|
94
|
+
array.addAll next_results(key_expando, key_end, element)
|
|
95
|
+
else
|
|
96
|
+
array.add nil
|
|
97
|
+
end
|
|
98
|
+
array
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def get_values(element)
|
|
102
|
+
values_pipes.map do |name, expando, to_pipe|
|
|
103
|
+
[name, next_results(expando, to_pipe, element)]
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# doesn't need to be spun out because it's a capped aggregator
|
|
108
|
+
def next_results(expando, pipe, element)
|
|
109
|
+
pipe.reset
|
|
110
|
+
expando.add element, ArrayList.new, nil
|
|
111
|
+
array = pipe.next
|
|
112
|
+
array.each { |element| element.graph = from_graph if element.respond_to? :graph }
|
|
113
|
+
array
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def prepare_aggregate_pipe(from_pipe, to_pipe)
|
|
117
|
+
expando = Pacer::Pipes::ExpandablePipe.new
|
|
118
|
+
expando.setStarts ArrayList.new.iterator
|
|
119
|
+
from_pipe.setStarts(expando)
|
|
120
|
+
agg_pipe = com.tinkerpop.pipes.sideeffect.AggregatePipe.new LinkedList.new
|
|
121
|
+
cap_pipe = com.tinkerpop.pipes.transform.SideEffectCapPipe.new agg_pipe
|
|
122
|
+
agg_pipe.setStarts to_pipe
|
|
123
|
+
cap_pipe.setStarts to_pipe
|
|
124
|
+
[expando, cap_pipe]
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
include Pacer::Core::SideEffect
|
|
129
|
+
|
|
130
|
+
attr_accessor :existing_multi_graph, :key_route, :values_routes, :from_graph
|
|
131
|
+
attr_writer :join_on
|
|
132
|
+
|
|
133
|
+
def key(&block)
|
|
134
|
+
self.key_route = Pacer::Route.block_branch(self, block)
|
|
135
|
+
self
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def join(name = nil, &block)
|
|
139
|
+
self.key_route = nil if name == :key
|
|
140
|
+
if block
|
|
141
|
+
values_routes << [(name || :values), Pacer::Route.block_branch(self, block)]
|
|
142
|
+
else
|
|
143
|
+
values_routes << [(name || :values), Pacer::Route.block_branch(self, proc { |v| v })]
|
|
144
|
+
end
|
|
145
|
+
self
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def join_on(*keys)
|
|
149
|
+
@join_on = keys
|
|
150
|
+
self
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def multigraph
|
|
154
|
+
cap.first
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
protected
|
|
158
|
+
|
|
159
|
+
def after_initialize
|
|
160
|
+
@values_routes = []
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def attach_pipe(end_pipe)
|
|
164
|
+
pipe = CombinePipe.new(from_graph, existing_multi_graph)
|
|
165
|
+
self.graph = pipe.multi_graph
|
|
166
|
+
pipe.setKeyPipe *key_route.send(:build_pipeline) if key_route
|
|
167
|
+
pipe.join_on = @join_on
|
|
168
|
+
values_routes.each do |name, route|
|
|
169
|
+
pipe.addValuesPipe name, *route.send(:build_pipeline)
|
|
170
|
+
end
|
|
171
|
+
pipe.setStarts end_pipe if end_pipe
|
|
172
|
+
pipe
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def inspect_string
|
|
176
|
+
"#{ inspect_class_name }(#{ key_route.inspect }: #{ Hash[values_routes].inspect })"
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Pacer
|
|
2
|
+
module Routes
|
|
3
|
+
module RouteOperations
|
|
4
|
+
def map(opts = {}, &block)
|
|
5
|
+
chain_route({:transform => :map, :block => block, :element_type => :object}.merge(opts))
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
module Transform
|
|
11
|
+
module Map
|
|
12
|
+
attr_accessor :block
|
|
13
|
+
|
|
14
|
+
protected
|
|
15
|
+
|
|
16
|
+
def attach_pipe(end_pipe)
|
|
17
|
+
pipe = Pacer::Pipes::MapPipe.new(back, block)
|
|
18
|
+
pipe.setStarts end_pipe if end_pipe
|
|
19
|
+
pipe
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
module Pacer
|
|
2
|
+
module Core
|
|
3
|
+
module Route
|
|
4
|
+
def paths
|
|
5
|
+
chain_route :transform => :path, :element_type => :object
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
module Transform
|
|
11
|
+
module Path
|
|
12
|
+
import com.tinkerpop.pipes.transform.PathPipe
|
|
13
|
+
|
|
14
|
+
def transpose
|
|
15
|
+
collect { |arraylist| arraylist.to_a }.transpose
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def subgraph(target_graph = nil)
|
|
19
|
+
raise "Can't create a subgraph within itself." if target_graph == graph
|
|
20
|
+
target_graph ||= Pacer.tg
|
|
21
|
+
target_graph.vertex_name ||= graph.vertex_name
|
|
22
|
+
bulk_job(nil, target_graph) do |path|
|
|
23
|
+
path_route = path.to_route(:graph => graph, :element_type => :mixed)
|
|
24
|
+
path_route.v.each do |vertex|
|
|
25
|
+
vertex.clone_into target_graph
|
|
26
|
+
end
|
|
27
|
+
path_route.e.each do |edge|
|
|
28
|
+
edge.clone_into target_graph
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
target_graph
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
protected
|
|
35
|
+
|
|
36
|
+
def attach_pipe(end_pipe)
|
|
37
|
+
pipe = PathPipe.new
|
|
38
|
+
pipe.setStarts end_pipe if end_pipe
|
|
39
|
+
pipe
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def configure_iterator(iter)
|
|
43
|
+
if respond_to? :graph
|
|
44
|
+
iter.extend Pacer::Core::Route::IteratorPathMixin
|
|
45
|
+
iter.graph = graph
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Pacer
|
|
2
|
+
module Routes
|
|
3
|
+
module RouteOperations
|
|
4
|
+
def process(opts = {}, &block)
|
|
5
|
+
chain_route({:transform => :process, :block => block}.merge(opts))
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
module Transform
|
|
11
|
+
module Process
|
|
12
|
+
attr_accessor :block
|
|
13
|
+
|
|
14
|
+
protected
|
|
15
|
+
|
|
16
|
+
def attach_pipe(end_pipe)
|
|
17
|
+
pipe = Pacer::Pipes::ProcessPipe.new(back, block)
|
|
18
|
+
pipe.setStarts end_pipe if end_pipe
|
|
19
|
+
pipe
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Pacer
|
|
2
|
+
module Core
|
|
3
|
+
module Route
|
|
4
|
+
def scatter(args = {})
|
|
5
|
+
chain_route({transform: :scatter, element_type: :object}.merge(args))
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
module Transform
|
|
11
|
+
module Scatter
|
|
12
|
+
import com.tinkerpop.pipes.transform.ScatterPipe
|
|
13
|
+
|
|
14
|
+
protected
|
|
15
|
+
|
|
16
|
+
def attach_pipe(end_pipe)
|
|
17
|
+
pipe = ScatterPipe.new
|
|
18
|
+
pipe.setStarts end_pipe if end_pipe
|
|
19
|
+
pipe
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
module Pacer
|
|
2
|
+
module Routes
|
|
3
|
+
module RouteOperations
|
|
4
|
+
def sort_section(section = nil, &block)
|
|
5
|
+
chain_route transform: :sort_section, block: block, section: section
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
module Transform
|
|
11
|
+
module SortSection
|
|
12
|
+
class SortSectionPipe < Pacer::Pipes::RubyPipe
|
|
13
|
+
attr_reader :block_1, :block_2, :to_sort, :to_emit, :section
|
|
14
|
+
|
|
15
|
+
def initialize(section, block)
|
|
16
|
+
super()
|
|
17
|
+
@to_emit = []
|
|
18
|
+
@section = section
|
|
19
|
+
@to_sort = []
|
|
20
|
+
if section
|
|
21
|
+
section.visitor = self
|
|
22
|
+
else
|
|
23
|
+
on_element nil
|
|
24
|
+
end
|
|
25
|
+
if block
|
|
26
|
+
if block.arity == 1
|
|
27
|
+
@block_1 = block
|
|
28
|
+
section.use_on_element = false
|
|
29
|
+
elsif block.arity == 2 or block.arity < 0
|
|
30
|
+
@block_2 = block
|
|
31
|
+
end
|
|
32
|
+
else
|
|
33
|
+
section.use_on_element = false
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def processNextStart
|
|
38
|
+
while to_emit.empty?
|
|
39
|
+
element = @starts.next
|
|
40
|
+
to_sort << element
|
|
41
|
+
end
|
|
42
|
+
to_emit.shift
|
|
43
|
+
rescue NativeException => e
|
|
44
|
+
if e.cause.getClass == Pacer::NoSuchElementException.getClass
|
|
45
|
+
if to_emit.empty?
|
|
46
|
+
raise e.cause
|
|
47
|
+
else
|
|
48
|
+
after_element
|
|
49
|
+
retry
|
|
50
|
+
end
|
|
51
|
+
else
|
|
52
|
+
raise e
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def on_element(element)
|
|
57
|
+
@section_element = element
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def after_element
|
|
61
|
+
if to_sort.any?
|
|
62
|
+
if block_1
|
|
63
|
+
sorted = to_sort.sort_by do |element|
|
|
64
|
+
block_1.call element
|
|
65
|
+
end
|
|
66
|
+
elsif block_2
|
|
67
|
+
sorted = to_sort.sort_by do |element|
|
|
68
|
+
block_2.call element, @section_element
|
|
69
|
+
end
|
|
70
|
+
else
|
|
71
|
+
sorted = to_sort.sort
|
|
72
|
+
end
|
|
73
|
+
to_emit.concat sorted
|
|
74
|
+
@to_sort = []
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
attr_accessor :block
|
|
80
|
+
attr_reader :section_name, :section_route
|
|
81
|
+
|
|
82
|
+
def section=(section)
|
|
83
|
+
if section.is_a? Symbol
|
|
84
|
+
@section_name = section
|
|
85
|
+
@section_route = @back.get_section_route(section)
|
|
86
|
+
elsif section.is_a? Pacer::Route and section.respond_to? :section_name
|
|
87
|
+
@section_name = section.section_name
|
|
88
|
+
@section_route = section
|
|
89
|
+
else
|
|
90
|
+
raise ArgumentError, "Unknown section #{ section }. Provide either a name or a route created with the #section methed."
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
protected
|
|
95
|
+
|
|
96
|
+
def attach_pipe(end_pipe)
|
|
97
|
+
pipe = SortSectionPipe.new(@section_route.send(:section_visitor), block)
|
|
98
|
+
pipe.setStarts end_pipe if end_pipe
|
|
99
|
+
pipe
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Pacer
|
|
2
|
+
module Routes::RouteOperations
|
|
3
|
+
def stream_sort(buffer = 1000, silo = 100)
|
|
4
|
+
chain_route :transform => :stream_sort, :buffer => buffer, :silo => silo
|
|
5
|
+
end
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
module Transform
|
|
9
|
+
module StreamSort
|
|
10
|
+
attr_accessor :buffer, :silo
|
|
11
|
+
|
|
12
|
+
protected
|
|
13
|
+
|
|
14
|
+
def attach_pipe(end_pipe)
|
|
15
|
+
pipe = Pacer::Pipes::StreamSortPipe.new buffer, silo
|
|
16
|
+
pipe.setStarts end_pipe if end_pipe
|
|
17
|
+
pipe
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Pacer
|
|
2
|
+
module Routes::RouteOperations
|
|
3
|
+
def stream_uniq(buffer = 1000)
|
|
4
|
+
chain_route :transform => :stream_uniq, :buffer => buffer
|
|
5
|
+
end
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
module Transform
|
|
9
|
+
module StreamUniq
|
|
10
|
+
attr_accessor :buffer
|
|
11
|
+
|
|
12
|
+
protected
|
|
13
|
+
|
|
14
|
+
def attach_pipe(end_pipe)
|
|
15
|
+
pipe = Pacer::Pipes::StreamUniqPipe.new buffer
|
|
16
|
+
pipe.setStarts end_pipe if end_pipe
|
|
17
|
+
pipe
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Pacer
|
|
2
|
+
module Transform
|
|
3
|
+
end
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
require 'pacer/transform/cap'
|
|
7
|
+
require 'pacer/transform/stream_sort'
|
|
8
|
+
require 'pacer/transform/stream_uniq'
|
|
9
|
+
require 'pacer/transform/gather'
|
|
10
|
+
require 'pacer/transform/map'
|
|
11
|
+
require 'pacer/transform/process'
|
|
12
|
+
require 'pacer/transform/join'
|
|
13
|
+
require 'pacer/transform/path'
|
|
14
|
+
require 'pacer/transform/scatter'
|
|
15
|
+
require 'pacer/transform/has_count_cap'
|
|
16
|
+
require 'pacer/transform/sort_section'
|