drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jacq...@apache.org
Subject [6/6] drill git commit: DRILL-1814: Check if writer state is OK before performing copy in copyAsValue() and copyAsField()
Date Fri, 05 Dec 2014 18:14:21 GMT
DRILL-1814: Check if writer state is OK before performing copy in copyAsValue() and copyAsField()


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

Branch: refs/heads/0.7.0
Commit: 142e5776115663af2278d3e4dfc68ea529595a47
Parents: 0ed30a8
Author: Mehant Baid <mehantr@gmail.com>
Authored: Thu Dec 4 18:37:36 2014 -0800
Committer: Jacques Nadeau <jacques@apache.org>
Committed: Fri Dec 5 10:13:10 2014 -0800

----------------------------------------------------------------------
 .../main/codegen/templates/ComplexReaders.java  | 24 +++++++++++++-------
 .../complex/impl/RepeatedListReaderImpl.java    |  4 ++--
 .../complex/impl/RepeatedMapReaderImpl.java     |  4 ++--
 .../complex/impl/SingleMapReaderImpl.java       | 12 ++++++----
 4 files changed, 28 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/142e5776/exec/java-exec/src/main/codegen/templates/ComplexReaders.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/ComplexReaders.java b/exec/java-exec/src/main/codegen/templates/ComplexReaders.java
