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.
Files changed (152) hide show
  1. data/.autotest +4 -1
  2. data/.gitignore +4 -0
  3. data/.rspec +1 -1
  4. data/Gemfile-dev +33 -0
  5. data/Gemfile-release +4 -0
  6. data/README.md +27 -9
  7. data/Rakefile +26 -8
  8. data/bin/autotest +1 -1
  9. data/lib/pacer/blueprints/multi_graph.rb +7 -19
  10. data/lib/pacer/blueprints/ruby_graph.rb +77 -52
  11. data/lib/pacer/blueprints/tg.rb +6 -93
  12. data/lib/pacer/blueprints.rb +0 -1
  13. data/lib/pacer/core/graph/edges_route.rb +10 -12
  14. data/lib/pacer/core/graph/element_route.rb +14 -21
  15. data/lib/pacer/core/graph/graph_index_route.rb +12 -8
  16. data/lib/pacer/core/graph/graph_route.rb +2 -5
  17. data/lib/pacer/core/graph/mixed_route.rb +3 -5
  18. data/lib/pacer/core/graph/vertices_route.rb +26 -27
  19. data/lib/pacer/core/route.rb +35 -66
  20. data/lib/pacer/exceptions.rb +13 -6
  21. data/lib/pacer/extensions/block_filter_element.rb +0 -5
  22. data/lib/pacer/filter/collection_filter.rb +9 -2
  23. data/lib/pacer/filter/empty_filter.rb +12 -3
  24. data/lib/pacer/filter/future_filter.rb +5 -5
  25. data/lib/pacer/filter/loop_filter.rb +7 -13
  26. data/lib/pacer/filter/object_filter.rb +10 -16
  27. data/lib/pacer/filter/property_filter/filters.rb +134 -93
  28. data/lib/pacer/filter/property_filter.rb +22 -19
  29. data/lib/pacer/filter/where_filter/node_visitor.rb +47 -26
  30. data/lib/pacer/filter/where_filter.rb +24 -3
  31. data/lib/pacer/function_resolver.rb +7 -2
  32. data/lib/pacer/graph/graph_ml.rb +39 -0
  33. data/lib/pacer/graph/graph_transactions_mixin.rb +107 -175
  34. data/lib/pacer/graph/pacer_graph.rb +438 -0
  35. data/lib/pacer/graph/simple_encoder.rb +20 -0
  36. data/lib/pacer/graph/yaml_encoder.rb +81 -0
  37. data/lib/pacer/graph.rb +8 -10
  38. data/lib/pacer/pipe/blackbox_pipeline.rb +11 -4
  39. data/lib/pacer/pipe/block_filter_pipe.rb +5 -22
  40. data/lib/pacer/pipe/cross_product_transform_pipe.rb +5 -7
  41. data/lib/pacer/pipe/edges_pipe.rb +22 -0
  42. data/lib/pacer/pipe/enumerable_pipe.rb +3 -9
  43. data/lib/pacer/pipe/expandable_pipe.rb +2 -14
  44. data/lib/pacer/pipe/id_collection_filter_pipe.rb +2 -8
  45. data/lib/pacer/pipe/is_empty_pipe.rb +5 -12
  46. data/lib/pacer/pipe/is_unique_pipe.rb +3 -13
  47. data/lib/pacer/pipe/label_collection_filter_pipe.rb +1 -7
  48. data/lib/pacer/pipe/label_prefix_pipe.rb +0 -6
  49. data/lib/pacer/pipe/loop_pipe.rb +27 -25
  50. data/lib/pacer/pipe/never_pipe.rb +1 -1
  51. data/lib/pacer/pipe/path_wrapping_pipe.rb +40 -0
  52. data/lib/pacer/pipe/process_pipe.rb +2 -20
  53. data/lib/pacer/pipe/property_comparison_pipe.rb +0 -6
  54. data/lib/pacer/pipe/ruby_pipe.rb +10 -3
  55. data/lib/pacer/pipe/simple_visitor_pipe.rb +12 -11
  56. data/lib/pacer/pipe/stream_sort_pipe.rb +1 -7
  57. data/lib/pacer/pipe/stream_uniq_pipe.rb +0 -6
  58. data/lib/pacer/pipe/type_filter_pipe.rb +1 -7
  59. data/lib/pacer/pipe/unary_transform_pipe.rb +6 -8
  60. data/lib/pacer/pipe/unwrapping_pipe.rb +13 -0
  61. data/lib/pacer/pipe/vertices_pipe.rb +22 -0
  62. data/lib/pacer/pipe/visitor_pipe.rb +3 -7
  63. data/lib/pacer/pipe/wrapping_pipe.rb +37 -0
  64. data/lib/pacer/pipes.rb +17 -12
  65. data/lib/pacer/route/mixin/bulk_operations.rb +8 -9
  66. data/lib/pacer/route/mixin/route_operations.rb +17 -11
  67. data/lib/pacer/route/mixins.rb +0 -1
  68. data/lib/pacer/route.rb +198 -121
  69. data/lib/pacer/side_effect/aggregate.rb +22 -2
  70. data/lib/pacer/side_effect/as.rb +73 -0
  71. data/lib/pacer/side_effect/group_count.rb +0 -3
  72. data/lib/pacer/side_effect/is_unique.rb +7 -6
  73. data/lib/pacer/side_effect.rb +1 -1
  74. data/lib/pacer/support/enumerable.rb +14 -12
  75. data/lib/pacer/support/nil_class.rb +5 -0
  76. data/lib/pacer/support/proc.rb +2 -2
  77. data/lib/pacer/support.rb +1 -1
  78. data/lib/pacer/transform/cap.rb +1 -1
  79. data/lib/pacer/transform/has_count_cap.rb +1 -1
  80. data/lib/pacer/transform/join.rb +20 -16
  81. data/lib/pacer/transform/map.rb +6 -2
  82. data/lib/pacer/transform/path.rb +44 -20
  83. data/lib/pacer/transform/sort_section.rb +58 -51
  84. data/lib/pacer/utils/tsort.rb +7 -2
  85. data/lib/pacer/utils.rb +0 -1
  86. data/lib/pacer/version.rb +4 -3
  87. data/lib/pacer/visitors/section.rb +42 -0
  88. data/lib/pacer/visitors/visits_section.rb +32 -0
  89. data/lib/pacer/visitors.rb +7 -0
  90. data/lib/pacer/wrappers/edge_wrapper.rb +164 -11
  91. data/lib/pacer/wrappers/element_wrapper.rb +133 -8
  92. data/lib/pacer/wrappers/index_wrapper.rb +47 -0
  93. data/lib/pacer/wrappers/vertex_wrapper.rb +175 -12
  94. data/lib/pacer/wrappers/wrapper_selector.rb +40 -0
  95. data/lib/pacer/wrappers/wrapping_pipe_function.rb +90 -0
  96. data/lib/pacer/wrappers.rb +3 -1
  97. data/lib/pacer-1.0.0-standalone.jar +0 -0
  98. data/lib/pacer.rb +13 -47
  99. data/pacer.gemspec +0 -8
  100. data/pom.xml +10 -3
  101. data/spec/pacer/blueprints/dex_spec.rb +12 -26
  102. data/spec/pacer/blueprints/neo4j_spec.rb +14 -28
  103. data/spec/pacer/blueprints/tg_spec.rb +6 -54
  104. data/spec/pacer/core/graph/edges_route_spec.rb +1 -1
  105. data/spec/pacer/core/graph/element_route_spec.rb +2 -2
  106. data/spec/pacer/core/graph/graph_route_spec.rb +2 -2
  107. data/spec/pacer/core/graph/vertices_route_spec.rb +10 -3
  108. data/spec/pacer/core/route_spec.rb +35 -58
  109. data/spec/pacer/filter/empty_filter_spec.rb +5 -6
  110. data/spec/pacer/filter/future_filter_spec.rb +8 -8
  111. data/spec/pacer/filter/loop_filter_spec.rb +120 -6
  112. data/spec/pacer/filter/object_filter_spec.rb +15 -0
  113. data/spec/pacer/filter/property_filter/filters_spec.rb +169 -0
  114. data/spec/pacer/filter/property_filter_spec.rb +15 -12
  115. data/spec/pacer/filter/uniq_filter_spec.rb +1 -1
  116. data/spec/pacer/filter/where_filter_spec.rb +55 -7
  117. data/spec/pacer/graph/{graph_mixin_spec.rb → pacer_graph_spec.rb} +114 -185
  118. data/spec/pacer/route/mixin/base_spec.rb +36 -35
  119. data/spec/pacer/route/mixin/route_operations_spec.rb +4 -46
  120. data/spec/pacer/side_effect/as_spec.rb +34 -0
  121. data/spec/pacer/support/enumerable_spec.rb +6 -6
  122. data/spec/pacer/transform/join_spec.rb +7 -5
  123. data/spec/pacer/transform/map_spec.rb +55 -0
  124. data/spec/pacer/transform/path_spec.rb +30 -15
  125. data/spec/pacer/transform/process_spec.rb +42 -0
  126. data/spec/pacer/transform/sort_section_spec.rb +82 -0
  127. data/spec/pacer/wrapper/edge_wrapper_spec.rb +122 -2
  128. data/spec/pacer/wrapper/element_wrapper_spec.rb +289 -3
  129. data/spec/pacer/wrapper/vertex_wrapper_spec.rb +289 -2
  130. data/spec/spec_helper.rb +16 -7
  131. data/spec/support/graph_runner.rb +80 -29
  132. data/tags +1165 -0
  133. metadata +46 -107
  134. data/.rvmrc +0 -0
  135. data/lib/pacer/blueprints/extensions.rb +0 -77
  136. data/lib/pacer/graph/edge_mixin.rb +0 -127
  137. data/lib/pacer/graph/element_mixin.rb +0 -202
  138. data/lib/pacer/graph/graph_indices_mixin.rb +0 -93
  139. data/lib/pacer/graph/graph_mixin.rb +0 -361
  140. data/lib/pacer/graph/index_mixin.rb +0 -30
  141. data/lib/pacer/graph/vertex_mixin.rb +0 -119
  142. data/lib/pacer/pipe/map_pipe.rb +0 -36
  143. data/lib/pacer/pipe/variable_store_iterator_wrapper.rb +0 -26
  144. data/lib/pacer/route/mixin/variable_route_module.rb +0 -26
  145. data/lib/pacer/side_effect/section.rb +0 -25
  146. data/lib/pacer/support/iterator_mixins.rb +0 -110
  147. data/lib/pacer/wrappers/new_element.rb +0 -106
  148. data/lib/pacer-0.9.1.1-standalone.jar +0 -0
  149. data/spec/pacer/graph/edge_mixin_spec.rb +0 -116
  150. data/spec/pacer/graph/element_mixin_spec.rb +0 -297
  151. data/spec/pacer/graph/index_mixin_spec.rb +0 -0
  152. data/spec/pacer/graph/vertex_mixin_spec.rb +0 -192
