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
@@ -15,12 +15,6 @@ module Pacer::Pipes
15
15
 
16
16
  def next
17
17
  super
18
- rescue NativeException => e
19
- if e.cause.getClass == Pacer::NoSuchElementException.getClass
20
- raise e.cause
21
- else
22
- raise e
23
- end
24
18
  ensure
25
19
  @path = @next_path
26
20
  @metadata = @next_metadata
@@ -32,8 +26,8 @@ module Pacer::Pipes
32
26
  if @queue.isEmpty
33
27
  @next_metadata = nil
34
28
  r = @starts.next
35
- if @starts.respond_to? :getPath
36
- @next_path = @starts.getPath
29
+ if pathEnabled and @starts.respond_to? :getCurrentPath
30
+ @next_path = @starts.getCurrentPath
37
31
  else
38
32
  @next_path = java.util.ArrayList.new
39
33
  end
@@ -42,12 +36,6 @@ module Pacer::Pipes
42
36
  element, @next_metadata, @next_path = @queue.remove
43
37
  element
44
38
  end
45
- rescue NativeException => e
46
- if e.cause.getClass == Pacer::NoSuchElementException.getClass
47
- raise e.cause
48
- else
49
- raise e
50
- end
51
39
  end
52
40
 
53
41
  def getPathToHere
@@ -10,24 +10,18 @@ module Pacer::Pipes
10
10
  if @comparison == Pacer::Pipes::EQUAL
11
11
  while true
12
12
  element = @starts.next
13
- if element and @ids.include? element.element_id
13
+ if element and @ids.include? element.getId
14
14
  return element
15
15
  end
16
16
  end
17
17
  else
18
18
  while true
19
19
  element = @starts.next
20
- if element and not @ids.include? element.element_id
20
+ if element and not @ids.include? element.getId
21
21
  return element
22
22
  end
23
23
  end
24
24
  end
25
- rescue NativeException => e
26
- if e.cause.getClass == Pacer::NoSuchElementException.getClass
27
- raise e.cause
28
- else
29
- raise e
30
- end
31
25
  end
32
26
  end
33
27
  end
@@ -6,20 +6,13 @@ module Pacer::Pipes
6
6
  end
7
7
 
8
8
  def processNextStart
9
- raise Pacer::NoSuchElementException if @raise
10
- @starts.next
9
+ raise EmptyPipe.instance if @raise
10
+ starts.next
11
11
  @raise = true
12
- rescue NativeException => e
13
- if e.cause.getClass == NoSuchElementException.getClass
14
- # This is the only case where we return true.
15
- # The only time we get here is if the first call to next
16
- # has no results.
17
- true
18
- else
19
- raise e
20
- end
12
+ rescue EmptyPipe, java.util.NoSuchElementException
13
+ true
21
14
  else
22
- raise Pacer::NoSuchElementException
15
+ raise EmptyPipe.instance
23
16
  end
24
17
 
25
18
  def reset
@@ -2,7 +2,7 @@ module Pacer::Pipes
2
2
  class IsUniquePipe < RubyPipe
3
3
  import java.util.ArrayList
4
4
  import com.tinkerpop.pipes.sideeffect.SideEffectPipe
5
- import com.tinkerpop.pipes.util.ExpandableIterator
5
+ import com.tinkerpop.pipes.util.iterators.ExpandableIterator
6
6
  import com.tinkerpop.pipes.filter.DuplicateFilterPipe
7
7
 
8
8
  include SideEffectPipe
@@ -16,12 +16,6 @@ module Pacer::Pipes
16
16
  value = starts.next
17
17
  check_uniqueness value if @unique
18
18
  value
19
- rescue NativeException => e
20
- if e.cause.getClass == Pacer::NoSuchElementException.getClass
21
- raise e.cause
22
- else
23
- raise e
24
- end
25
19
  end
26
20
 
27
21
  def reset
@@ -42,12 +36,8 @@ module Pacer::Pipes
42
36
  def check_uniqueness(value)
