You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/04/01 16:06:00 UTC

[jira] [Commented] (AVRO-1702) Add LogicalType support to c++ library

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

ASF GitHub Bot commented on AVRO-1702:
--------------------------------------

thiru-apache commented on a change in pull request #302: AVRO-1702: Added support for logical types in the C++ client.
URL: https://github.com/apache/avro/pull/302#discussion_r178462083
 
 

 ##########
 File path: lang/c++/impl/Compiler.cc
 ##########
 @@ -327,6 +338,50 @@ static NodePtr makeRecordNode(const Entity& e,
         fieldValues, fieldNames, defaultValues));
 }
 
+static LogicalType makeLogicalType(const Entity& e, const Object& m) {
+    if (!containsField(e, m, "logicalType")) {
+        return LogicalType(LogicalType::NONE);
+    }
+
+    const std::string& typeField = getStringField(e, m, "logicalType");
+
+    if (typeField == "decimal") {
+        LogicalType decimalType(LogicalType::DECIMAL);
+        try {
+            decimalType.setPrecision(getLongField(e, m, "precision"));
+            if (containsField(e, m, "scale")) {
+                decimalType.setScale(getLongField(e, m, "scale"));
+            }
+        } catch (Exception& ex) {
+            // If any part of the logical type is malformed, per the standard we
+            // must ignore the whole attribute.
+            return LogicalType(LogicalType::NONE);
+        }
+        return decimalType;
+    }
+    if (typeField == "date") {
 
 Review comment:
   I think this will save some code and become more readable if we do something like:
   
       LogicalType::Type t = LogicalType::NONE;
       if (typeField == "date") {
           t = LogicalType::DATE;
       else if (typeField == "time-millis") {
           t = LogicalType::TIME_MILLIS;
      else if ... {
      }
      return LogicalType(t);

----------------------------------------------------------------
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:
users@infra.apache.org


> Add LogicalType support to c++ library
> --------------------------------------
>
>                 Key: AVRO-1702
>                 URL: https://issues.apache.org/jira/browse/AVRO-1702
>             Project: Avro
>          Issue Type: New Feature
>          Components: c++
>            Reporter: peter liu
>            Assignee: peter liu
>            Priority: Major
>
> I'd like to port the logicaltype support to c++ library



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