data/lib/pacer/support.rb CHANGED
@@ -2,9 +2,9 @@ module Pacer
2
2
  module Support
3
3
  end
4
4
  end
5
- require 'pacer/support/iterator_mixins'
6
5
  require 'pacer/support/array_list'
7
6
  require 'pacer/support/enumerable'
8
7
  require 'pacer/support/proc'
9
8
  require 'pacer/support/hash'
10
9
  require 'pacer/support/native_exception'
10
+ require 'pacer/support/nil_class'
@@ -26,7 +26,7 @@ module Pacer
26
26
  def side_effect_pipe(end_pipe)
27
27
  old_back = @side_effect.back
28
28
  begin
29
- empty = Pacer::Route.new :filter => :empty, :back => self
29
+ empty = Pacer::Route.empty self
30
30
  @side_effect.back = empty
31
31
  _, side_effect_pipe = @side_effect.send :build_pipeline
32
32
  side_effect_pipe.setStarts end_pipe if end_pipe
@@ -2,7 +2,7 @@ module Pacer
2
2
  module Routes
3
3
  module RouteOperations
4
4
  def has_count_route(opts = {})
5
- chain_route({ :transform => :has_count_cap }.merge(opts))
5
+ chain_route({ :transform => :has_count_cap, element_type: :object }.merge(opts))
6
6
  end
