parquet 0.8.0-aarch64-linux → 0.9.0-aarch64-linux
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 +4 -4
- data/README.md +132 -11
- data/lib/parquet/3.2/parquet.so +0 -0
- data/lib/parquet/3.3/parquet.so +0 -0
- data/lib/parquet/3.4/parquet.so +0 -0
- data/lib/parquet/4.0/parquet.so +0 -0
- data/lib/parquet/version.rb +1 -1
- data/lib/parquet.rbi +65 -8
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 06deeee590e4572ff7d4b302597e26804ca0a7dc4a8eccfd7687f926276a5ef7
|
|
4
|
+
data.tar.gz: 5514690113ee28379aa505d49ee88cd0e806ad8f4fb7e442c3ffef6e0d36305c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e68aced5c5b45ae7dbcd5f3b8215817c10a0cc72379044523895870e3e164a4212fd24d34b9eca9e7913d3f6ff8f43c040ac3d3094a0af955b4353a710db38e2
|
|
7
|
+
data.tar.gz: 44998090036e3de92c39f2418ccb68369564209e2a3d165405fa56e14d96b1b283aa3e3980cd5880c861e578b1fb90f0332412ee472669e09ad5f2256af11d6c
|
data/README.md
CHANGED
|
@@ -145,6 +145,33 @@ puts metadata["row_groups"].size # Number of row groups
|
|
|
145
145
|
|
|
146
146
|
## Writing Parquet Files
|
|
147
147
|
|
|
148
|
+
`write_rows` and `write_columns` stream an enumerable to a path or writable IO
|
|
149
|
+
and return `nil`. Each row is an array in schema order. For column writing, each
|
|
150
|
+
yielded batch contains one array per field, all of the same length.
|
|
151
|
+
|
|
152
|
+
Both methods require `schema:` and `write_to:`. `schema:` accepts the array form
|
|
153
|
+
shown below, a `Parquet::Schema` DSL result, or a `fields` schema hash. Use `nil`
|
|
154
|
+
or `[]` to infer string columns named `f0`, `f1`, ... from the first row or
|
|
155
|
+
batch. Empty input requires an explicit schema.
|
|
156
|
+
|
|
157
|
+
`compression:` accepts `"none"`, `"uncompressed"`, `"snappy"`, `"gzip"`,
|
|
158
|
+
`"lz4"`, `"zstd"`, and `"brotli"`; `nil` defaults to Snappy.
|
|
159
|
+
`flush_threshold:` defaults to 100 MiB. `logger:` accepts a Ruby logger with
|
|
160
|
+
`debug`, `info`, `warn`, and `error` methods.
|
|
161
|
+
|
|
162
|
+
`write_rows` also accepts `batch_size:`, `sample_size:`, and `string_cache:`.
|
|
163
|
+
Without `batch_size:`, sizing starts at 1,000 rows and adapts to row size; the
|
|
164
|
+
cap is 1,000,000 rows and lower for wide schemas. Sampling defaults to 100 rows
|
|
165
|
+
and is capped at 10,000. `string_cache: true` uses a capacity of 100, or you can
|
|
166
|
+
pass a capacity up to 65,536; `nil` and `false` disable it.
|
|
167
|
+
|
|
168
|
+
Path output is staged and atomically published only after the complete file has
|
|
169
|
+
been written. On Unix, replacing an existing path preserves its uid, gid, and
|
|
170
|
+
mode and uses standard last-committer-wins rename semantics; creating a path is
|
|
171
|
+
no-clobber. Extended attributes and ACLs are not preserved. IO output is first
|
|
172
|
+
staged on disk, then copied to the IO; a failed copy may leave the IO partially
|
|
173
|
+
written.
|
|
174
|
+
|
|
148
175
|
### Row-wise Writing
|
|
149
176
|
|
|
150
177
|
Best for: Streaming data, converting from other formats, memory-constrained environments
|
|
@@ -159,17 +186,109 @@ schema = [
|
|
|
159
186
|
]
|
|
160
187
|
|
|
161
188
|
# Stream data from any enumerable
|
|
162
|
-
rows = CSV.foreach("input.csv").map do |row|
|
|
189
|
+
rows = CSV.foreach("input.csv").lazy.map do |row|
|
|
163
190
|
[row[0].to_i, row[1], row[2] == "true", row[3].to_f]
|
|
164
191
|
end
|
|
165
192
|
|
|
166
193
|
Parquet.write_rows(rows,
|
|
167
194
|
schema: schema,
|
|
168
195
|
write_to: "output.parquet",
|
|
169
|
-
batch_size: 5000
|
|
196
|
+
batch_size: 5000
|
|
197
|
+
)
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Repacking Existing Parquet Files
|
|
201
|
+
|
|
202
|
+
Concatenate Parquet files and re-split them into differently sized files without
|
|
203
|
+
translating rows through Ruby.
|
|
204
|
+
|
|
205
|
+
```ruby
|
|
206
|
+
Parquet.repack(
|
|
207
|
+
["input-0.parquet", "input-1.parquet"],
|
|
208
|
+
output_dir: "repacked",
|
|
209
|
+
rows_per_file: 100_000
|
|
170
210
|
)
|
|
211
|
+
# => [{ "path" => "repacked/batch-0.parquet", "num_rows" => 100_000 },
|
|
212
|
+
# { "path" => "repacked/batch-1.parquet", "num_rows" => 42_137 }]
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
The outputs hold exactly the input rows, in input order. Every output but the
|
|
216
|
+
last holds `rows_per_file` rows, and there is always at least one output even
|
|
217
|
+
when the inputs are empty. Omit `rows_per_file:` to concatenate everything into
|
|
218
|
+
a single file.
|
|
219
|
+
|
|
220
|
+
Each output's Parquet schema is identical to the first input's, and that input's
|
|
221
|
+
file-level key/value metadata (`ARROW:schema`, `pandas`, and so on) is carried
|
|
222
|
+
over. Inputs must agree on leaf column shape — path, physical and logical type,
|
|
223
|
+
nesting — but may differ in key/value metadata and Parquet field ids.
|
|
224
|
+
|
|
225
|
+
#### Compression and copying
|
|
226
|
+
|
|
227
|
+
With no `compression:`, each column keeps its own codec — Parquet records one
|
|
228
|
+
per column, and a file may legitimately use several. Naming a codec applies it
|
|
229
|
+
to every column instead:
|
|
230
|
+
|
|
231
|
+
```ruby
|
|
232
|
+
Parquet.repack("input.parquet", output_dir: "out", compression: "zstd")
|
|
171
233
|
```
|
|
172
234
|
|
|
235
|
+
Keeping the inputs' codecs also lets repack copy whole row groups into the
|
|
236
|
+
output byte-for-byte, skipping decompression and re-encoding entirely. A row
|
|
237
|
+
group is copied when it fits the output's remaining row budget, is large enough
|
|
238
|
+
to be worth copying, and the request did not ask for a different codec;
|
|
239
|
+
otherwise its rows are decoded and re-encoded. Both routes produce the same
|
|
240
|
+
rows, so which one runs is not something callers need to reason about — but the
|
|
241
|
+
copy route is dramatically faster, so a plain concatenation is close to an
|
|
242
|
+
I/O-bound copy.
|
|
243
|
+
|
|
244
|
+
Small row groups are deliberately merged rather than copied: copying them
|
|
245
|
+
one-for-one would make a compaction of many small files reproduce exactly the
|
|
246
|
+
fragmentation it was meant to remove.
|
|
247
|
+
|
|
248
|
+
#### Output directory ownership
|
|
249
|
+
|
|
250
|
+
`repack` owns the `{output_file_prefix}-{n}.parquet` names in `output_dir`. If
|
|
251
|
+
any already exist it raises `ArgumentError` rather than mixing two runs' files
|
|
252
|
+
in one directory:
|
|
253
|
+
|
|
254
|
+
```ruby
|
|
255
|
+
Parquet.repack("input.parquet", output_dir: "out", rows_per_file: 1000, overwrite: true)
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
`overwrite: true` replaces that set and deletes members left over from a longer
|
|
259
|
+
earlier run, so the returned list always equals what a reader finds in the
|
|
260
|
+
directory. Files outside the set are never touched.
|
|
261
|
+
|
|
262
|
+
#### Bounds
|
|
263
|
+
|
|
264
|
+
`max_read_rows_per_chunk:` (default 8192, reduced for wide schemas) bounds rows
|
|
265
|
+
buffered while reading; output row groups are bounded in rows by the same slot
|
|
266
|
+
budget. Both are resource controls: varying them cannot change the returned
|
|
267
|
+
list, the rows, the schema, or the codecs. They do shift compressed byte counts
|
|
268
|
+
and page boundaries, which are representation rather than contract.
|
|
269
|
+
|
|
270
|
+
Input metadata is read one file at a time, so peak memory is set by the widest
|
|
271
|
+
single file and its row-group size, not by how many files you pass or how many
|
|
272
|
+
rows they hold in total. Note that the row-group bound is in rows, not bytes: a
|
|
273
|
+
schema with very large values still buffers one row group's worth of encoded
|
|
274
|
+
data.
|
|
275
|
+
|
|
276
|
+
Reading and writing run with the GVL released, so other Ruby threads keep
|
|
277
|
+
running and `Interrupt` / `Timeout` are honoured. An interrupted call leaves no
|
|
278
|
+
output behind.
|
|
279
|
+
|
|
280
|
+
A repacked output is capped at 32,767 row groups. Merging small groups keeps
|
|
281
|
+
that limit out of reach in practice; if a single output would exceed it,
|
|
282
|
+
repack raises rather than writing an unreadable file, and `rows_per_file:` is
|
|
283
|
+
the way out.
|
|
284
|
+
|
|
285
|
+
#### Page indexes and other optional structures
|
|
286
|
+
|
|
287
|
+
Every row group in a Parquet file must agree on whether it carries a page index,
|
|
288
|
+
and a copied row group can only contribute the index its source had. So an
|
|
289
|
+
output carries one exactly when every contributing input does. Bloom filters are
|
|
290
|
+
not carried over on either route.
|
|
291
|
+
|
|
173
292
|
### Column-wise Writing
|
|
174
293
|
|
|
175
294
|
Best for: Pre-columnar data, better compression, higher performance
|
|
@@ -196,13 +315,10 @@ schema = [
|
|
|
196
315
|
Parquet.write_columns(batches.each,
|
|
197
316
|
schema: schema,
|
|
198
317
|
write_to: "output.parquet",
|
|
199
|
-
compression: "snappy"
|
|
318
|
+
compression: "snappy"
|
|
200
319
|
)
|
|
201
320
|
```
|
|
202
321
|
|
|
203
|
-
`write_columns` also accepts `logger:` with the same Ruby logger interface as
|
|
204
|
-
row writes.
|
|
205
|
-
|
|
206
322
|
## Data Types
|
|
207
323
|
|
|
208
324
|
### Basic Types
|
|
@@ -385,14 +501,19 @@ Control memory usage with flush thresholds:
|
|
|
385
501
|
Parquet.write_rows(huge_dataset.each,
|
|
386
502
|
schema: schema,
|
|
387
503
|
write_to: "output.parquet",
|
|
388
|
-
batch_size:
|
|
389
|
-
flush_threshold: 32 * 1024**2
|
|
504
|
+
batch_size: 1_000,
|
|
505
|
+
flush_threshold: 32 * 1024**2 # 32 MiB
|
|
390
506
|
)
|
|
391
507
|
```
|
|
392
508
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
509
|
+
Writer-owned memory stays bounded as the file grows. `flush_threshold` controls
|
|
510
|
+
the converted-value buffer; a single larger row may exceed it temporarily. The
|
|
511
|
+
row-group target is at least 8 MiB, and each file may contain up to 32,768 row
|
|
512
|
+
groups.
|
|
513
|
+
|
|
514
|
+
Encoded data and completed row-group metadata are staged on disk, so large
|
|
515
|
+
writes need temporary disk space. Ruby still owns the current row or batch, and
|
|
516
|
+
an in-memory destination such as `StringIO` holds the output in memory.
|
|
396
517
|
|
|
397
518
|
## Architecture
|
|
398
519
|
|
data/lib/parquet/3.2/parquet.so
CHANGED
|
Binary file
|
data/lib/parquet/3.3/parquet.so
CHANGED
|
Binary file
|
data/lib/parquet/3.4/parquet.so
CHANGED
|
Binary file
|
data/lib/parquet/4.0/parquet.so
CHANGED
|
Binary file
|
data/lib/parquet/version.rb
CHANGED
data/lib/parquet.rbi
CHANGED
|
@@ -90,7 +90,8 @@ module Parquet
|
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
# Options:
|
|
93
|
-
# - `read_from`: An
|
|
93
|
+
# - `read_from`: An Enumerable yielding arrays of values representing each row. The outer
|
|
94
|
+
# enumerable is pulled incrementally and is never materialized with `to_a`.
|
|
94
95
|
# - `schema`: Array of hashes specifying column names and types. Supported types:
|
|
95
96
|
# - `int8`, `int16`, `int32`, `int64`
|
|
96
97
|
# - `uint8`, `uint16`, `uint32`, `uint64`
|
|
@@ -103,8 +104,9 @@ module Parquet
|
|
|
103
104
|
# - `write_to`: String path or IO object to write the parquet file to
|
|
104
105
|
# - `batch_size`: Optional positive batch size for writing (defaults to 1000, at most 1_000_000
|
|
105
106
|
# for one-column schemas; wide schemas may have a lower safety cap)
|
|
106
|
-
# - `flush_threshold`: Optional
|
|
107
|
-
#
|
|
107
|
+
# - `flush_threshold`: Optional positive byte quantum for converted native values (defaults
|
|
108
|
+
# to 100MB). One larger row is written alone. Encoded row groups use this
|
|
109
|
+
# value with an 8MB minimum; completed footer metadata is disk-spooled.
|
|
108
110
|
# - `compression`: Optional compression type to use (defaults to "zstd")
|
|
109
111
|
# Supported values: "none", "uncompressed", "snappy", "gzip", "lz4", "zstd"
|
|
110
112
|
# - `sample_size`: Optional positive number of rows to sample for size estimation
|
|
@@ -116,7 +118,7 @@ module Parquet
|
|
|
116
118
|
# cached string content.
|
|
117
119
|
sig do
|
|
118
120
|
params(
|
|
119
|
-
read_from: T::
|
|
121
|
+
read_from: T::Enumerable[T::Array[T.untyped]],
|
|
120
122
|
schema: T::Array[T::Hash[String, String]],
|
|
121
123
|
write_to: T.any(String, IO),
|
|
122
124
|
batch_size: T.nilable(Integer),
|
|
@@ -139,7 +141,8 @@ module Parquet
|
|
|
139
141
|
end
|
|
140
142
|
|
|
141
143
|
# Options:
|
|
142
|
-
# - `read_from`: An
|
|
144
|
+
# - `read_from`: An Enumerable yielding arrays of column batches. Batches are validated and
|
|
145
|
+
# consumed one at a time; all columns in each batch must have equal length.
|
|
143
146
|
# - `schema`: Array of hashes specifying column names and types. Supported types:
|
|
144
147
|
# - `int8`, `int16`, `int32`, `int64`
|
|
145
148
|
# - `uint8`, `uint16`, `uint32`, `uint64`
|
|
@@ -151,14 +154,15 @@ module Parquet
|
|
|
151
154
|
# - `timestamp_millis`, `timestamp_micros`
|
|
152
155
|
# - Looks like [{"column_name" => {"type" => "date32", "format" => "%Y-%m-%d"}}, {"column_name" => "int8"}]
|
|
153
156
|
# - `write_to`: String path or IO object to write the parquet file to
|
|
154
|
-
# - `flush_threshold`: Optional
|
|
155
|
-
#
|
|
157
|
+
# - `flush_threshold`: Optional positive byte quantum for converted native values (defaults
|
|
158
|
+
# to 100MB). One larger row is written alone. Encoded row groups use this
|
|
159
|
+
# value with an 8MB minimum; completed footer metadata is disk-spooled.
|
|
156
160
|
# - `compression`: Optional compression type to use (defaults to "zstd")
|
|
157
161
|
# Supported values: "none", "uncompressed", "snappy", "gzip", "lz4", "zstd"
|
|
158
162
|
# - `logger`: Optional Ruby logger for column-write progress messages
|
|
159
163
|
sig do
|
|
160
164
|
params(
|
|
161
|
-
read_from: T::
|
|
165
|
+
read_from: T::Enumerable[T::Array[T::Array[T.untyped]]],
|
|
162
166
|
schema: T::Array[T::Hash[String, String]],
|
|
163
167
|
write_to: T.any(String, IO),
|
|
164
168
|
flush_threshold: T.nilable(Integer),
|
|
@@ -175,4 +179,57 @@ module Parquet
|
|
|
175
179
|
logger: nil
|
|
176
180
|
)
|
|
177
181
|
end
|
|
182
|
+
|
|
183
|
+
# Concatenates Parquet files and re-splits them into a new set of files
|
|
184
|
+
# without translating rows through Ruby. Returns one hash per output file,
|
|
185
|
+
# `{"path" => String, "num_rows" => Integer}`, in output order.
|
|
186
|
+
#
|
|
187
|
+
# The outputs hold exactly the input rows, in input order. Every output but
|
|
188
|
+
# the last holds `rows_per_file` rows; there is always at least one output,
|
|
189
|
+
# even when the inputs are empty. Each output's Parquet schema is identical
|
|
190
|
+
# to the first input's, and that input's file-level key/value metadata (such
|
|
191
|
+
# as `ARROW:schema` or `pandas`) is carried over.
|
|
192
|
+
#
|
|
193
|
+
# Inputs must agree on leaf column shape — path, physical and logical type,
|
|
194
|
+
# nesting. They may differ in key/value metadata and Parquet field ids.
|
|
195
|
+
#
|
|
196
|
+
# Options:
|
|
197
|
+
# - `read_from`: String path or array of paths to Parquet files with matching schemas
|
|
198
|
+
# - `output_dir`: Directory where {output_file_prefix}-{n}.parquet files will be written
|
|
199
|
+
# - `output_file_prefix`: Single filename component used for outputs, default "batch".
|
|
200
|
+
# Path separators and `..` are rejected.
|
|
201
|
+
# - `rows_per_file`: Optional maximum number of rows per output file. When nil, all input
|
|
202
|
+
# rows are concatenated into one file.
|
|
203
|
+
# - `max_read_rows_per_chunk`: Optional upper bound for rows read per chunk, default 8192
|
|
204
|
+
# and reduced for wide schemas. It bounds memory only; it never changes the returned
|
|
205
|
+
# list, the rows, the schema, or the codecs.
|
|
206
|
+
# - `compression`: Optional codec for the outputs. When nil each column keeps its own
|
|
207
|
+
# codec, which also lets whole row groups be copied without re-encoding.
|
|
208
|
+
# - `overwrite`: When false (default), a non-empty `{output_file_prefix}-*.parquet` set in
|
|
209
|
+
# `output_dir` raises ArgumentError. When true, that set is replaced and any files left
|
|
210
|
+
# over from a longer earlier run are removed. Files outside the set are never touched.
|
|
211
|
+
#
|
|
212
|
+
# Raises ArgumentError for an invalid request or mismatched input schemas, and
|
|
213
|
+
# IOError when an input or output cannot be read or written.
|
|
214
|
+
sig do
|
|
215
|
+
params(
|
|
216
|
+
read_from: T.any(String, T::Array[String]),
|
|
217
|
+
output_dir: String,
|
|
218
|
+
output_file_prefix: T.nilable(String),
|
|
219
|
+
rows_per_file: T.nilable(Integer),
|
|
220
|
+
max_read_rows_per_chunk: T.nilable(Integer),
|
|
221
|
+
compression: T.nilable(String),
|
|
222
|
+
overwrite: T.nilable(T::Boolean)
|
|
223
|
+
).returns(T::Array[T::Hash[String, T.any(String, Integer)]])
|
|
224
|
+
end
|
|
225
|
+
def self.repack(
|
|
226
|
+
read_from,
|
|
227
|
+
output_dir:,
|
|
228
|
+
output_file_prefix: nil,
|
|
229
|
+
rows_per_file: nil,
|
|
230
|
+
max_read_rows_per_chunk: nil,
|
|
231
|
+
compression: nil,
|
|
232
|
+
overwrite: nil
|
|
233
|
+
)
|
|
234
|
+
end
|
|
178
235
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: parquet
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: aarch64-linux
|
|
6
6
|
authors:
|
|
7
7
|
- Nathan Jaremko
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-08-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bigdecimal
|