index a6f2f04..027f61d 100644
--- a/exec/java-exec/src/main/codegen/templates/ComplexReaders.java
+++ b/exec/java-exec/src/main/codegen/templates/ComplexReaders.java
@@ -75,13 +75,17 @@ public class ${nullMode}${name}ReaderImpl extends AbstractFieldReader
{
   <#if mode == "Repeated">
 
   public void copyAsValue(${minor.class?cap_first}Writer writer){
-    Repeated${minor.class?cap_first}WriterImpl impl = (Repeated${minor.class?cap_first}WriterImpl)
writer;
-    impl.inform(impl.vector.copyFromSafe(idx(), impl.idx(), vector));
+    if (writer.ok()) {
+      Repeated${minor.class?cap_first}WriterImpl impl = (Repeated${minor.class?cap_first}WriterImpl)
writer;
+      impl.inform(impl.vector.copyFromSafe(idx(), impl.idx(), vector));
+    }
   }
   
   public void copyAsField(String name, MapWriter writer){
-    Repeated${minor.class?cap_first}WriterImpl impl = (Repeated${minor.class?cap_first}WriterImpl)
 writer.list(name).${lowerName}();
-    impl.inform(impl.vector.copyFromSafe(idx(), impl.idx(), vector));
+    if (writer.ok()) {
+      Repeated${minor.class?cap_first}WriterImpl impl = (Repeated${minor.class?cap_first}WriterImpl)
 writer.list(name).${lowerName}();
+      impl.inform(impl.vector.copyFromSafe(idx(), impl.idx(), vector));
+    }
   }
   
   public int size(){
@@ -107,13 +111,17 @@ public class ${nullMode}${name}ReaderImpl extends AbstractFieldReader
{
   <#else>
   
   public void copyAsValue(${minor.class?cap_first}Writer writer){
-    ${nullMode}${minor.class?cap_first}WriterImpl impl = (${nullMode}${minor.class?cap_first}WriterImpl)
writer;
-    impl.inform(impl.vector.copyFromSafe(idx(), impl.idx(), vector));
+    if (writer.ok()) {
+      ${nullMode}${minor.class?cap_first}WriterImpl impl = (${nullMode}${minor.class?cap_first}WriterImpl)
writer;
+      impl.inform(impl.vector.copyFromSafe(idx(), impl.idx(), vector));
+    }
   }
   
   public void copyAsField(String name, MapWriter writer){
-    ${nullMode}${minor.class?cap_first}WriterImpl impl = (${nullMode}${minor.class?cap_first}WriterImpl)
writer.${lowerName}(name);
-    impl.inform(impl.vector.copyFromSafe(idx(), impl.idx(), vector));
+    if (writer.ok()) {
+      ${nullMode}${minor.class?cap_first}WriterImpl impl = (${nullMode}${minor.class?cap_first}WriterImpl)
writer.${lowerName}(name);
+      impl.inform(impl.vector.copyFromSafe(idx(), impl.idx(), vector));
+    }
   }
   
   public void read(Nullable${minor.class?cap_first}Holder h){

http://git-wip-us.apache.org/repos/asf/drill/blob/142e5776/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/RepeatedListReaderImpl.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/RepeatedListReaderImpl.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/RepeatedListReaderImpl.java
index d21100b..c60730c 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/RepeatedListReaderImpl.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/RepeatedListReaderImpl.java
@@ -49,7 +49,7 @@ public class RepeatedListReaderImpl extends AbstractFieldReader{
 
   @Override
   public void copyAsValue(ListWriter writer) {
-    if (currentOffset == NO_VALUES) {
+    if (currentOffset == NO_VALUES || writer.ok() == false) {
       return;
     }
     RepeatedListWriter impl = (RepeatedListWriter) writer;
@@ -58,7 +58,7 @@ public class RepeatedListReaderImpl extends AbstractFieldReader{
 
   @Override
   public void copyAsField(String name, MapWriter writer) {
-    if (currentOffset == NO_VALUES) {
+    if (currentOffset == NO_VALUES || writer.ok() == false) {
       return;
     }
     RepeatedListWriter impl = (RepeatedListWriter) writer.list(name);

http://git-wip-us.apache.org/repos/asf/drill/blob/142e5776/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/RepeatedMapReaderImpl.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/RepeatedMapReaderImpl.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/RepeatedMapReaderImpl.java
index e57e37c..15f8a2b 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/RepeatedMapReaderImpl.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/RepeatedMapReaderImpl.java
@@ -149,7 +149,7 @@ public class RepeatedMapReaderImpl extends AbstractFieldReader{
 
   @Override
   public void copyAsValue(MapWriter writer) {
-    if (currentOffset == NO_VALUES) {
+    if (currentOffset == NO_VALUES || writer.ok() == false) {
       return;
     }
     RepeatedMapWriter impl = (RepeatedMapWriter) writer;
@@ -157,7 +157,7 @@ public class RepeatedMapReaderImpl extends AbstractFieldReader{
   }
 
   public void copyAsValueSingle(MapWriter writer) {
-    if (currentOffset == NO_VALUES) {
+    if (currentOffset == NO_VALUES || writer.ok() == false) {
       return;
     }
     SingleMapWriter impl = (SingleMapWriter) writer;

http://git-wip-us.apache.org/repos/asf/drill/blob/142e5776/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/SingleMapReaderImpl.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/SingleMapReaderImpl.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/SingleMapReaderImpl.java
index c2d96b1..3ec66ff 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/SingleMapReaderImpl.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/SingleMapReaderImpl.java
@@ -93,14 +93,18 @@ public class SingleMapReaderImpl extends AbstractFieldReader{
 
   @Override
   public void copyAsValue(MapWriter writer){
-    SingleMapWriter impl = (SingleMapWriter) writer;
-    impl.inform(impl.container.copyFromSafe(idx(), impl.idx(), vector));
+    if (writer.ok()) {
+      SingleMapWriter impl = (SingleMapWriter) writer;
+      impl.inform(impl.container.copyFromSafe(idx(), impl.idx(), vector));
+    }
   }
 
   @Override
   public void copyAsField(String name, MapWriter writer){
-    SingleMapWriter impl = (SingleMapWriter) writer.map(name);
-    impl.inform(impl.container.copyFromSafe(idx(), impl.idx(), vector));
+    if (writer.ok()) {
+      SingleMapWriter impl = (SingleMapWriter) writer.map(name);
+      impl.inform(impl.container.copyFromSafe(idx(), impl.idx(), vector));
+    }
   }
 
 


Mime
View raw message