7
7
 
8
8
  def has_count?(opts = {})
@@ -1,11 +1,15 @@
1
1
  module Pacer
2
2
  module Routes
3
3
  module RouteOperations
4
+ def key(&block)
5
+ join(:key, &block)
6
+ end
7
+
4
8
  def join(name = nil, options = {}, &block)
5
9
  args = {
6
10
  :transform => :join,
7
11
  element_type: :vertex,
8
- graph: options.fetch(:multi_graph, Pacer::MultiGraph.new),
12
+ graph: options.fetch(:multi_graph, Pacer::MultiGraph.blank),
9
13
  from_graph: graph
10
14
  }
11
15
  args[:multi_graph] = options[:multi_graph] if options[:multi_graph]
@@ -33,12 +37,13 @@ module Pacer
33
37
  include SideEffectPipe rescue nil # may raise exception on reload.
34
38
 
35
39
  attr_accessor :multi_graph, :current_keys, :current_values, :join_on
36
- attr_reader :key_expando, :key_end, :values_pipes, :from_graph
40
+ attr_reader :key_expando, :key_end, :values_pipes, :from_graph, :wrapper
37
41
 
38
42
  def initialize(from_graph, multi_graph)
39
43
  super()
40
44
  @from_graph = from_graph
41
- @multi_graph = multi_graph || Pacer::MultiGraph.new
45
+ @wrapper = Pacer::Wrappers::WrapperSelector.build
46
+ @multi_graph = multi_graph || Pacer::MultiGraph.blank
42
47
  @values_pipes = []