43
37
  @expando.add value
44
38
  @unique_pipe.next
45
- rescue NativeException => e
46
- if e.cause.getClass == Pacer::NoSuchElementException.getClass
47
- @unique = false
48
- else
49
- raise e
50
- end
39
+ rescue EmptyPipe, java.util.NoSuchElementException
40
+ @unique = false
51
41
  end
52
42
 
53
43
  def prepare_state
@@ -8,13 +8,7 @@ module Pacer::Pipes
8
8
  def processNextStart
9
9
  while true
10
10
  edge = @starts.next
11
- return edge if edge and @labels.include? edge.label
12
- end
13
- rescue NativeException => e
14
- if e.cause.getClass == Pacer::NoSuchElementException.getClass
15
- raise e.cause
16
- else
17
- raise e
11
+ return edge if edge and @labels.include? edge.getLabel
18
12
  end
19
13
  end
20
14
  end
@@ -10,12 +10,6 @@ module Pacer::Pipes
10
10
  edge = @starts.next
11
11
  return edge if edge.label =~ @prefix
12
12
  end
13
- rescue NativeException => e
14
- if e.cause.getClass == Pacer::NoSuchElementException.getClass
15
- raise e.cause
16
- else
17
- raise e
18
- end
19
13
  end
20
14
  end
21
15
  end
@@ -4,73 +4,75 @@ module Pacer::Pipes
4
4
 
5
5
  def initialize(graph, looping_pipe, control_block)
6
6
  super()
7
+ @graph = graph
7
8
  @control_block = control_block
9
+ @wrapper = Pacer::Wrappers::WrapperSelector.build
8
10
 
9
11
  @expando = ExpandablePipe.new
10
12
  empty = ArrayList.new
11
13
  @expando.setStarts empty.iterator
12
14
  looping_pipe.setStarts(@expando)
15
+ #if control_block.arity < 0 and 1 < control_block.arity
16
+ @yield_paths = true
17
+ looping_pipe.enablePath true
18
+ #end
13
19
  @looping_pipe = looping_pipe
14
20
  end
15
21
 
16
22
  def next
17
23
  super
18
- rescue NativeException => e
19
- if e.cause.getClass == Pacer::NoSuchElementException.getClass
20
- raise e.cause
21
- else
22
- raise e
23
- end
24
24
  ensure
25
25
  @path = @next_path
26
26
  end
27
27
 
28
28
  def setStarts(starts)
29
- @starts_has_path = starts.respond_to? :getPath
30
29
  super
30
+ enablePath true if yield_paths
31
31
  end
32
32
 
33
33
  protected
34
34
 
35
+ attr_reader :wrapper, :control_block, :expando, :looping_pipe, :graph, :yield_paths
36
+
35
37
  def processNextStart
36
38
  while true
37
39
  # FIXME: hasNext shouldn't be raising an exception...
38
- has_next = @looping_pipe.hasNext rescue nil
40
+ has_next = looping_pipe.hasNext
39
41
  if has_next
40
- element = @looping_pipe.next
41
- depth = (@expando.metadata || 0) + 1
42
- @next_path = @looping_pipe.getPath
42
+ element = looping_pipe.next
43
+ depth = (expando.metadata || 0) + 1
44
+ @next_path = looping_pipe.getCurrentPath if yield_paths
43
45
  else
44
- element = @starts.next
45
- if @starts_has_path
46
- @next_path = @starts.getPath
46
+ element = starts.next
47
+ if pathEnabled
48
+ @next_path = starts.getCurrentPath
47
49
  else
48
50
  @next_path = ArrayList.new
49
51
  @next_path.add element
50
52
  end
51
53
  depth = 0
52
54
  end
