grumlin 0.22.0 → 0.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 519d93b97b2cd8f07a1e11e75e45b0b7ca780947e82b3624d5e6c7c6d719ec27
4
- data.tar.gz: 5eed9eab9e99fe02246995adbc8c01988bd21d150df234946a575d01cda518f2
3
+ metadata.gz: 8f91cc8f8b58fc3d72726e876dabac6a8f167e81bd524907eef4df7d72802e79
4
+ data.tar.gz: 892fa89f75c999899ff0869c7c6f74c26526b9eb5a6da0b43bd4df8a1b64504a
5
5
  SHA512:
6
- metadata.gz: 76cd4990acd94d119b2a716e25b10d35bdc970e794a77de4d25dcc7e3f67f5129236ff1c037a4f0f0c3208643afca9695b6dc602bb84ae01d61a84c1b89364fe
7
- data.tar.gz: afda51dc7010f1fc508e96b203727ebee971597b6425aa2ec29932d7957e1b2b12d8959526a5fc10d92e46926e94dab1ca3d62eb583bbb36498f99bbd3e11689
6
+ metadata.gz: 5d50c9b36f4a69a431620404b333b71c8fd9ca2fd8a6b2689c6ece3da57198de4cfa294adaf631238ca1186581eaa3b74a9ec8dea6e6f50f69a977a78ea71a79
7
+ data.tar.gz: 3f201c437eee80beac09bb76f121542f7c611b68ce513545fb46d6c44790cf061527564e5f9c03e4f55e51c70c67e355802d0e63e64004d4db36de135f110750
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.1)
5
5
  async-pool (~> 0.3)
6
6
  async-websocket (~> 0.19)
7
7
  oj (~> 3.13)
@@ -21,14 +21,14 @@ 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.58.0)
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
34
  async-pool (0.3.10)
@@ -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
@@ -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?
@@ -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.1"
5
5
  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.1
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-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-pool