grumlin 0.22.0 → 0.22.3

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
  SHA256:
3
- metadata.gz: 519d93b97b2cd8f07a1e11e75e45b0b7ca780947e82b3624d5e6c7c6d719ec27
4
- data.tar.gz: 5eed9eab9e99fe02246995adbc8c01988bd21d150df234946a575d01cda518f2
3
+ metadata.gz: bdd374421192255c1b8a9eb86bd3be6247992f5d480c87dfff44be0d03c81171
4
+ data.tar.gz: 0daa84321a8c03711739d3f236c4c3c99cc91d7366aa1c3be7cc9f504d1e4f47
5
5
  SHA512:
6
- metadata.gz: 76cd4990acd94d119b2a716e25b10d35bdc970e794a77de4d25dcc7e3f67f5129236ff1c037a4f0f0c3208643afca9695b6dc602bb84ae01d61a84c1b89364fe
7
- data.tar.gz: afda51dc7010f1fc508e96b203727ebee971597b6425aa2ec29932d7957e1b2b12d8959526a5fc10d92e46926e94dab1ca3d62eb583bbb36498f99bbd3e11689
6
+ metadata.gz: 80ab5b7c904b4fc5bffd9904ca0a07f8eecb278475b080ba0b2d9916c9c0e58a8dee3399ecbf34ab59ea8a93fa426e0edcfe31e8ad5a721262108db71cf8b4c2
7
+ data.tar.gz: c7c3fa75552675a033044e3afc7144cf435df7a7ddcc0d9c611ae926633057fd968d9cd1f41aa54d6f7c7c937cf41ebaacb39c748859742bb9939edb696238a5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grumlin (0.22.0)
4
+ grumlin (0.22.3)
5
5
  async-pool (~> 0.3)
6
6
  async-websocket (~> 0.19)
7
7
  oj (~> 3.13)
@@ -21,17 +21,17 @@ GEM
21
21
  console (~> 1.10)
22
22
  nio4r (~> 2.3)
23
23
  timers (~> 4.1)
24
- async-http (0.57.0)
24
+ async-http (0.59.1)
25
25
  async (>= 1.25)
26
26
  async-io (>= 1.28)
27
27
  async-pool (>= 0.2)
28
28
  protocol-http (~> 0.23.1)
29
29
  protocol-http1 (~> 0.14.0)
30
30
  protocol-http2 (~> 0.14.0)
31
- traces (~> 0.4.0)
31
+ traces (>= 0.4.0)
32
32
  async-io (1.33.0)
33
33
  async
34
- async-pool (0.3.10)
34
+ async-pool (0.3.11)
35
35
  async (>= 1.25)
36
36
  async-rspec (1.16.1)
37
37
  rspec (~> 3.0)
@@ -81,7 +81,7 @@ GEM
81
81
  parser (3.1.2.0)
82
82
  ast (~> 2.4.1)
83
83
  protocol-hpack (1.4.2)
84
- protocol-http (0.23.1)
84
+ protocol-http (0.23.4)
85
85
  protocol-http1 (0.14.4)
86
86
  protocol-http (~> 0.22)
87
87
  protocol-http2 (0.14.2)
@@ -157,7 +157,7 @@ GEM
157
157
  thor (1.2.1)
158
158
  tilt (2.0.10)
159
159
  timers (4.3.3)
160
- traces (0.4.1)
160
+ traces (0.6.0)
161
161
  tzinfo (2.0.4)
162
162
  concurrent-ruby (~> 1.0)
163
163
  unicode-display_width (2.1.0)
data/README.md CHANGED
@@ -249,6 +249,7 @@ Each `return_mode` is mapped to a particular termination step:
249
249
  - `add_edge(label, id = nil, from:, to:, start: g, **properties)`
250
250
  - `drop_vertex(id, start: g)`
251
251
  - `drop_edge(id = nil, from: nil, to: nil, label: nil, start: g)`
252
+ - `drop_in_batches(traversal, batch_size: 10_000)`
252
253
 
253
254
  and a few methods that emulate upserts:
254
255
  - `upsert_vertex(label, id, create_properties: {}, update_properties: {}, on_failure: :retry, start: g, **params)`
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Grumlin
4
4
  module Repository
5
- module InstanceMethods
5
+ module InstanceMethods # rubocop:disable Metrics/ModuleLength
6
6
  include Grumlin::Expressions
7
7
 
8
8
  extend Forwardable
@@ -10,7 +10,7 @@ module Grumlin
10
10
  UPSERT_RETRY_PARAMS = {
11
11
  on: [Grumlin::AlreadyExistsError, Grumlin::ConcurrentModificationError],
12
12
  sleep_method: ->(n) { Async::Task.current.sleep(n) },
13
- tries: 3,
13
+ tries: 5,
14
14
  sleep: ->(n) { (n**2) + 1 + rand }
15
15
  }.freeze
16
16
 
