Skip to content
This repository
  • 4 commits
  • 16 files changed
  • 0 comments
  • 1 contributor
5 lib/pacer.rb
@@ -250,11 +250,6 @@ def open_graphs
250 250 @open_graphs
251 251 end
252 252
253   - def next_graph_id
254   - @next_graph_id = 0 unless defined? @next_graph_id
255   - @next_graph_id += 1
256   - end
257   -
258 253 # Tell pacer to record that we're starting a graph.
259 254 #
260 255 # @param [Class] type type of graph
17 lib/pacer/blueprints/extensions.rb
@@ -7,28 +7,11 @@ def self.included(target)
7 7 target.class_eval do
8 8 include GraphMixin
9 9 include GraphIndicesMixin if target.ancestors.include? com.tinkerpop.blueprints.pgm.IndexableGraph
10   - include GraphTransactionsStub
11   - include ManagedTransactionsMixin
12 10 include Pacer::Core::Route
13 11 include Pacer::Core::Graph::GraphRoute
14 12 include Pacer::Core::Graph::GraphIndexRoute if target.ancestors.include? com.tinkerpop.blueprints.pgm.IndexableGraph
15 13 end
16 14 end
17   -
18   - # Override to return an enumeration-friendly array of vertices.
19   - def get_vertices
20   - getVertices.iterator.to_route(:graph => self, :element_type => :vertex)
21   - end
22   -
23   - # Override to return an enumeration-friendly array of edges.
24   - def get_edges
25   - getEdges.iterator.to_route(:graph => self, :element_type => :edge)
26   - end
27   -
28   - def ==(other)
29   - other.class == self.class and other.object_id == self.object_id
30   - end
31   -
32 15 end
33 16
34 17 module VertexExtensions
6 lib/pacer/blueprints/ruby_graph.rb
@@ -71,10 +71,6 @@ def shutdown
71 71 clear
72 72 end
73 73
74   - def ==(other)
75   - other.equal? self
76   - end
77   -
78 74 def supports_custom_element_ids?
79 75 true
80 76 end
@@ -90,7 +86,7 @@ def supports_manual_indices?
90 86 def supports_edge_indices?
91 87 false
92 88 end
93   -
  89 +
94 90 include GraphExtensions
95 91
96 92 protected
17 lib/pacer/blueprints/tg.rb
@@ -15,13 +15,10 @@ def self.tg(path = nil)
15 15 graph
16 16 end
17 17
18   -
19 18 # Extend the java class imported from blueprints.
20 19 class TinkerGraph
21 20 include GraphMixin
22 21 include GraphIndicesMixin
23   - include GraphTransactionsStub
24   - include ManagedTransactionsMixin
25 22 include Pacer::Core::Route
26 23 include Pacer::Core::Graph::GraphRoute
27 24 include Pacer::Core::Graph::GraphIndexRoute
@@ -37,20 +34,6 @@ def vertex_class
37 34 def edge_class
38 35 TinkerEdge
39 36 end
40   -
41   - # Override to return an enumeration-friendly array of vertices.
42   - def get_vertices
43   - getVertices.iterator.to_route(:graph => self, :element_type => :vertex)
44   - end
45   -
46   - # Override to return an enumeration-friendly array of edges.
47   - def get_edges
48   - getEdges.iterator.to_route(:graph => self, :element_type => :edge)
49   - end
50   -
51   - def ==(other)
52   - other.class == self.class and other.object_id == self.object_id
53   - end
54 37 end
55 38
56 39
17 lib/pacer/core/graph/vertices_route.rb
@@ -171,18 +171,11 @@ def add_edges_to(label, to_vertices, props = {})
171 171
172 172 has_props = !props.empty?
173 173 edge_ids = []
174   - counter = 0
175   - graph.managed_transactions do
176   - graph.managed_transaction do
177   - each do |from_v|
178   - to_vertices.each do |to_v|
179   - counter += 1
180   - graph.managed_checkpoint if counter % graph.bulk_job_size == 0
181   - begin
182   - edge = graph.create_edge(nil, from_v, to_v, label.to_s, props)
183   - edge_ids << edge.element_id
184   - end
185   - end
  174 + each do |from_v|
  175 + to_vertices.each do |to_v|
  176 + begin
  177 + edge = graph.create_edge(nil, from_v, to_v, label.to_s, props)
  178 + edge_ids << edge.element_id
