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_r315669990
 
 

 ##########
 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:
   I know that this code is copied from the above, but wouldn't it be better to 
replace `(byte)0xFF` with `-1`?

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to