@@ -26,6 +26,28 @@ module Grumlin
26
26
  start.V(id).drop.iterate
27
27
  end
28
28
 
29
+ def drop_in_batches(traversal, batch_size: 10_000) # rubocop:disable Metrics/AbcSize
30
+ total_count = traversal.count.next
31
+
32
+ batches = (total_count / batch_size) + 1
33
+
34
+ Console.logger.info(self) do
35
+ "drop_in_batches: total_count: #{total_count}, batch_size: #{batch_size}, batches: #{batches}"
36
+ end
37
+
38
+ batches.times do |batch|
39
+ Console.logger.info(self) { "drop_in_batches: deleting batch #{batch + 1}/#{batches}..." }
40
+ traversal.limit(batch_size).drop.iterate
41
+ Console.logger.info(self) { "drop_in_batches: batch #{batch + 1}/#{batches} deleted" }
42
+ end
43
+
44
+ return if traversal.count.next.zero?
45
+
46
+ drop_in_batches(traversal, batch_size: batch_size)
47
+
48
+ Console.logger.info(self) { "drop_in_batches: finished." }
49
+ end
50
+
29
51
  def drop_edge(id = nil, from: nil, to: nil, label: nil, start: g) # rubocop:disable Metrics/AbcSize
30
52
  raise ArgumentError, "either id or from:, to: and label: must be passed" if [id, from, to, label].all?(&:nil?)
31
53
  return start.E(id).drop.iterate unless id.nil?
@@ -18,11 +18,19 @@ module Grumlin
18
18
  # {"detailedMessage":"",
19
19
  # "requestId":"UUID",
20
20
  # "code":"ConcurrentModificationException"}
21
- # Currencly we simply search for substings to identify the exact error
21
+ # Currently we simply search for substrings to identify the exact error
22
22
  # TODO: parse json and use `code` instead
23
+
23
24
  VERTEX_ALREADY_EXISTS = "Vertex with id already exists:"
24
25
  EDGE_ALREADY_EXISTS = "Edge with id already exists:"
26
+
25
27
  CONCURRENT_VERTEX_INSERT_FAILED = "Failed to complete Insert operation for a Vertex due to conflicting concurrent"
28
+
29
+ CONCURRENT_VERTEX_PROPERTY_INSERT_FAILED =
30
+ "Failed to complete Insert operation for a VertexProperty due to conflicting concurrent"
31
+ CONCURRENT_EDGE_PROPERTY_INSERT_FAILED =
32
+ "Failed to complete Insert operation for a EdgeProperty due to conflicting concurrent"
33
+
26
34
  CONCURRENT_EDGE_INSERT_FAILED = "Failed to complete Insert operation for an Edge due to conflicting concurrent"
27
35
  CONCURRENCT_MODIFICATION_FAILED = "Failed to complete operation due to conflicting concurrent"
28
36
 
@@ -49,9 +57,15 @@ module Grumlin
49
57
  return EdgeAlreadyExistsError if status[:message]&.include?(EDGE_ALREADY_EXISTS)
50
58
  end
51
59
 
52
- def concurrent_modification_error(status)
60
+ def concurrent_modification_error(status) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
53
61
  return ConcurrentVertexInsertFailedError if status[:message]&.include?(CONCURRENT_VERTEX_INSERT_FAILED)
62
+ if status[:message]&.include?(CONCURRENT_VERTEX_PROPERTY_INSERT_FAILED)
63
+ return ConcurrentVertexPropertyInsertFailedError
64
+ end
54
65
  return ConcurrentEdgeInsertFailedError if status[:message]&.include?(CONCURRENT_EDGE_INSERT_FAILED)
66
+ if status[:message]&.include?(CONCURRENT_EDGE_PROPERTY_INSERT_FAILED)
67
+ return ConcurrentEdgePropertyInsertFailedError
68
+ end
55
69
  return ConcurrentModificationError if status[:message]&.include?(CONCURRENCT_MODIFICATION_FAILED)
56
70
  end
57
71
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grumlin
4
- VERSION = "0.22.0"
4
+ VERSION = "0.22.3"
5
5
  end
data/lib/grumlin.rb CHANGED
@@ -107,6 +107,9 @@ module Grumlin
107
107
  class ConcurrentVertexInsertFailedError < ConcurrentInsertFailedError; end
108
108
  class ConcurrentEdgeInsertFailedError < ConcurrentInsertFailedError; end
109
109
 
110
+ class ConcurrentVertexPropertyInsertFailedError < ConcurrentInsertFailedError; end
111
+ class ConcurrentEdgePropertyInsertFailedError < ConcurrentInsertFailedError; end
112
+
110
113
  class ServerSerializationError < ServerSideError; end
111
114
 
112
115
  class ServerTimeoutError < ServerSideError; end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grumlin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0
4
+ version: 0.22.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Sinyavskiy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-12 00:00:00.000000000 Z
11
+ date: 2022-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-pool