pacer 1.3.1-java → 1.3.2-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 873067a94942616e42ecb659e821bdf1f13c6bd4
4
- data.tar.gz: 91c4e71707fa23b969e6205d650a981464d2b4a5
3
+ metadata.gz: 941518faaec723674b8421588ee147d210b65b7a
4
+ data.tar.gz: 5624f8bf440519e6335d7f850d8cb0b3403c4d49
5
5
  SHA512:
6
- metadata.gz: bacb0e4e165bd10005d090cc7e1cd1fae2954b88901725078729c2fdd62e202c7f42237ed1d62b2d08aa5b1864b061eceb6638bc3900dbf9ccfbedfef32179fa
7
- data.tar.gz: 687bc677f5ca3682ef2b012ed278731d2a2963f85f399ef4829b55a4dc35d6e82d504d4470e50a60c6dc5d19f8d2b19e93411801ef6ac60815b0ed22d84ed167
6
+ metadata.gz: 85df9faed211d24e9a2810867194a41494955d76e03918b99150b03720eb93c2c83e1d4832215424b7f30d07138d0226333c634782950cd31a1d903c42004585
7
+ data.tar.gz: 25b18a28d5f9f25ee014ae6ea3940dc0c6dce0abfebdab76414394252018aa6d8da58da5e5faf45eec324861e7d910a3f84344151a67b8da72b0b0a4157f0e01
data/.gitignore CHANGED
@@ -15,6 +15,9 @@ Gemfile.lock
15
15
  # jeweler generated
16
16
  pkg
17
17
 
18
+ # mac custom attributes files
19
+ .DS_Store
20
+
18
21
  # Project specific
19
22
  *.graph
20
23
  *.db
@@ -27,3 +30,4 @@ bin
27
30
  .jitcache