43
48
  @current_keys = []
44
49
  @current_values = []
@@ -61,31 +66,25 @@ module Pacer
61
66
  def processNextStart
62
67
  while true
63
68
  if current_keys.empty?
64
- element = starts.next
69
+ element = wrapper.new starts.next
65
70
  element.graph = from_graph if element.respond_to? :graph
66
71
  self.current_keys = get_keys(element)
67
72
  self.current_values = get_values(element) unless current_keys.empty?
68
73
  else
69
74
  key = current_keys.removeFirst
70
75
  if key
71
- combined = multi_graph.send(:getVertex, key) || multi_graph.send(:addVertex, key)
76
+ combined = multi_graph.vertex(key) || multi_graph.create_vertex(key)
72
77
  else
73
- combined = multi_graph.send(:addVertex, nil)
78
+ combined = multi_graph.create_vertex
74
79
  end
75
80
  combined.join_on join_on if join_on
76
81
  combined[:key] = key
77
82
  current_values.each do |key, values|
78
- combined.append_property_array key, values
83
+ combined.element.append_property_array key, values
79
84
  end
80
85
  return combined
81
86
  end
82
87
  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
88
  end
90
89
 
91
90
  def get_keys(element)
@@ -109,8 +108,13 @@ module Pacer
109
108
  pipe.reset
110
109
  expando.add element, ArrayList.new, nil
111
110
  array = pipe.next
112
- array.each { |element| element.graph = from_graph if element.respond_to? :graph }
113
- array
111
+ array.map do |element|
112
+ if element.is_a? Pacer::Element
113
+ element = wrapper.new element
114
+ element.graph = from_graph if element.respond_to? :graph
115
+ end
116
+ element
117
+ end
114
118
  end
115
119
 
116
120
  def prepare_aggregate_pipe(from_pipe, to_pipe)
@@ -178,4 +182,4 @@ module Pacer
178
182
  end
179
183
  end
180
184
  end
181
-
185
+
@@ -2,7 +2,7 @@ module Pacer
2
2
  module Routes
3
3
  module RouteOperations
4
4
  def map(opts = {}, &block)
5
- chain_route({:transform => :map, :block => block, :element_type => :object}.merge(opts))
5
+ chain_route({:transform => :map, :block => block, :element_type => :object, :extensions => []}.merge(opts))
6
6
  end
7
7
  end
8
8
  end
@@ -14,7 +14,11 @@ module Pacer
14
14
  protected
15
15
 