53
- element.graph ||= @graph if element.respond_to? :graph=
54
- case @control_block.call element, depth, @next_path
55
+ wrapped = wrapper.new(element)
56
+ wrapped.graph = graph if wrapped.respond_to? :graph=
57
+ path = @next_path.map do |e|
58
+ w = wrapper.new e
59
+ w.graph = graph if w.respond_to? :graph=
60
+ w
61
+ end
62
+ case control_block.call wrapped, depth, path
55
63
  when :loop
56
- @expando.add element, depth, @next_path
64
+ expando.add element, depth, @next_path
57
65
  when :emit
58
66
  return element
59
67
  when :emit_and_loop, :loop_and_emit
60
- @expando.add element, depth, @next_path
68
+ expando.add element, depth, @next_path
61
69
  return element
62
70
  when false, nil
63
71
  else
64
- @expando.add element, depth, @next_path
72
+ expando.add element, depth, @next_path
65
73
  return element
66
74
  end
67
75
  end
68
- rescue NativeException => e
69
- if e.cause.getClass == Pacer::NoSuchElementException.getClass
70
- raise e.cause
71
- else
72
- raise e
73
- end
74
76
  end
75
77
 
76
78
  def getPathToHere
@@ -3,7 +3,7 @@ module Pacer::Pipes
3
3
  protected
4
4
 
5
5
  def processNextStart
6
- raise NoSuchElementException
6
+ raise EmptyPipe.instance
7
7
  end
8
8
  end
9
9
  end
@@ -0,0 +1,40 @@
1
+ module Pacer
2
+ module Pipes
3
+ class PathWrappingPipe < RubyPipe
4
+ attr_reader :graph
5
+ attr_accessor :vertex_wrapper, :edge_wrapper, :other_wrapper
6
+
7
+ def initialize(graph, vertex_extensions = [], edge_extensions = [])
8
+ super()
9
+ @graph = graph
10
+ @vertex_wrapper = Pacer::Wrappers::WrapperSelector.build :vertex, vertex_extensions || Set[]
11
+ @edge_wrapper = Pacer::Wrappers::WrapperSelector.build :edge, edge_extensions || Set[]
12
+ end
13
+
14
+ def getCurrentPath
15
+ starts.getCurrentPath
16
+ end
17
+
18
+ def processNextStart
19
+ path = starts.next
20
+ path.collect do |item|
21
+ if item.is_a? Pacer::Vertex
22
+ wrapped = vertex_wrapper.new item
23
+ wrapped.graph = graph
24
+ wrapped
25
+ elsif item.is_a? Pacer::Edge
26
+ wrapped = edge_wrapper.new item
27
+ wrapped.graph = graph
28
+ wrapped
29
+ elsif other_wrapper
30
+ wrapped = other_wrapper.new item
31
+ wrapped.graph = graph if wrapped.respond_to? :graph
32
+ wrapped
33
+ else
34
+ item
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -5,33 +5,15 @@ module Pacer::Pipes
5
5
 
6
6
  def initialize(back, block)
7
7
  super()
8
- @block = block
9
- @back = back
10
- @graph = back.graph if back
11
- @extensions = back.extensions + [Pacer::Extensions::BlockFilterElement]
12
- @is_element = graph.element_type?(back.element_type) if graph
8
+ @block = Pacer::Wrappers::WrappingPipeFunction.new back, block
13
9
  end
14
10
 
15
11
  def processNextStart
16
12
  while true
17
13
  obj = starts.next
18
- begin
19
- if is_element
20
- obj = obj.add_extensions(extensions)
21
- obj.back = back
22
- obj.graph = graph
23
- end
24
- rescue
25
- end
26
- result = block.call(obj)
14
+ block.call(obj)
27
15
  return obj
28
16
  end
29
- rescue NativeException => e
30
- if e.cause.getClass == Pacer::NoSuchElementException.getClass
31
- raise e.cause
32
- else
33
- raise e
34
- end
35
17
  end
36
18
  end
37
19
  end
@@ -29,12 +29,6 @@ module Pacer::Pipes
29
29
  return obj if l and r and l <= r
30
30
  end
31
31
  end
