You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@orc.apache.org by GitBox <gi...@apache.org> on 2021/04/12 14:47:19 UTC

[GitHub] [orc] boroknagyz opened a new pull request #682: ORC-781: [C++] Make type annotations available from C++

boroknagyz opened a new pull request #682:
URL: https://github.com/apache/orc/pull/682


   ORC-522 added support for type annotations, but only to the Java ORC
   library. This patch adds support for type annotations for the C++
   ORC library.
   
   Both reads and writes are supported. orc-metadata now also prints out
   the type attriburtes.
   
   Testing
    * added unit tests in TestAttributes.cc
    * added unit test to TestFileMetadata.cc
   
   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. File a JIRA issue first and use it as a prefix of your PR title, e.g., `ORC-001: Fix ABC`.
     2. Use your PR title to summarize what this PR proposes instead of describing the problem.
     3. Make PR title and description complete because these will be the permanent commit log.
     4. If possible, provide a concise and reproducible example to reproduce the issue for a faster review.
     5. If the PR is unfinished, use GitHub PR Draft feature.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If there is a discussion in the mailing list, please add the link.
   -->
   
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   -->
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [orc] wgtmac merged pull request #682: ORC-781: [C++] Make type annotations available from C++

Posted by GitBox <gi...@apache.org>.
wgtmac merged pull request #682:
URL: https://github.com/apache/orc/pull/682


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [orc] boroknagyz commented on a change in pull request #682: ORC-781: [C++] Make type annotations available from C++

Posted by GitBox <gi...@apache.org>.
boroknagyz commented on a change in pull request #682:
URL: https://github.com/apache/orc/pull/682#discussion_r615973103



##########
File path: c++/include/orc/Type.hh
##########
@@ -58,6 +58,11 @@ namespace orc {
     virtual uint64_t getMaximumLength() const = 0;
     virtual uint64_t getPrecision() const = 0;
     virtual uint64_t getScale() const = 0;
+    virtual Type& setAttribute(const std::string& key,

Review comment:
       This allows method chaining. I've followed the Java implementation:
   https://github.com/apache/orc/blob/f381f2dd78e6b305b8a4e0b07124034de72ef1a1/java/core/src/java/org/apache/orc/TypeDescription.java#L242-L252
   But I can switch to void if you prefer that.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [orc] wgtmac commented on pull request #682: ORC-781: [C++] Make type annotations available from C++

Posted by GitBox <gi...@apache.org>.
wgtmac commented on pull request #682:
URL: https://github.com/apache/orc/pull/682#issuecomment-820516204


   > The Java test failure seems unrelated to my change. @wgtmac, could you please take a look at this change?
   
   Thanks for pinging me. I will take a look shortly.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [orc] boroknagyz commented on a change in pull request #682: ORC-781: [C++] Make type annotations available from C++

Posted by GitBox <gi...@apache.org>.
boroknagyz commented on a change in pull request #682:
URL: https://github.com/apache/orc/pull/682#discussion_r615971579



##########
File path: c++/src/TypeImpl.cc
##########
@@ -121,6 +121,32 @@ namespace orc {
     return scale;
   }
 
+  Type& TypeImpl::setAttribute(const std::string& key,
+                     const std::string& value) {
+    attributes[key] = value;
+    return *this;
+  }
+
+  Type& TypeImpl::removeAttribute(const std::string& key) {
+    attributes.erase(key);
+    return *this;
+  }
+
+  std::vector<std::string> TypeImpl::getAttributeKeys() const {
+    std::vector<std::string> ret;
+    ret.reserve(attributes.size());
+    for (auto& attribute : attributes) {
+      ret.push_back(attribute.first);
+    }
+    return ret;
+  }
+
+  std::string TypeImpl::getAttributeValue(const std::string& key) const {

Review comment:
       I've added hasAttributeKey() to Type, and throw std::range_error in removeAttribute() and getAttributeValue() when key is not present




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [orc] boroknagyz commented on pull request #682: ORC-781: [C++] Make type annotations available from C++

Posted by GitBox <gi...@apache.org>.
boroknagyz commented on pull request #682:
URL: https://github.com/apache/orc/pull/682#issuecomment-823263774


   Thanks for the review @wgtmac! Could you please merge this PR?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [orc] wgtmac commented on a change in pull request #682: ORC-781: [C++] Make type annotations available from C++

Posted by GitBox <gi...@apache.org>.
wgtmac commented on a change in pull request #682:
URL: https://github.com/apache/orc/pull/682#discussion_r614643081



##########
File path: c++/include/orc/Type.hh
##########
@@ -58,6 +58,11 @@ namespace orc {
     virtual uint64_t getMaximumLength() const = 0;
     virtual uint64_t getPrecision() const = 0;
     virtual uint64_t getScale() const = 0;
+    virtual Type& setAttribute(const std::string& key,

Review comment:
       What's the benefit to make return type as Type& for setAttribute() and removeAttribute() ? Is it better to make it void?

##########
File path: c++/src/TypeImpl.cc
##########
@@ -121,6 +121,32 @@ namespace orc {
     return scale;
   }
 
+  Type& TypeImpl::setAttribute(const std::string& key,
+                     const std::string& value) {
+    attributes[key] = value;
+    return *this;
+  }
+
+  Type& TypeImpl::removeAttribute(const std::string& key) {
+    attributes.erase(key);
+    return *this;
+  }
+
+  std::vector<std::string> TypeImpl::getAttributeKeys() const {
+    std::vector<std::string> ret;
+    ret.reserve(attributes.size());
+    for (auto& attribute : attributes) {
+      ret.push_back(attribute.first);
+    }
+    return ret;
+  }
+
+  std::string TypeImpl::getAttributeValue(const std::string& key) const {

Review comment:
       I'd prefer to add a new interface`bool hasAttributeKey(const std::string& key) const` to check existence and throw here if the key does not exist.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [orc] boroknagyz commented on pull request #682: ORC-781: [C++] Make type annotations available from C++

Posted by GitBox <gi...@apache.org>.
boroknagyz commented on pull request #682:
URL: https://github.com/apache/orc/pull/682#issuecomment-819531141


   The Java test failure seems unrelated to my change. @wgtmac, could you please take a look at this change?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org