186 179 end
187 180 end
188 181 end
1  lib/pacer/graph.rb
@@ -11,4 +11,3 @@ module Pacer
11 11 require 'pacer/graph/edge_mixin'
12 12 require 'pacer/graph/index_mixin'
13 13 require 'pacer/graph/graph_indices_mixin'
14   -require 'pacer/graph/graph_transactions_mixin'
7 lib/pacer/graph/graph_mixin.rb
@@ -14,13 +14,6 @@ def self.included(target)
14 14 end
15 15 end
16 16
17   - attr_accessor :in_bulk_job
18   -
19   - def graph_id
20   - @graph_id = Pacer.next_graph_id unless defined? @graph_id
21   - @graph_id
22   - end
23   -
24 17 # Get a vertex by id.
25 18 #
26 19 # @overload vertex(id)
124 lib/pacer/graph/graph_transactions_mixin.rb
... ... @@ -1,124 +0,0 @@
1   -module Pacer
2   - import com.tinkerpop.blueprints.pgm.TransactionalGraph
3   -
4   - # Collect a global set of graphs that are currently in a transaction.
5   - #
6   - # @return [Set] graphs with an open transaction
7   - def self.graphs_in_transaction
8   - @graphs = Set[] unless defined? @graphs
9   - @graphs
10   - end
11   -
12   - # Methods used internally to do 'managed transactions' which I define
13   - # as transactions that are started and committed automatically
14   - # internally, typically on operations that potentially touch a large
15   - # number of elements.
16   - #
17   - # The reason for keeping track of these separately is to prevent them
18   - # from being confused with manual transactions. Although when this was
19   - # written, I had made manual transactions nestable. That has been
20   - # since explicitly disallowed by Blueprints. I am not sure if this
21   - # code is actually needed anymore (if it was refactored out).
22   - #
23   - # TODO: the method names in this module need to be cleaned up.
24   - # TODO: some methods may be able to be eliminated.
25   - module ManagedTransactionsMixin
26   - def manage_transactions=(v)
27   - @manage_transactions = v
28   - end
29   -
30   - def manage_transactions?
31   - @manage_transactions = true unless defined? @manage_transactions
32   - @manage_transactions
33   - end
34   - alias manage_transactions manage_transactions?
35   -
36   - def unmanaged_transactions
37   - old_value = manage_transactions
38   - @manage_transactions = false
39   - yield
40   - ensure
41   - @manage_transactions = old_value
42   - end
43   -
44   - def managed_transactions
45   - if manage_transactions?
46   - manual_transactions { yield }
47   - else
48   - yield
49   - end
50   - end
51   -
52   - def managed_manual_transaction
53   - if manage_transactions?
54   - manual_transaction { yield }
55   - else
56   - yield
57   - end
58   - end
59   -
60   - def managed_transaction
61   - if manage_transactions?
62   - transaction { yield }
63   - else
64   - yield
65   - end
66   - end
67   -
68   - def managed_start_transaction
69   - begin_transaction if manage_transactions?
70   - end
71   -
72   - def managed_commit_transaction
73   - commit_transaction if manage_transactions?
74   - end
75   -
76   - def managed_checkpoint
77   - checkpoint if manage_transactions?
78   - end
79   - end
80   -
81   - # This is included into graphs that don't support transactions so that
82   - # their interface is the same as for graphs that do support them.
83   - #
84   - # All methods in this module do nothing but yield or return values
85   - # that match those in {GraphTransactionsMixin}
86   - module GraphTransactionsStub
87   - def in_transaction?
88   - false
89   - end
90   -
91   - def manual_transaction
92   - yield
93   - end
94   -
95   - def manual_transactions
96   - yield
97   - end
98   -
99   - def transaction
100   - yield
101   - end
102   -
103   - def begin_transaction
104   - end
105   -
106   - def commit_transaction
107   - end
108   -
109   - def rollback_transaction
110   - end
111   -
112   - def checkpoint
113   - end
114   - end
115   -
116   - # Add features to transactions to allow them to be more rubyish and
117   - # more convenient to use.
118   - #
119   - # TODO: the method names in this module need to be cleaned up.
120   - # TODO: some methods may be able to be eliminated.
121   - module GraphTransactionsMixin
122   - include GraphTransactionsStub
123   - end
124   -end
23 lib/pacer/route/mixin/bulk_operations.rb
@@ -19,28 +19,7 @@ def bulk_map(size = nil, target_graph = nil)
19 19 # +size+ records.
20 20 def bulk_job(size = nil, target_graph = nil)
21 21 target_graph ||= graph
22   - if target_graph and not target_graph.in_bulk_job?
23   - begin
24   - target_graph.in_bulk_job = true
25   - size ||= target_graph.bulk_job_size
26   - counter = 0
27   - each_slice(size) do |slice|
28   - print counter if Pacer.verbose?
29   - counter += size
30   - target_graph.managed_manual_transaction do
31   - target_graph.unmanaged_transactions do
32   - slice.each do |element|
33   - yield element
34   - end
35   - end
36   - print '.' if Pacer.verbose?
37   - end
38   - end
39   - ensure
40   - puts '!' if Pacer.verbose?
41   - target_graph.in_bulk_job = false
42   - end
43   - elsif target_graph
  22 + if target_graph