32
- rescue NativeException => e
33
- if e.cause.getClass == Pacer::NoSuchElementException.getClass
34
- raise e.cause
35
- else
36
- raise e
37
- end
38
32
  end
39
33
  end
40
34
  end
@@ -1,5 +1,7 @@
1
1
  module Pacer::Pipes
2
2
  class RubyPipe < AbstractPipe
3
+ field_reader :pathEnabled
4
+
3
5
  attr_reader :starts
4
6
 
5
7
  def setStarts(starts)
@@ -9,14 +11,19 @@ module Pacer::Pipes
9
11
 
10
12
  def reset
11
13
  super
12
- @starts.reset if starts.respond_to? :reset
14
+ starts.reset if starts.respond_to? :reset
15
+ end
16
+
17
+ def enablePath(b)
18
+ super
19
+ starts.enablePath b if starts.respond_to? :enablePath
13
20
  end
14
21
 
15
22
  protected
16
23
 
17
24
  def getPathToHere
18
- if starts.respond_to? :getPath
19
- starts.getPath
25
+ if starts.respond_to? :getCurrentPath
26
+ starts.getCurrentPath
20
27
  else
21
28
  java.util.ArrayList.new
22
29
  end
@@ -1,14 +1,15 @@
1
1
  module Pacer
2
2
  module Pipes
3
3
  class SimpleVisitorPipe < Pacer::Pipes::RubyPipe
4
- attr_reader :visitor, :in_section
4
+ attr_reader :visitor, :in_section, :wrapper, :graph
5
5
 
6
6
  attr_accessor :use_on_element, :use_after_element, :use_reset
7
7
 
8
- def initialize(visitor = nil)
8
+ def initialize(wrapper, graph)
9
9
  super()
10
- self.visitor = visitor if visitor
11
10
  @in_section = false
11
+ @wrapper = wrapper
12
+ @graph = graph
12
13
  end
13
14
 
14
15
  def visitor=(visitor)
@@ -22,15 +23,15 @@ module Pacer
22
23
  visitor.after_element if use_after_element and in_section
23
24
  current = starts.next
24
25
  @in_section = true unless in_section
25
- visitor.on_element(current) if use_on_element
26
- return current
27
- rescue NativeException => e
28
- if e.cause.getClass == Pacer::NoSuchElementException.getClass
29
- @in_section = false
30
- raise e.cause
31
- else
32
- raise
26
+ if use_on_element
27
+ wrapped = wrapper.new current
28
+ wrapped.graph = graph
29
+ visitor.on_element(wrapped)
33
30
  end
31
+ return current
32
+ rescue EmptyPipe, java.util.NoSuchElementException
33
+ @in_section = false
34
+ raise EmptyPipe.instance
34
35
  end
35
36
 
36
37
  def reset
@@ -72,13 +72,7 @@ module Pacer::Pipes
72
72
  @clearing = @first_silo + @second_silo.sort! + @third_silo.sort!
73
73
  return processNextStart if @clearing.any?
74
74
  end
75
- raise Pacer::NoSuchElementException
76
- rescue NativeException => e
77
- if e.cause.getClass == NoSuchElementException.getClass
78
- raise e.cause
79
- else
80
- raise e
81
- end
75
+ raise EmptyPipe.instance
82
76
  end
83
77
  end
84
78
  end
@@ -22,12 +22,6 @@ module Pacer::Pipes
22
22
  return obj
23
23
  end
24
24
  end
25
- rescue NativeException => e
26
- if e.cause.getClass == NoSuchElementException.getClass
27
- raise e.cause
28
- else
29
- raise e
30
- end
31
25
  end
32
26
  end
33
27
  end
@@ -10,13 +10,7 @@ module Pacer::Pipes
10
10
  s = @starts.next
11
11
  return s if s.is_a? @type
12
12
  end
