You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2019/08/20 13:08:29 UTC

[GitHub] [drill] vvysotskyi commented on a change in pull request #1844: DRILL-7326: Support repeated lists for CTAS parquet format

vvysotskyi commented on a change in pull request #1844: DRILL-7326: Support repeated lists for CTAS parquet format
URL: https://github.com/apache/drill/pull/1844#discussion_r315669214
 
 

 ##########
 File path: exec/java-exec/src/main/codegen/templates/ParquetOutputRecordWriter.java
 ##########
 @@ -268,10 +268,109 @@ public void writeField() throws IOException {
     consumer.endField(fieldName, fieldId);
   </#if>
     }
+
+    <#if mode.prefix == "Repeated">
+     @Override
+     public void writeListField() {
+      if (reader.size() == 0) {
+        return;
+      }
+      consumer.startField("list", 0);
+      for (int i = 0; i < reader.size(); i++) {
+        consumer.startGroup();
+        consumer.startField("element", 0);
+
+          <#if  minor.class == "TinyInt" ||
+            minor.class == "UInt1" ||
+            minor.class == "UInt2" ||
+            minor.class == "SmallInt" ||
+            minor.class == "Int" ||
+            minor.class == "Time" ||
+            minor.class == "Decimal9" ||
+            minor.class == "UInt4">
+        reader.read(i, holder);
+        consumer.addInteger(holder.value);
+  <#elseif minor.class == "Float4">
+        reader.read(i, holder);
+        consumer.addFloat(holder.value);
+  <#elseif minor.class == "BigInt" ||
+            minor.class == "Decimal18" ||
+            minor.class == "TimeStamp" ||
+            minor.class == "UInt8">
+        reader.read(i, holder);
+        consumer.addLong(holder.value);
+  <#elseif minor.class == "Date">
+        reader.read(i, holder);
+        consumer.addInteger((int) (holder.value / DateTimeConstants.MILLIS_PER_DAY));
+  <#elseif minor.class == "Float8">
+      reader.read(i, holder);
+      consumer.addDouble(holder.value);
+  <#elseif minor.class == "Bit">
+      reader.read(i, holder);
+      consumer.addBoolean(holder.value == 1);
+  <#elseif minor.class == "Decimal28Sparse" ||
+            minor.class == "Decimal38Sparse">
+      <#if mode.prefix == "Repeated" >
+      <#else>
+        consumer.startField(fieldName, fieldId);
+        reader.read(holder);
+        byte[] bytes = DecimalUtility.getBigDecimalFromSparse(
+            holder.buffer, holder.start, ${minor.class}Holder.nDecimalDigits, holder.scale).unscaledValue().toByteArray();
+        byte[] output = new byte[ParquetTypeHelper.getLengthForMinorType(MinorType.${minor.class?upper_case})];
+        if (holder.getSign(holder.start, holder.buffer)) {
+          Arrays.fill(output, 0, output.length - bytes.length, (byte)0xFF);
 
 Review comment:
   ```suggestion
             Arrays.fill(output, 0, output.length - bytes.length, (byte) 0xFF);
   ```

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


With regards,
Apache Git Services