sunchao commented on code in PR #7787:
URL: https://github.com/apache/datafusion-comet/pull/7787#discussion_r4735271068
##########
native/shuffle/src/spark_unsafe/row.rs:
##########
@@ -1245,6 +1245,27 @@ impl<'a> SortedRowEncoder<'a> {
}
}
+/// The bytes one batch's rows may add up to. Arrow indexes the values of a
string or binary
+/// column with `i32` offsets, and a row's size bounds the bytes it adds to
any one column,
+/// including strings nested in arrays, maps and structs. Each Arrow buffer is
also no larger than
+/// the part of the rows it comes from, so the batch's encoded block stays
close to its row bytes.
+/// The reader rejects a block past `Integer.MAX_VALUE` bytes
(`NativeBatchDecoderIterator`), and
+/// data that does not compress, or the `none` codec, keeps a block that
large, so the budget
+/// leaves half of that as headroom rather than stopping at `i32::MAX`.
+const MAX_BATCH_ROW_BYTES: usize = 1 << 30;
Review Comment:
`get_string` can turn one invalid byte into three UTF-8 bytes (`U+FFFD`).
Spark can produce such strings with a binary-to-string cast. I reproduced `byte
array offset overflow` with 8,192 distinct 96 KiB strings filled with `0xff`
except for an 8-digit ASCII row ID. The rows fit in about 768 MiB, but the
dictionary values exceed 2 GiB before compression. Could we budget for up to 3×
expansion for schemas containing strings, including nested strings, and check
oversized single rows before appending? A small injected limit would work for
the regression test.
##########
native/shuffle/src/spark_unsafe/row.rs:
##########
@@ -1245,6 +1245,27 @@ impl<'a> SortedRowEncoder<'a> {
}
}
+/// The bytes one batch's rows may add up to. Arrow indexes the values of a
string or binary
+/// column with `i32` offsets, and a row's size bounds the bytes it adds to
any one column,
+/// including strings nested in arrays, maps and structs. Each Arrow buffer is
also no larger than
Review Comment:
The whole IPC block can grow by more than 2× even without strings. I tried
8,192 rows, each with an array of 10,000 null structs with four `BIGINT`
fields. Spark uses one slot per null element. Arrow allocates a slot in each of
the four child arrays. With compression off, `ShuffleBlockWriter` rejected a
2,672,673,620-byte block from 665,845,760 bytes of rows. Could we split and
retry oversized multi-row blocks before updating the checksum or writing them
out? If that’s a separate fix, please narrow this size claim and track the
block limit separately.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]