[ 
https://issues.apache.org/jira/browse/ARROW-2118?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16395447#comment-16395447
 ] 

ASF GitHub Bot commented on ARROW-2118:
---------------------------------------

cpcloud commented on a change in pull request #1735: ARROW-2118: [C++] Fix 
misleading error when memory mapping a zero-length file
URL: https://github.com/apache/arrow/pull/1735#discussion_r173854438
 
 

 ##########
 File path: cpp/src/arrow/io/file.cc
 ##########
 @@ -624,16 +624,22 @@ class MemoryMappedFile::MemoryMap : public MutableBuffer 
{
       is_mutable_ = false;
     }
 
-    void* result = mmap(nullptr, static_cast<size_t>(file_->size()), 
prot_flags, map_mode,
-                        file_->fd(), 0);
-    if (result == MAP_FAILED) {
-      std::stringstream ss;
-      ss << "Memory mapping file failed, errno: " << errno;
-      return Status::IOError(ss.str());
+    size_ = file_->size();
+
+    void* result = nullptr;
+
+    // Memory mapping fails when file size is 0
+    if (size_ > 0) {
+      result =
+          mmap(nullptr, static_cast<size_t>(size_), prot_flags, map_mode, 
file_->fd(), 0);
+      if (result == MAP_FAILED) {
+        std::stringstream ss;
+        ss << "Memory mapping file failed, errno: " << errno;
 
 Review comment:
   That's in the `<cstring>` header.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> [Python] Improve error message when calling parquet.read_table on an empty 
> file
> -------------------------------------------------------------------------------
>
>                 Key: ARROW-2118
>                 URL: https://issues.apache.org/jira/browse/ARROW-2118
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: Python
>            Reporter: Wes McKinney
>            Assignee: Wes McKinney
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 0.9.0
>
>
> Currently it raises an exception about memory mapping failing



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to