44 23 each do |element|
45 24 yield element
46 25 end
14 spec/pacer/blueprints/neo4j_spec.rb
@@ -159,19 +159,5 @@
159 159 v.extensions.should include(Tackle::SimpleMixin)
160 160 end
161 161 end
162   -
163   - describe '#get_vertices' do
164   - before { e0 }
165   - subject { graph.get_vertices }
166   - it { should be_a(Pacer::Core::Route) }
167   - its(:count) { should == 2 }
168   - end
169   -
170   - describe '#get_edges' do
171   - before { e0 }
172   - subject { graph.get_edges }
173   - it { should be_a(Pacer::Core::Route) }
174   - its(:count) { should == 1 }
175   - end
176 162 end
177 163 end
14 spec/pacer/blueprints/tg_spec.rb
@@ -110,19 +110,5 @@
110 110 v.extensions.should include(Tackle::SimpleMixin)
111 111 end
112 112 end
113   -
114   - describe '#get_vertices' do
115   - before { e0 }
116   - subject { graph.get_vertices }
117   - it { should be_a(Pacer::Core::Route) }
118   - its(:count) { should == 2 }
119   - end
120   -
121   - describe '#get_edges' do
122   - before { e0 }
123   - subject { graph.get_edges }
124   - it { should be_a(Pacer::Core::Route) }
125   - its(:count) { should == 1 }
126   - end
127 113 end
128 114 end
1  spec/pacer/graph/edge_mixin_spec.rb
@@ -37,7 +37,6 @@
37 37 before do
38 38 @edge_id = e0.element_id
39 39 e0.delete!
40   - graph.checkpoint # deleted edges in neo may be looked up during the transaction
41 40 end
42 41 it 'should be removed' do
43 42 graph.edge(@edge_id).should be_nil
17 spec/pacer/graph/graph_mixin_spec.rb
@@ -116,7 +116,7 @@
116 116 if graph.respond_to? :id_prefix
117 117 should == graph.id_prefix + '1234'
118 118 elsif graph.supports_custom_element_ids?
119   - should == '1234'
  119 + should == '1234'