16
16
  def attach_pipe(end_pipe)
17
- pipe = Pacer::Pipes::MapPipe.new(back, block)
17
+ # Must wrap based on parent pipe because the element in the block has
18
+ # not yet been affected by any of this block's transforms.
19
+ pf = Pacer::Wrappers::WrappingPipeFunction.new back || source, block
20
+ pf = Pacer::Wrappers::UnwrappingPipeFunction.new pf
21
+ pipe = com.tinkerpop.pipes.transform.TransformFunctionPipe.new pf
18
22
  pipe.setStarts end_pipe if end_pipe
19
23
  pipe
20
24
  end
@@ -1,36 +1,57 @@
1
1
  module Pacer
2
2
  module Core
3
3
  module Route
4
- def paths
5
- chain_route :transform => :path, :element_type => :object
4
+ def paths(*exts)
5
+ route = chain_route :transform => :path, :element_type => :object
6
+ if exts.any?
7
+ exts = exts.map { |e| Array.wrap(e) if e }
8
+ route.map(modules: Pacer::Transform::Path::Methods) do |path|
9
+ path.zip(exts).map { |element, ext| ext ? element.add_extensions(ext) : element }
10
+ end
11
+ else
12
+ route
13
+ end
6
14
  end
7
15
  end
8
16
  end
9
17
 
10
18
  module Transform
11
19
  module Path
12
- import com.tinkerpop.pipes.transform.PathPipe
13
-
14
- def transpose
15
- collect { |arraylist| arraylist.to_a }.transpose
16
- end
20
+ module Methods
21
+ def transpose
22
+ collect { |arraylist| arraylist.to_a }.transpose
23
+ end
17
24
 
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
25
+ def subgraph(target_graph = nil, opts = {})
26
+ raise "Can't create a subgraph within itself." if target_graph == graph
27
+ target_graph ||= Pacer.tg
28
+ target_graph.vertex_name ||= graph.vertex_name
29
+ missing_edges = Set[]
30
+ bulk_job(nil, target_graph) do |path|
31
+ path.select { |e| e.is_a? Pacer::Vertex }.each do |vertex|
32
+ vertex.clone_into target_graph
33
+ end
34
+ path.select { |e| e.is_a? Pacer::Edge }.each do |edge|
35
+ unless edge.clone_into target_graph, ignore_missing_vertices: true
36
+ missing_edges << edge
37
+ end
38
+ end
26
39
  end
27
- path_route.e.each do |edge|
28
- edge.clone_into target_graph
40
+ if missing_edges.any?
41
+ missing_edges.to_route(graph: graph, element_type: :edge).bulk_job nil, target_graph do |edge|
42
+ edge.clone_into target_graph,
43
+ ignore_missing_vertices: opts[:ignore_missing_vertices],
44
+ show_missing_vertices: opts[:show_missing_vertices]
45
+ end
29
46
  end
47
+ target_graph
30
48
  end
31
- target_graph
32
49
  end
33
50
 
51
+ import com.tinkerpop.pipes.transform.PathPipe
52
+
53
+ include Methods
54
+
34
55
  protected
35
56
 
36
57
  def attach_pipe(end_pipe)
@@ -41,8 +62,11 @@ module Pacer
41
62
 
42
63
  def configure_iterator(iter)
43
64
  if respond_to? :graph
44
- iter.extend Pacer::Core::Route::IteratorPathMixin
45
- iter.graph = graph
65
+ pipe = Pacer::Pipes::PathWrappingPipe.new(graph)
66
+ pipe.setStarts iter
67
+ pipe
68
+ else
69
+ iter
46
70
  end
47
71
  end
48
72
  end
@@ -7,49 +7,77 @@ module Pacer
7
7
  end
8
8
  end
9
9
 
10
+
10
11
  module Transform
11
12
  module SortSection
13
+ # VisitsSection module provides:
14
+ # section=
15
+ # section_visitor
16
+ include Pacer::Visitors::VisitsSection
17
+
18
+ attr_accessor :block
19
+
20
+ protected
21
+
22
+ def attach_pipe(end_pipe)
23
+ pf = Pacer::Wrappers::WrappingPipeFunction.new self, block if block
24
+ pipe = SortSectionPipe.new(self, section_visitor, pf)
25
+ pipe.setStarts end_pipe if end_pipe
26
+ pipe
27
+ end
28
+
29
+
12
30
  class SortSectionPipe < Pacer::Pipes::RubyPipe
