exwiw 0.5.1 → 0.5.3

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.
data/lib/exwiw/runner.rb CHANGED
@@ -44,7 +44,7 @@ module Exwiw
44
44
  QueryAstBuilder.validate_scope!(dumpable_configs, table_by_name, @dump_target, @logger)
45
45
 
46
46
  @logger.info("Determining table processing order...")
47
- ordered_table_names = DetermineTableProcessingOrder.run(dumpable_configs)
47
+ ordered_table_names = DetermineTableProcessingOrder.run(dumpable_configs, logger: @logger)
48
48
 
49
49
  clean_output_dir!
50
50
 
@@ -97,18 +97,36 @@ module Exwiw
97
97
  else
98
98
  phase = "generating INSERT statement"
99
99
  @logger.debug(" Generate INSERT statement...")
100
- chunk_size = table.bulk_insert_chunk_size
101
- chunks = chunk_size ? results.each_slice(chunk_size).to_a : [results]
102
- insert_sql = chunks.map { |chunk_rows| adapter.to_bulk_insert(chunk_rows, table) }.join("\n")
103
-
104
- @logger.info(" Generated INSERT statement for #{record_num} records (#{chunks.size} statement(s)).")
100
+ # Stream each chunk straight to the file instead of building the whole
101
+ # table's INSERT/JSONL output as one string first. This keeps only a
102
+ # single chunk's serialized text (and its transient intermediate
103
+ # objects) in memory at a time — important for large MongoDB
104
+ # collections, whose one-giant-chunk JSONL would otherwise be held in
105
+ # full alongside the already-large in-memory result set.
106
+ #
107
+ # The chunk size falls back to the adapter's default when the table
108
+ # config does not set one (SQL adapters: nil -> one statement, as
109
+ # before; MongoDB: a positive default so the output is chunked). The
110
+ # bytes written are identical to joining the chunks with "\n" and
111
+ # appending a trailing newline, matching the previous `file.puts`.
112
+ chunk_size = table.bulk_insert_chunk_size || adapter.default_bulk_insert_chunk_size
113
+ chunks = chunk_size ? results.each_slice(chunk_size) : [results]
114
+
115
+ statement_count = 0
105
116
  File.open(File.join(@output_dir, "insert-#{insert_idx}-#{table_name}.#{adapter.output_extension}"), 'w') do |file|
106
117
  pre = adapter.pre_insert_sql(table)
107
118
  file.puts(pre) if pre
108
- file.puts(insert_sql)
119
+ chunks.each do |chunk_rows|
120
+ file.print("\n") if statement_count.positive?
121
+ file.print(adapter.to_bulk_insert(chunk_rows, table))
122
+ statement_count += 1
123
+ end
124
+ file.print("\n")
109
125
  post = adapter.post_insert_sql(table)
110
126
  file.puts(post) if post
111
127
  end
128
+
129
+ @logger.info(" Generated INSERT statement for #{record_num} records (#{statement_count} statement(s)).")
112
130
  end
113
131
 
114
132
  if adapter.supports_bulk_delete? && !@insert_only && !(table.respond_to?(:rails_managed?) && table.rails_managed?)
data/lib/exwiw/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Exwiw
4
- VERSION = "0.5.1"
4
+ VERSION = "0.5.3"
5
5
  end
data/mise.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [env]
2
- # Prepend scenario/bin so `pg_dump` resolves to the wrapper that delegates to
2
+ # Prepend e2e/bin so `pg_dump` resolves to the wrapper that delegates to
3
3
  # the postgres container (compose.yml). exwiw's PostgreSQL adapter shells out
4
4
  # to pg_dump, which requires a server/client major-version match — the dev DB
5
5
  # is postgres:17 while host clients are often older (e.g. Homebrew pg14).
6
- _.path = ["./scenario/bin"]
6
+ _.path = ["./e2e/bin"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exwiw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shia
@@ -35,12 +35,15 @@ files:
35
35
  - CHANGELOG.md
36
36
  - LICENSE.txt
37
37
  - README.md
38
+ - docs/optimization-notes.md
39
+ - docs/optimize-mongodb-export-with-native-ext.md
38
40
  - docs/plans/2026-05-15-insert-000-schema-file.md
39
41
  - docs/plans/2026-05-16-mongodb-from-clean-scenario.md
40
42
  - docs/plans/2026-05-22-after-insert-hook.md
41
43
  - docs/plans/2026-05-22-postgres-copy-mode-scenario-test.md
42
44
  - docs/plans/2026-05-29-rails-managed-tables.md
43
45
  - docs/plans/2026-05-31-ids-column-for-sql-adapters.md
46
+ - docs/plans/2026-06-19-mongodb-export-remove-parallelism-native-ext.md
44
47
  - exe/exwiw
45
48
  - lib/exwiw.rb
46
49
  - lib/exwiw/adapter.rb