arina-ielchiieva commented on a change in pull request #1726: DRILL-7143: 
Support default value for empty columns
URL: https://github.com/apache/drill/pull/1726#discussion_r271269796
 
 

 ##########
 File path: 
exec/vector/src/main/java/org/apache/drill/exec/vector/accessor/writer/AbstractFixedWidthWriter.java
 ##########
 @@ -93,17 +112,62 @@ protected final int prepareWrite(int writeIndex) {
     @Override
     protected final void fillEmpties(final int writeIndex) {
       final int width = width();
-      final int stride = ZERO_BUF.length / width;
+      final int stride = emptyValue.length / width;
       int dest = lastWriteIndex + 1;
       while (dest < writeIndex) {
         int length = writeIndex - dest;
         length = Math.min(length, stride);
-        drillBuf.setBytes(dest * width, ZERO_BUF, 0, length * width);
+        drillBuf.setBytes(dest * width, emptyValue, 0, length * width);
         dest += length;
       }
     }
   }
 
+  /**
+   * Base class for writers that use the Java int type as their native
+   * type. Handles common implicit conversions from other types to int.
+   */
+  public static abstract class BaseIntWriter extends BaseFixedWidthWriter {
+
+    @Override
+    public final void setLong(final long value) {
+      try {
+        // Catches int overflow. Does not catch overflow for smaller types.
+        setInt(Math.toIntExact(value));
+      } catch (final ArithmeticException e) {
+        throw InvalidConversionError.writeError(schema(), value, e);
+      }
+    }
+
+    @Override
+    public final void setDouble(final double value) {
 
 Review comment:
   Double covers Float as well?

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