13
- attr_reader :block_1, :block_2, :to_sort, :to_emit, :section
31
+ attr_reader :pf_1, :pf_2, :to_sort, :to_emit, :section
32
+ attr_reader :getPathToHere
14
33
 
15
- def initialize(section, block)
34
+ def initialize(route, section, pipe_function)
16
35
  super()
17
36
  @to_emit = []
18
37
  @section = section
19
38
  @to_sort = []
39
+ @paths = []
20
40
  if section
21
41
  section.visitor = self
22
42
  else
23
43
  on_element nil
24
44
  end
25
- if block
26
- if block.arity == 1
27
- @block_1 = block
45
+ if pipe_function
46
+ if pipe_function.arity == 1
47
+ @pf_1 = pipe_function
28
48
  section.use_on_element = false
29
- elsif block.arity == 2 or block.arity < 0
30
- @block_2 = block
49
+ else
50
+ @pf_2 = pipe_function
31
51
  end
32
52
  else
33
53
  section.use_on_element = false
34
54
  end
35
55
  end
36
56
 
57
+ def setStarts(starts)
58
+ super
59
+ enablePath(true) if pf_2
60
+ end
61
+
37
62
  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
63
+ if pathEnabled
64
+ while to_emit.empty?
65
+ to_sort << [starts.next, starts.getCurrentPath]
50
66
  end
51
67
  else
52
- raise e
68
+ while to_emit.empty?
69
+ to_sort << [starts.next, nil]
70
+ end
71
+ end
72
+ raise EmptyPipe.instance if to_emit.empty?
73
+ element, @getPathToHere = to_emit.shift
74
+ element
75
+ rescue EmptyPipe, java.util.NoSuchElementException
76
+ if to_emit.empty?
77
+ raise EmptyPipe.instance
78
+ else
79
+ after_element
80
+ retry
53
81
  end
54
82
  end
55
83
 
@@ -59,45 +87,24 @@ module Pacer
59
87
 
60
88
  def after_element
61
89
  if to_sort.any?
62
- if block_1
63
- sorted = to_sort.sort_by do |element|
64
- block_1.call element
90
+ if pf_1
91
+ sorted = to_sort.sort_by do |element, path|
92
+ pf_1.call element
65
93
  end
66
- elsif block_2
67
- sorted = to_sort.sort_by do |element|
68
- block_2.call element, @section_element
94
+ elsif pf_2
95
+ sorted = to_sort.sort_by do |element, path|
96
+ pf_2.call_with_args element, @section_element, pf_2.wrap_path(path)
69
97
  end
70
98
  else
71
- sorted = to_sort.sort
99
+ sorted = to_sort.sort_by do |element, path|
100
+ element
101
+ end
72
102
  end
73
103
  to_emit.concat sorted
74
- @to_sort = []
104
+ @to_sort.clear
75
105
  end
76
106
  end
77
107
  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
108
  end
102
109
  end
103
110
  end
@@ -15,6 +15,11 @@ module Pacer
15
15
  # into a route.
16
16
  def dependencies(&block)
17
17
  anon_mod = Module.new
18
+ class << anon_mod
19
+ def inspect
20
+ '<TSort anon mixin module>'
21
+ end
22
+ end
18
23
  anon_mod.const_set :Route, TSort::Route
19
24
  anon_mod.const_set :Vertex, Module.new
20
25
  anon_mod::Vertex.const_set :DependenciesBlock, block
@@ -23,7 +28,7 @@ module Pacer
23
28
  target.const_set :DependenciesBlock, self::DependenciesBlock
24
29
  end
25
30
  end
26
- route = v(*(extensions - [TSort] + [anon_mod]))
31
+ route = v.add_extensions [TSort, anon_mod]
27
32
  route.tsort_anon_mod = anon_mod
28
33
  route
29
34
  end