120 120 end
121 121 end
122 122
@@ -127,7 +127,7 @@
127 127 if graph.respond_to? :id_prefix
128 128 should == graph.id_prefix + '1234'
129 129 elsif graph.supports_custom_element_ids?
130   - should == '1234'
  130 + should == '1234'
131 131 end
132 132 end
133 133 it_behaves_like 'a vertex with a mixin'
@@ -141,7 +141,7 @@
141 141 if graph.respond_to? :id_prefix
142 142 should == graph.id_prefix + '1234'
143 143 elsif graph.supports_custom_element_ids?
144   - should == '1234'
  144 + should == '1234'
145 145 end
146 146 end
147 147
@@ -151,7 +151,7 @@
151 151 if graph.respond_to? :id_prefix
152 152 should == graph.id_prefix + '1234'
153 153 elsif graph.supports_custom_element_ids?
154   - should == '1234'
  154 + should == '1234'
155 155 end
156 156 end
157 157 it_behaves_like 'a vertex with a mixin'
@@ -257,7 +257,6 @@
257 257 end
258 258
259 259 describe '#load_edges' do
260   - before { graph.checkpoint }
261 260 context 'invalid' do
262 261 subject { graph.load_edges [e0.element_id, nil, e0.element_id, 'missing'] }
263 262 it { should == [e0, e0] }
@@ -324,9 +323,7 @@
324 323 its(:index_type) { should == Pacer.manual_index }
325 324 its(:index_class) { should == graph.index_class(:edge) }
326 325 after do
327   - graph.transaction do
328   - graph.drop_index 'missing_edge'
329   - end
  326 + graph.drop_index 'missing_edge'
330 327 end
331 328 end
332 329
@@ -340,9 +337,7 @@
340 337 its(:index_type) { should == Pacer.manual_index }
341 338 its(:index_class) { should == graph.index_class(:vertex) }
342 339 after do
343   - graph.transaction do
344   - graph.drop_index 'missing_vertex'
345   - end
  340 + graph.drop_index 'missing_vertex'
346 341 end
347 342 end
348 343 end
1  spec/pacer/graph/vertex_mixin_spec.rb
@@ -98,7 +98,6 @@ module Vertex
98 98 before do
99 99 @vertex_id = v0.element_id
100 100 v0.delete!
101   - graph.checkpoint # deleted edges in neo may otherwise still be looked up during the transaction
102 101 end
103 102 it 'should be removed' do
104 103 graph.vertex(@vertex_id).should be_nil
1  spec/pacer/route/mixin/base_spec.rb
@@ -211,7 +211,6 @@
211 211 end
212 212
213 213 describe '#result' do
214   - before { graph.checkpoint }
215 214 subject { route.result }
216 215 its(:element_type) { should == route.element_type }
217 216 end
18 spec/support/graph_runner.rb
@@ -119,17 +119,13 @@ def for_graph(name, usage_style, indices, transactions, source_graph_1, source_g
119 119 unindexed_graph.v.delete! if unindexed_graph
120 120 end
121 121 if transactions and spec.use_transactions?
122   - graph.manual_transactions do
123   - graph2.manual_transactions do
124   - begin
125   - graph.begin_transaction
126   - graph2.begin_transaction
127   - spec.run
128   - ensure
129   - graph.rollback_transaction rescue nil
130   - graph2.rollback_transaction rescue nil
131   - end
132   - end
  122 + begin
  123 + #graph.begin_transaction
  124 + #graph2.begin_transaction
  125 + spec.run
  126 + ensure
  127 + #graph.rollback_transaction rescue nil
  128 + #graph2.rollback_transaction rescue nil
133 129 end
134 130 else
135 131 spec.run

No commit comments for this range

Something went wrong with that request. Please try again.