pitrou commented on code in PR #43834:
URL: https://github.com/apache/arrow/pull/43834#discussion_r1736275071
##########
cpp/src/arrow/integration/json_integration_test.cc:
##########
@@ -148,6 +162,48 @@ static Status ValidateFull(const RecordBatch& batch) {
return Status::OK();
}
+static Status ValidateEmbeddedStream(
+ const std::shared_ptr<io::RandomAccessFile>& arrow_file,
+ const Schema& footer_schema) {
+ // Many validations are skipped here since they will already
+ // have been handled by RecordBatchFileReader.
+ // For example we already know that the magic is in place.
+ ARROW_ASSIGN_OR_RAISE(int64_t file_size, arrow_file->GetSize());
+ ARROW_ASSIGN_OR_RAISE(auto footer_cookie, arrow_file->ReadAt(file_size - 10,
10));
+ auto footer_size =
+
bit_util::FromLittleEndian(util::SafeLoadAs<int32_t>(footer_cookie->data()));
+ int64_t footer_offset = 8 + file_size - footer_size - 10;
Review Comment:
The `8 +` is a bit cryptic. I realize it accounts for the 8-byte padded
magic at the start of file, but a comment would make this easier to understand.
Or perhaps you can change the checks to something like:
```c++
// The footer is followed by the 10-byte footer length + magic
const int64_t footer_offset = file_size - footer_size - 10;
// Make sure the stream ends before the footer
ARROW_ASSIGN_OR_RAISE(const int64_t stream_size, stream->Tell());
const int64_t stream_end_offset = stream_size + 8;
if (stream_end_offset > footer_offset) {
```
--
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]