avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sean Busbey (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-1847) IDL compiler uses ByteBuffer for decimal type even if logical type is supported
Date Mon, 13 Jun 2016 16:42:21 GMT

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

Sean Busbey commented on AVRO-1847:
-----------------------------------

{code}
diff --git a/lang/java/avro/src/main/java/org/apache/avro/data/RecordBuilderBase.java b/lang/java/avro/src/main/java/org/apache/avro/data/RecordBuilderBase.java
index 8e34a36..03780dd 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/data/RecordBuilderBase.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/data/RecordBuilderBase.java
...
+  /**
+   * Gets the default value of the given field, if any.
+   * @param field the field whose default value should be retrieved.
+   * @return the default value associated with the given field,
+   * or null if none is specified in the schema.
+   * @throws IOException
+   */
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  protected Object defaultValue(Field field, Conversion<?> conversion) throws IOException
{
+    Object rawDefaultValue = data.deepCopy(field.schema(), data.getDefaultValue(field));
+    if (conversion == null) {
+      return rawDefaultValue;
+    } else {
+      return Conversions.convertToLogicalType(rawDefaultValue, field.schema(), field.schema().getLogicalType(),
conversion);
+    }
+  }
{code}

If the convert to/from methods are made consistent on null conversions meaning a no-op, this
code can be simplified away.

> IDL compiler uses ByteBuffer for decimal type even if logical type is supported 
> --------------------------------------------------------------------------------
>
>                 Key: AVRO-1847
>                 URL: https://issues.apache.org/jira/browse/AVRO-1847
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.8.0
>            Reporter: Yibing Shi
>         Attachments: AVRO-1847.1.patch, AVRO-1847.2.patch, AVRO-1847.3.patch, AVRO-1847.4.patch
>
>
> Version 1.8.0 has added the support of logical types. A conversion class (Conversions.DecimalConversion)
has also been added for decimal type. However, the IDL compiler still uses ByteBuffer for
decimal types, which is not the same behaviour as data, time or timestamp type (added in AVRO-1684).




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message