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

ASF GitHub Bot commented on ORC-431:
------------------------------------

xndai closed pull request #334: ORC-431: [C++] Fix typo in exception message 
and simplify code logic.
URL: https://github.com/apache/orc/pull/334
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/c++/src/Writer.cc b/c++/src/Writer.cc
index 621876927b..9a7a777cc2 100644
--- a/c++/src/Writer.cc
+++ b/c++/src/Writer.cc
@@ -135,7 +135,7 @@ namespace orc {
       privateBits->fileVersion = version;
       return *this;
     }
-    throw std::logic_error("Unpoorted file version specified.");
+    throw std::logic_error("Unsupported file version specified.");
   }
 
   FileVersion WriterOptions::getFileVersion() const {
@@ -571,7 +571,8 @@ namespace orc {
     *footer.add_types() = protoType;
 
     for (uint64_t i = 0; i < t.getSubtypeCount(); ++i) {
-      if (t.getKind() != LIST && t.getKind() != MAP && t.getKind() != UNION) {
+      // only add subtypes' field names if this type is STRUCT
+      if (t.getKind() == STRUCT) {
         footer.mutable_types(pos)->add_fieldnames(t.getFieldName(i));
       }
       footer.mutable_types(pos)->add_subtypes(++index);
diff --git a/c++/src/io/OutputStream.cc b/c++/src/io/OutputStream.cc
index be8ea4f85c..fd71c4b86f 100644
--- a/c++/src/io/OutputStream.cc
+++ b/c++/src/io/OutputStream.cc
@@ -51,7 +51,7 @@ namespace orc {
       newCapacity += dataBuffer->capacity();
     }
     dataBuffer->reserve(newCapacity);
-    dataBuffer->resize(dataBuffer->size() + blockSize);
+    dataBuffer->resize(newSize);
     *buffer = dataBuffer->data() + oldSize;
     return true;
   }
@@ -92,7 +92,7 @@ namespace orc {
 
   uint64_t BufferedOutputStream::flush() {
     uint64_t dataSize = dataBuffer->size();
-    outputStream->write(dataBuffer->data(), dataBuffer->size());
+    outputStream->write(dataBuffer->data(), dataSize);
     dataBuffer->resize(0);
     return dataSize;
   }


 

----------------------------------------------------------------
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]


> Fix typo in exception message and simplify code logic
> -----------------------------------------------------
>
>                 Key: ORC-431
>                 URL: https://issues.apache.org/jira/browse/ORC-431
>             Project: ORC
>          Issue Type: Improvement
>          Components: C++
>            Reporter: Fang Zheng
>            Priority: Minor
>
> 1. Fix typo in the exception message in WriterOptions::setFileVersion(): 
> "Unpoorted" should be "Unsupported".
> 2. Simplify some code in Writer.cc and OutputStream.cc to avoid 
> re-computation.
> 3. Simplify a condition check in WriterImpl::buildFooterType().



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

Reply via email to