@@ -54,7 +59,7 @@ module Pacer
54
59
 
55
60
  def tsort_dependencies(tsort_anon_mod = nil)
56
61
  if self.class.const_defined? :DependenciesBlock
57
- self.class::DependenciesBlock.call(self).add_extension(tsort_anon_mod)
62
+ self.class::DependenciesBlock.call(self).add_extensions([tsort_anon_mod])
58
63
  else
59
64
  self.in
60
65
  end
data/lib/pacer/utils.rb CHANGED
@@ -4,7 +4,6 @@ module Pacer
4
4
  autoload :GraphAnalysis, 'pacer/utils/graph_analysis'
5
5
  autoload :TSort, 'pacer/utils/tsort'
6
6
  autoload :Trie, 'pacer/utils/trie'
7
- import com.tinkerpop.blueprints.pgm.util.AutomaticIndexHelper
8
7
  end
9
8
  end
10
9
 
data/lib/pacer/version.rb CHANGED
@@ -1,13 +1,14 @@
1
1
  module Pacer
2
2
  unless const_defined? :VERSION
3
- VERSION = "0.9.1.1"
3
+ VERSION = "1.0.0"
4
4
 
5
5
  JAR = "pacer-#{ VERSION }-standalone.jar"
6
6
  JAR_PATH = "lib/#{ JAR }"
7
7
 
8
8
  START_TIME = Time.now
9
9
 
10
- BLUEPRINTS_VERSION = "1.0"
11
- PIPES_VERSION = "0.8"
10
+ BLUEPRINTS_VERSION = "2.1.0"
11
+ PIPES_VERSION = "2.1.0"
12
+ GREMLIN_VERSION = "2.1.0"
12
13
  end
13
14
  end
@@ -0,0 +1,42 @@
1
+ module Pacer
2
+ module Routes
3
+ module RouteOperations
4
+ def section(section_name = nil, visitor_target = nil)
5
+ chain_route visitor: :section, section_name: section_name, visitor_target: visitor_target
6
+ end
7
+ end
8
+ end
9
+
10
+ module Visitors
11
+ module Section
12
+ attr_accessor :section_name, :visitor_target
13
+
14
+ def will_visit!
15
+ @visitor_count = visitor_count + 1
16
+ end
17
+
18
+ def section_visitor
19
+ section_visitors.pop
20
+ end
21
+
22
+ protected
23
+
24
+ def visitor_count
25
+ @visitor_count = 0 unless defined? @visitor_count
26
+ @visitor_count
27
+ end
28
+
29
+ attr_reader :section_visitors
30
+
31
+ def attach_pipe(end_pipe)
32
+ pipe = end_pipe
33
+ @section_visitors = (1..visitor_count).map do
34
+ pipe = Pacer::Pipes::SimpleVisitorPipe.new Pacer::Wrappers::WrapperSelector.build(element_type, extensions), graph
35
+ pipe.setStarts end_pipe if end_pipe
36
+ end_pipe = pipe
37
+ end
38
+ pipe
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,32 @@
1
+ module Pacer
2
+ module Visitors
3
+ # This module is mixed in to the route that actually refers to this section.
4
+ module VisitsSection
5
+ attr_reader :section, :section_route
6
+
7
+ def section=(section)
8
+ if section.is_a? Symbol
9
+ @section = section
10
+ @section_route = @back.get_section_route(section)
11
+ elsif section.is_a? Pacer::Route and section.respond_to? :section_name
12
+ @section = section.section_name
13
+ @section_route = section
14
+ else
15
+ raise ArgumentError, "Unknown section #{ section }. Provide either a name or a route created with the #section methed."
16
+ end
17
+ @section_route.will_visit!
18
+ @section_route
19
+ end
20
+
21
+ protected
22
+
23
+ def section_visitor
24
+ section_route.section_visitor if section_route
25
+ end
26
+
27
+ def section_visitor_target
28
+ section_route.visitor_target if section_route
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,7 @@
1
+ module Pacer
2
+ module Visitors
3
+ end
4
+ end
5
+
6
+ require 'pacer/visitors/visits_section'
7
+ require 'pacer/visitors/section'