in src/iceberg/arrow/arrow_fs_file_io.cc [29:52]
Result<std::string> ArrowFileSystemFileIO::ReadFile(const std::string& file_location,
std::optional<size_t> length) {
::arrow::fs::FileInfo file_info(file_location);
if (length.has_value()) {
file_info.set_size(length.value());
}
std::string content;
ICEBERG_ARROW_ASSIGN_OR_RETURN(auto file, arrow_fs_->OpenInputFile(file_info));
ICEBERG_ARROW_ASSIGN_OR_RETURN(auto file_size, file->GetSize());
content.resize(file_size);
size_t remain = file_size;
size_t offset = 0;
while (remain > 0) {
size_t read_length = std::min(remain, static_cast<size_t>(1024 * 1024));
ICEBERG_ARROW_ASSIGN_OR_RETURN(
auto read_bytes,
file->Read(read_length, reinterpret_cast<uint8_t*>(&content[offset])));
remain -= read_bytes;
offset += read_bytes;
}
return content;
}