drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jacq...@apache.org
Subject [03/12] drill git commit: DRILL-4241: Various Type Fixes
Date Mon, 11 Jan 2016 07:53:51 GMT
DRILL-4241: Various Type Fixes


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/8aac12b4
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/8aac12b4
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/8aac12b4

Branch: refs/heads/master
Commit: 8aac12b41dac299b91f3ada2e3742bc36f3454a6
Parents: 805e041
Author: Todd Lipcon <todd@cloudera.com>
Authored: Sun Jan 10 22:50:30 2016 -0800
Committer: Jacques Nadeau <jacques@apache.org>
Committed: Sun Jan 10 22:54:03 2016 -0800

----------------------------------------------------------------------
 .../drill/exec/store/kudu/KuduRecordReader.java | 112 ++++++++++---------
 1 file changed, 57 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/8aac12b4/contrib/storage-kudu/src/main/java/org/apache/drill/exec/store/kudu/KuduRecordReader.java
----------------------------------------------------------------------
diff --git a/contrib/storage-kudu/src/main/java/org/apache/drill/exec/store/kudu/KuduRecordReader.java
b/contrib/storage-kudu/src/main/java/org/apache/drill/exec/store/kudu/KuduRecordReader.java
index 0200527..fefb649 100644
--- a/contrib/storage-kudu/src/main/java/org/apache/drill/exec/store/kudu/KuduRecordReader.java
+++ b/contrib/storage-kudu/src/main/java/org/apache/drill/exec/store/kudu/KuduRecordReader.java
@@ -102,63 +102,13 @@ public class KuduRecordReader extends AbstractRecordReader {
       while (iterator == null || !iterator.hasNext()) {
         if (!scanner.hasMoreRows()) {
           iterator = null;
-          break;
+          return 0;
         }
         iterator = scanner.nextRows();
-
-        for (; rowCount < 4095 && iterator.hasNext(); rowCount++) {
-          writer.setPosition(rowCount);
-          RowResult result = iterator.next();
-          int i = 0;
-          for (ColumnSchema column : result.getColumnProjection().getColumns()) {
-            switch (column.getType()) {
-            case STRING: {
-              final ByteBuffer buf = result.getBinary(i);
-              final int length = buf.remaining();
-              ensure(length);
-              buffer.setBytes(0, buf);
-              writer.varChar(column.getName()).writeVarChar(0, length, buffer);
-              break;
-            }
-            case BINARY: {
-              final ByteBuffer buf = result.getBinary(i);
-              final int length = buf.remaining();
-              ensure(length);
-              buffer.setBytes(0, buf);
-              writer.varBinary(column.getName()).writeVarBinary(0, length, buffer);
-              break;
-            }
-            case INT8:
-              writer.integer(column.getName()).writeInt(result.getByte(i));
-              break;
-            case INT16:
-              writer.integer(column.getName()).writeInt(result.getShort(i));
-              break;
-            case INT32:
-              writer.integer(column.getName()).writeInt(result.getInt(i));
-              break;
-            case INT64:
-              writer.bigInt(column.getName()).writeBigInt(result.getLong(i));
-              break;
-            case FLOAT:
-              writer.float4(column.getName()).writeFloat4(result.getFloat(i));
-              break;
-            case DOUBLE:
-              writer.float8(column.getName()).writeFloat8(result.getDouble(i));
-              break;
-            case BOOL:
-              writer.bit(column.getName()).writeBit(result.getBoolean(i) ? 1 : 0);
-              break;
-            case TIMESTAMP:
-              writer.timeStamp(column.getName()).writeTimeStamp(result.getLong(i) / 1000);
-              break;
-            default:
-              throw new UnsupportedOperationException("unsupported type " + column.getType());
-            }
-
-            i++;
-          }
-        }
+      }
+      for (; rowCount < 4095 && iterator.hasNext(); rowCount++) {
+        writer.setPosition(rowCount);
+        addRowResult(iterator.next());
       }
     } catch (Exception ex) {
       throw new RuntimeException(ex);
@@ -167,6 +117,58 @@ public class KuduRecordReader extends AbstractRecordReader {
     return rowCount;
   }
 
+  private void addRowResult(RowResult result) {
+    int i = 0;
+    for (ColumnSchema column : result.getColumnProjection().getColumns()) {
+      switch (column.getType()) {
+      case STRING: {
+        final ByteBuffer buf = result.getBinary(i);
+        final int length = buf.remaining();
+        ensure(length);
+        buffer.setBytes(0, buf);
+        writer.varChar(column.getName()).writeVarChar(0, length, buffer);
+        break;
+      }
+      case BINARY: {
+        final ByteBuffer buf = result.getBinary(i);
+        final int length = buf.remaining();
+        ensure(length);
+        buffer.setBytes(0, buf);
+        writer.varBinary(column.getName()).writeVarBinary(0, length, buffer);
+        break;
+      }
+      case INT8:
+        writer.integer(column.getName()).writeInt(result.getByte(i));
+        break;
+      case INT16:
+        writer.integer(column.getName()).writeInt(result.getShort(i));
+        break;
+      case INT32:
+        writer.integer(column.getName()).writeInt(result.getInt(i));
+        break;
+      case INT64:
+        writer.bigInt(column.getName()).writeBigInt(result.getLong(i));
+        break;
+      case FLOAT:
+        writer.float4(column.getName()).writeFloat4(result.getFloat(i));
+        break;
+      case DOUBLE:
+        writer.float8(column.getName()).writeFloat8(result.getDouble(i));
+        break;
+      case BOOL:
+        writer.bit(column.getName()).writeBit(result.getBoolean(i) ? 1 : 0);
+        break;
+      case TIMESTAMP:
+        writer.timeStamp(column.getName()).writeTimeStamp(result.getLong(i) / 1000);
+        break;
+      default:
+        throw new UnsupportedOperationException("unsupported type " + column.getType());
+      }
+
+      i++;
+    }
+  }
+
   private void ensure(final int length) {
     buffer = buffer.reallocIfNeeded(length);
   }


Mime
View raw message