You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/11/10 12:36:22 UTC
[GitHub] [arrow] paleolimbot commented on a change in pull request #11613: ARROW-14464: [R] Change write_parquet()'s default chunk_size from all rows
paleolimbot commented on a change in pull request #11613:
URL: https://github.com/apache/arrow/pull/11613#discussion_r746544188
##########
File path: r/R/parquet.R
##########
@@ -196,7 +196,27 @@ write_parquet <- function(x,
allow_truncated_timestamps = allow_truncated_timestamps
)
)
- writer$WriteTable(x, chunk_size = chunk_size %||% x$num_rows)
+
+ # determine an approximate chunk size
+ if (is.null(chunk_size)) {
+ num_cells <- x$num_rows * x$num_columns
+ target_cells_per_group <- getOption("arrow.parquet_cells_per_group", 2.5e8)
+
+ if (num_cells < target_cells_per_group) {
+ # If the total number of cells is less than the 2.5 million, we want one group
+ num_chunks <- 1
+ } else {
+ # no more than 2.5 million cells (rows * cols) per group
+ num_chunks <- num_cells / target_cells_per_group
+ }
+
+ # but there are no more than 200 chunks
+ num_chunks <- min(num_chunks, getOption("arrow.parquet_max_chunks", 200))
+
+ chunk_size <- x$num_rows / num_chunks
+ }
+
+ writer$WriteTable(x, chunk_size = chunk_size)
Review comment:
I imagine this is already taken care of in the C++ somehow but I would expected something like:
``` r
on.exit(writer$Close())
writer$WriteTable(x, chunk_size = chunk_size)
```
...to clean up the writer as soon as possible in case `WriteTable` errors.
##########
File path: r/R/parquet.R
##########
@@ -196,7 +196,27 @@ write_parquet <- function(x,
allow_truncated_timestamps = allow_truncated_timestamps
)
)
- writer$WriteTable(x, chunk_size = chunk_size %||% x$num_rows)
+
+ # determine an approximate chunk size
+ if (is.null(chunk_size)) {
+ num_cells <- x$num_rows * x$num_columns
+ target_cells_per_group <- getOption("arrow.parquet_cells_per_group", 2.5e8)
Review comment:
In the comment below you say 2.5 million...this would be `2.5e6` instead of `2.5e8`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org