13
- raise Pacer::NoSuchElementException
14
- rescue NativeException => e
15
- if e.cause.getClass == Pacer::NoSuchElementException.getClass
16
- raise e.cause
17
- else
18
- raise e
19
- end
13
+ raise EmptyPipe.instance
20
14
  end
21
15
  end
22
16
  end
@@ -1,7 +1,7 @@
1
1
  module Pacer::Pipes
2
2
  class UnaryTransformPipe < RubyPipe
3
3
  import com.tinkerpop.pipes.Pipe
4
- import com.tinkerpop.pipes.util.SingleIterator
4
+ import com.tinkerpop.pipes.util.iterators.SingleIterator
5
5
 
6
6
  attr_reader :branch_a, :method
7
7
 
@@ -21,12 +21,6 @@ module Pacer::Pipes
21
21
  def processNextStart
22
22
  next_a
23
23
  a.send method rescue nil if a.respond_to? method
24
- rescue NativeException => e
25
- if e.cause.getClass == Pacer::NoSuchElementException.getClass
26
- raise e.cause
27
- else
28
- raise e
29
- end
30
24
  end
31
25
 
32
26
  protected
@@ -42,8 +36,12 @@ module Pacer::Pipes
42
36
  if branch_a
43
37
  begin
44
38
  self.a = branch_a.next
39
+ rescue EmptyPipe
40
+ next_element
41
+ branch_a.setStarts SingleIterator.new(element) if branch_a
42
+ retry
45
43
  rescue NativeException => e
46
- if e.cause.getClass == Pacer::NoSuchElementException.getClass or @first
44
+ if @first
47
45
  next_element
48
46
  branch_a.setStarts SingleIterator.new(element) if branch_a
49
47
  retry
@@ -0,0 +1,13 @@
1
+ module Pacer
2
+ module Pipes
3
+ class UnwrappingPipe < RubyPipe
4
+ def processNextStart
5
+ starts.next.element
6
+ end
7
+
8
+ def getCurrentPath
9
+ starts.getCurrentPath
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,22 @@
1
+ module Pacer::Pipes
2
+ class VerticesPipe < AbstractPipe
3
+ attr_reader :starts
4
+
5
+ def setStarts(starts)
6
+ @starts = starts.first
7
+ self.iter = @starts.getVertices.iterator
8
+ end
9
+
10
+ def processNextStart
11
+ iter.next
12
+ end
13
+
14
+ def reset
15
+ self.iter = @starts.getVertices.iterator
16
+ end
17
+
18
+ private
19
+
20
+ attr_accessor :iter
21
+ end
22
+ end
@@ -47,13 +47,9 @@ module Pacer
47
47
  end
48
48
  end
49
49
  end
50
- rescue NativeException => e
51
- if e.cause.getClass == Pacer::NoSuchElementException.getClass
52
- @in_section = false
53
- raise e.cause
54
- else
55
- raise
56
- end
50
+ rescue EmptyPipe, java.util.NoSuchElementException
51
+ @in_section = false
52
+ raise EmptyPipe.instance
57
53
  end
58
54
 
59
55
  def reset
@@ -0,0 +1,37 @@
1
+ module Pacer
2
+ module Pipes
3
+ class WrappingPipe < RubyPipe
4
+ attr_reader :graph, :element_type, :extensions, :wrapper
5
+
6
+ def initialize(graph, element_type = nil, extensions = [])
7
+ super()
8
+ @graph = graph
9
+ @element_type = element_type
10
+ @extensions = extensions || []
11
+ @wrapper = Pacer::Wrappers::WrapperSelector.build element_type, @extensions
12
+ end
13
+
14
+ def getCurrentPath
15
+ starts.getCurrentPath
16
+ end
17
+
18
+ def wrapper=(w)
19
+ if extensions.any? and w.respond_to? :add_extensions
20
+ @wrapper = w.add_extensions extensions
21
+ else
22
+ @wrapper = w
23
+ end
24
+ end
25
+
26
+ def processNextStart
27
+ e = wrapper.new starts.next
28
+ if element_type == :vertex or element_type == :edge or element_type == :mixed
29
+ e.graph = graph
30
+ elsif e.respond_to? :graph=
31
+ e.graph = graph
32
+ end
33
+ e
34
+ end
35
+ end
36
+ end
37
+ end
data/lib/pacer/pipes.rb CHANGED
@@ -5,8 +5,7 @@ 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.ExpandableIterator
9
- import com.tinkerpop.pipes.util.MultiIterator
8
+ import com.tinkerpop.pipes.util.iterators.MultiIterator
10
9
  import com.tinkerpop.pipes.util.PipeHelper