28
31
  coverage/*
29
32
  dex.log
33
+ vendor/
@@ -7,7 +7,7 @@ module Pacer::Core::Graph
7
7
  def v(*args, &block)
8
8
  route = chain_route :element_type => :vertex,
9
9
  :pipe_class => Pacer::Pipes::TypeFilterPipe,
10
- :pipe_args => graph.base_vertex_wrapper,
10
+ :pipe_args => Pacer::Vertex,
11
11
  :wrapper => wrapper,
12
12
  :extensions => extensions
13
13
  Pacer::Route.property_filter(route, args, block)
@@ -17,7 +17,7 @@ module Pacer::Core::Graph
17
17
  def e(*args, &block)
18
18
  route = chain_route :element_type => :edge,
19
19
  :pipe_class => Pacer::Pipes::TypeFilterPipe,
20
- :pipe_args => graph.base_edge_wrapper,
20
+ :pipe_args => Pacer::Edge,
21
21
  :wrapper => wrapper,
22
22
  :extensions => extensions
23
23
  Pacer::Route.property_filter(route, args, block)
@@ -68,13 +68,13 @@ module Pacer::Core::Graph
68
68
  end
69
69
 
70
70
  def element_type
71
- graph.element_type(:mixed)
71
+ :mixed
72
72
  end
73
73
 
74
74
  # Calculate and save result.
75
75
  def result(name = nil)
76
76
  ids = collect do |element|
77
- if element.is_a? Pacer::Wrappers::VertexWrapper
77
+ if element.is_a? Pacer::Vertex
78
78
  [:vertex, element.element_id]
79
79
  else
80
80
  [:edge, element.element_id]
@@ -35,7 +35,7 @@ module Pacer
35
35
 
36
36
  def attach_pipe(end_pipe)
37
37
  pipe = FutureFilterPipe.new(lookahead_pipe)
38
- pipe.set_starts(end_pipe) if end_pipe
38
+ pipe.setStarts(end_pipe) if end_pipe
39
39
  pipe
40
40
  end
41
41
 
@@ -5,6 +5,20 @@ module Pacer
5
5
  chain_route :filter => :loop, :looping_route => block
6
6
  end
7
7
 
8
+ def all(&block)
9
+ loop(&block).while do |e, depth|
10
+ if depth == 0
11
+ :loop
12
+ else
13
+ :loop_and_recur
14
+ end
15
+ end
16
+ end
17
+
18
+ def deepest(&block)
19
+ loop(&block).deepest!
20
+ end
21
+
8
22
  # Apply the given path fragment multiple times in succession. If a Range
9
23
  # or Array of numbers is given, the results are a combination of the
10
24
  # results from all of the specified repetition levels. That is useful if
@@ -145,18 +159,45 @@ HELP
145
159
  self
146
160
  end
147
161
 
162
+ # this could have concurrency problems if multiple instances of the same
163
+ # route
164
+ def deepest!
165
+ @deepest = true
166
+ self
167
+ end
168
+
148
169
  protected
149
170
 
150
171
  def attach_pipe(end_pipe)
151
- unless @control_block
172
+ if @deepest
173
+ control_block = deepest_control_block
174
+ elsif @control_block
175
+ control_block = @control_block
176
+ else
152
177
  fail ClientError, 'No loop control block specified. Use either #while or #until after #loop.'
153
178
  end
154
-
155
- pipe = Pacer::Pipes::LoopPipe.new(graph, looping_pipe, @control_block)
179
+ pipe = Pacer::Pipes::LoopPipe.new(graph, looping_pipe, control_block)
156
180
  pipe.setStarts(end_pipe) if end_pipe
157
181
  pipe
158
182
  end
159
183
 
184
+ def deepest_control_block
185
+ expando = Pacer::Pipes::ExpandablePipe.new
186
+ empty = java.util.ArrayList.new
187
+ expando.setStarts empty.iterator
188
+ control_pipe = looping_pipe
189
+ control_pipe.setStarts expando
190
+ proc do |el, depth|
191
+ control_pipe.reset
192
+ expando.add el.element
193
+ if control_pipe.hasNext
194
+ :loop
195
+ elsif depth > 0
196
+ :emit
197
+ end
198
+ end
199
+ end
200
+
160
201
  def looping_pipe
161
202
  Pacer::Route.pipeline(looping_route)
162
203
  end
@@ -32,7 +32,8 @@ module Pacer
32
32
  protected
33
33
 
34
34
  def attach_pipe(end_pipe)
35
- pipe = ObjectFilterPipe.new(value, negate ? Pacer::Pipes::NOT_EQUAL : Pacer::Pipes::EQUAL)
35
+ obj = if value.respond_to?(:element) then value.element else value end
36
+ pipe = ObjectFilterPipe.new(obj, negate ? Pacer::Pipes::NOT_EQUAL : Pacer::Pipes::EQUAL)
36
37
  pipe.set_starts end_pipe if end_pipe
37
38
  pipe
38
39
  end
@@ -33,7 +33,7 @@ module Pacer
33
33
 
34
34
  def where_statement=(str)
35
35
  @where_statement = str
36
- @built = @parsed = @intermediate = nil
36
+ @parsed = @intermediate = nil
37
37
  end
38
38
 
39
39
  def parsed
@@ -49,7 +49,7 @@ module Pacer
49
49
  end
50
50
 
51
51
  def build!
52
- @built ||= intermediate.build
52
+ intermediate.build
53
53
  end
54
54
 
55
55
  protected
data/lib/pacer/loader.rb CHANGED
@@ -80,6 +80,7 @@ require 'pacer/filter/block_filter'
80
80
  require 'pacer/filter/object_filter'
81
81
  require 'pacer/filter/random_filter'
82
82
 
83
+ require 'pacer/transform/branch'
83
84
  require 'pacer/transform/cap'
84
85
  require 'pacer/transform/stream_sort'
85
86
  require 'pacer/transform/stream_uniq'
@@ -0,0 +1,127 @@
1
+ module Pacer
2
+ module Core
3
+ module Route
4
+ def branch(&block)
5
+ route = chain_route transform: ::Pacer::Transform::Branch
6
+ route.add_block! &block
7
+ end
8
+
9
+ def cond(where, &block)
10
+ route = chain_route transform: ::Pacer::Transform::Branch
11
+ route.add_cond! where, &block
12
+ end
13
+ end
14
+ end
15
+
16
+ module Transform
17
+ module Branch
18
+ import com.tinkerpop.pipes.branch.CopySplitPipe;
19
+ import com.tinkerpop.pipes.branch.ExhaustMergePipe
20
+ import com.tinkerpop.pipes.branch.FairMergePipe
21
+
22
+ attr_accessor :branches, :split_pipe_class, :merge_pipe_class, :conds
23
+
24
+ def after_initialize
25
+ super
26
+ self.branches ||= []
27
+ self.conds ||= []
28
+ self.split_pipe_class ||= CopySplitPipe
29
+ self.merge_pipe_class ||= FairMergePipe
30
+ end
31
+
32
+ def clone(conf = {})
33
+ back.chain_route({transform: Branch,
34
+ branches: branches.clone,
35
+ element_type: element_type,
36
+ conds: conds.clone,
37
+ extensions: extensions.clone,
38
+ split_pipe_class: split_pipe_class,
39
+ merge_pipe_class: merge_pipe_class
40
+ }.merge(conf))
41
+ end
42
+
43
+ def branch(&block)
44
+ route = clone
45
+ route.add_block! &block
46
+ end
47
+
48
+ def cond(where, &block)
49
+ route = clone
50
+ route.add_cond! where, &block
51
+ end
52
+
53
+ def otherwise(&block)
54
+ where = "(#{ conds.compact.map { |c| "not (#{c})" }.join " and " })"
55
+ cond where, &block
56
+ end
57
+
58
+ def merge
59
+ route = clone
60
+ route.merge_pipe_class = FairMergePipe
61
+ route.chain_route transform: MergedBranch
62
+ end
63
+
64
+ def merge_exhaustive
65
+ route = clone
66
+ route.merge_pipe_class = ExhaustMergePipe
67
+ route.chain_route transform: MergedBranch
68
+ end
69
+
70
+ def add_block!(&block)
71
+ will_clone = false
72
+ branch = block.call(Pacer::Route.empty(self))
73
+ branches.push branch
74
+ conf = {}
75
+
76
+ exts = branches.
77
+ map { |b| b.extensions }.
78
+ map { |a| a ? a.to_set : Set[] }.
79
+ reduce { |r, e| r.intersection(e) }
80
+ if exts.to_a != config[:extensions]
81
+ conf[:extensions] = exts.to_a
82
+ end
83
+
84
+ types = branches.map { |b| b.element_type }.to_set
85
+ if types.length == 1
86
+ type = types.first
87
+ elsif types.difference([:vertex, :edge, :mixed]).empty?
88
+ type = :mixed
89
+ elsif types.difference([:path, :array]).empty?
90
+ type = :array
91
+ else
92
+ type = :object
93
+ end
94
+ if type != element_type
95
+ conf[:element_type] = type
96
+ end
97
+ if conf.empty?
98
+ self
99
+ else
100
+ clone conf
101
+ end
102
+ end
103
+
104
+ def add_cond!(where, &block)
105
+ conds[branches.length] = where
106
+ add_block! do |r|
107
+ block.call r.where(where)
108
+ end
109
+ end
110
+
111
+ def attach_pipe(end_pipe)
112
+ branch_pipes = branches.map { |b| Pacer::Route.pipeline(b) }
113
+ split = split_pipe_class.new branch_pipes
114
+ split.setStarts end_pipe if end_pipe
115
+ merge = merge_pipe_class.new branch_pipes
116
+ merge.setStarts split
117
+ merge
118
+ end
119
+ end
120
+
121
+ module MergedBranch
122
+ # This just exists so that if I merge and then branch again,
123
+ # the new branches will be against the merged source.
124
+ end
125
+ end
126
+ end
127
+
@@ -5,7 +5,7 @@ module Pacer
5
5
  route = chain_route :transform => :path, :element_type => :path
6
6
  if exts.any?
7
7
  exts = exts.map { |e| Array.wrap(e) if e }
8
- route.map(modules: Pacer::Transform::Path::Methods) do |path|
8
+ route.map(element_type: :path) do |path|
9
9
  path.zip(exts).map { |element, ext| ext ? element.add_extensions(ext) : element }
10
10
  end
11
11
  else
data/lib/pacer/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Pacer
2
2
  unless const_defined? :VERSION
3
- VERSION = "1.3.1"
3
+ VERSION = "1.3.2"
4
4
 
5
5
  JAR = "pacer-#{ VERSION }-standalone.jar"
6
6
  JAR_PATH = "lib/#{ JAR }"
data/pom.xml CHANGED
@@ -8,7 +8,7 @@
8
8
  <!-- NOTE: the following properties are automatically updated based on the values in lib/pacer-neo4j/version.rb -->
9
9
  <properties>
10
10
  <blueprints.version>2.3.0</blueprints.version>
11
- <gem.version>1.3.1</gem.version>
11
+ <gem.version>1.3.2</gem.version>
12
12
  <pipes.version>2.3.0</pipes.version>
13
13
  <gremlin.version>2.3.0</gremlin.version>
14
14
  </properties>
@@ -1,15 +1,35 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Pacer::Filter::ObjectFilter do
4
- it '#is' do
5
- [1, 2, 3, 2, 3].to_route.is(2).to_a.should == [2, 2]
6
- end
3
+ Run.tg(:read_only) do
4
+ use_pacer_graphml_data(:read_only)
5
+
6
+ describe Pacer::Filter::ObjectFilter do
7
+ it '#is' do
8
+ [1, 2, 3, 2, 3].to_route.is(2).to_a.should == [2, 2]
9
+ end
7
10
 
8
- it '#is_not' do
9
- [1, 2, 3, 2, 3].to_route.is_not(2).to_a.should == [1, 3, 3]
10
- end
11
+ it '#is_not' do
12
+ [1, 2, 3, 2, 3].to_route.is_not(2).to_a.should == [1, 3, 3]
13
+ end
14
+
15
+ it '#compact' do
16
+ [1, nil, 2, 3].to_route.compact.to_a.should == [1, 2, 3]
17
+ end
18
+
19
+ describe '#vertex filter' do
11
20
 
12
- it '#compact' do
13
- [1, nil, 2, 3].to_route.compact.to_a.should == [1, 2, 3]
21
+ let (:filter_node) { graph.vertex 3 }
22
+
23
+ it "#is_not" do
24
+ all_nodes = graph.v.to_a.select { |n| n.getId != filter_node.getId }
25
+ graph.v.is_not(filter_node).to_a.should == all_nodes
26
+ end
27
+
28
+ it "#is" do
29
+ graph.v.is(filter_node).to_a.should == [filter_node]
30
+ end
31
+
32
+ end
14
33
  end
34
+
15
35
  end
@@ -362,13 +362,13 @@ Run.all :read_write do
362
362
  it 'should create a file that can be read back' do
363
363
  graph.v.count.should == 2
364
364
  graph.e.count.should == 2
365
- Pacer::GraphML.export graph, 'tmp/graph_mixin_spec_export.graphml'
365
+ Pacer::GraphML.export graph, '/tmp/graph_mixin_spec_export.graphml'
366
366
  graph2.e.delete!
367
367
  graph2.v.delete!
368
368
  graph2.v.count.should == 0
369
369
  graph2.e.count.should == 0
370
- Pacer::GraphML.import graph2, 'tmp/graph_mixin_spec_export.graphml'
371
- puts File.read 'tmp/graph_mixin_spec_export.graphml'
370
+ Pacer::GraphML.import graph2, '/tmp/graph_mixin_spec_export.graphml'
371
+ puts File.read '/tmp/graph_mixin_spec_export.graphml'
372
372
  graph2.v.count.should == 2
373
373
  graph2.e.count.should == 2
374
374
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pacer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: java
6
6
  authors:
7
7
  - Darrick Wiebe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-04 00:00:00.000000000 Z
11
+ date: 2013-08-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Pacer defines routes through a graph and then traverses them very quickly.
14
14
  email: darrick@innatesoftware.com
@@ -124,6 +124,7 @@ files:
124
124
  - lib/pacer/support/native_exception.rb
125
125
  - lib/pacer/support/nil_class.rb
126
126
  - lib/pacer/support/proc.rb
127
+ - lib/pacer/transform/branch.rb
127
128
  - lib/pacer/transform/cap.rb
128
129
  - lib/pacer/transform/flat_map.rb
129
130
  - lib/pacer/transform/gather.rb
@@ -217,7 +218,7 @@ files:
217
218
  - spec/support/use_transactions.rb
218
219
  - spec/tackle/simple_mixin.rb
219
220
  - spec/tackle/tinkerpop_graph_mixins.rb
220
- - lib/pacer-1.3.1-standalone.jar
221
+ - lib/pacer-1.3.2-standalone.jar
221
222
  homepage: http://github.com/pangloss/pacer
222
223
  licenses:
223
224
  - MIT