Github user AnatoliShein commented on a diff in the pull request:

    https://github.com/apache/orc/pull/134#discussion_r125674828
  
    --- Diff: c++/src/OrcHdfsFile.cc ---
    @@ -121,39 +116,24 @@ namespace orc {
         }
     
         uint64_t getNaturalReadSize() const override {
    -      return BUF_SIZE;
    +      return 1048576; //1 MB
         }
     
         void read(void* buf,
                   uint64_t length,
                   uint64_t offset) override {
     
    -      ssize_t total_bytes_read = 0;
           size_t last_bytes_read = 0;
     
           if (!buf) {
             throw ParseError("Buffer is null");
           }
     
           hdfs::Status status;
    -      char input_buffer[BUF_SIZE];
    -      do{
    -        //Reading file chunks
    -        status = file->PositionRead(input_buffer, sizeof(input_buffer), 
offset, &last_bytes_read);
    -        if(status.ok()) {
    -          //Writing file chunks to buf
    -          if(total_bytes_read + last_bytes_read >= length){
    -            memcpy((char*) buf + total_bytes_read, input_buffer, length - 
total_bytes_read);
    -            break;
    -          } else {
    -            memcpy((char*) buf + total_bytes_read, input_buffer, 
last_bytes_read);
    -            total_bytes_read += last_bytes_read;
    -            offset += last_bytes_read;
    -          }
    -        } else {
    -          throw ParseError("Error reading the file: " + status.ToString());
    -        }
    -      } while (true);
    +      status = file->PositionRead(buf, static_cast<size_t>(length), 
static_cast<off_t>(offset), &last_bytes_read);
    --- End diff --
    
    This makes sense. I just added a loop here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to