11
10
 
12
11
  import com.tinkerpop.pipes.filter.RandomFilterPipe
@@ -14,8 +13,12 @@ module Pacer
14
13
  import com.tinkerpop.pipes.filter.RangeFilterPipe
15
14
  import com.tinkerpop.pipes.filter.FilterPipe
16
15
 
17
- import com.tinkerpop.pipes.transform.IdPipe
18
- import com.tinkerpop.pipes.transform.PropertyPipe
16
+ import com.tinkerpop.gremlin.pipes.transform.IdPipe
17
+ import com.tinkerpop.gremlin.pipes.transform.PropertyPipe
18
+
19
+ IN = com.tinkerpop.blueprints.Direction::IN
20
+ OUT = com.tinkerpop.blueprints.Direction::OUT
21
+ BOTH = com.tinkerpop.blueprints.Direction::BOTH
19
22
 
20
23
  EQUAL = FilterPipe::Filter::EQUAL
21
24
  NOT_EQUAL = FilterPipe::Filter::NOT_EQUAL
@@ -23,23 +26,22 @@ module Pacer
23
26
  end
24
27
 
25
28
  import java.util.Iterator
26
- begin
27
- java.util.ArrayList.new.iterator.next
28
- rescue NativeException => e
29
- NoSuchElementException = e.cause
30
- Pipes::NoSuchElementException = e.cause
31
- end
29
+
30
+ EmptyPipe = com.tinkerpop.pipes.util.FastNoSuchElementException
31
+ Pipes::EmptyPipe = EmptyPipe
32
32
  end
33
33
 
34
34
  require 'pacer/pipe/ruby_pipe'
35
35
 
36
+ require 'pacer/pipe/vertices_pipe'
37
+ require 'pacer/pipe/edges_pipe'
38
+
36
39
  require 'pacer/pipe/never_pipe'
37
40
  require 'pacer/pipe/block_filter_pipe'
38
41
  require 'pacer/pipe/collection_filter_pipe'
39
42
  require 'pacer/pipe/enumerable_pipe'
40
43
  require 'pacer/pipe/expandable_pipe'
41
44
  require 'pacer/pipe/loop_pipe'
42
- require 'pacer/pipe/map_pipe'
43
45
  require 'pacer/pipe/process_pipe'
44
46
  require 'pacer/pipe/visitor_pipe'
45
47
  require 'pacer/pipe/simple_visitor_pipe'
@@ -51,7 +53,6 @@ require 'pacer/pipe/type_filter_pipe'
51
53
  require 'pacer/pipe/label_collection_filter_pipe'
52
54
  require 'pacer/pipe/id_collection_filter_pipe'
53
55
  require 'pacer/pipe/label_prefix_pipe'
54
- require 'pacer/pipe/variable_store_iterator_wrapper'
55
56
 
56
57
  require 'pacer/pipe/property_comparison_pipe'
57
58
 
@@ -59,3 +60,7 @@ require 'pacer/pipe/blackbox_pipeline'
59
60
 
60
61
  require 'pacer/pipe/unary_transform_pipe'
61
62
  require 'pacer/pipe/cross_product_transform_pipe'
63
+
64
+ require 'pacer/pipe/wrapping_pipe'
65
+ require 'pacer/pipe/path_wrapping_pipe'
66
+ require 'pacer/pipe/unwrapping_pipe'