Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Drill >> mail # dev >> [7/7] git commit: DRILL-458: Use GenericAccessor for accessing RepeatedTypes in jdbc


Copy link to this message
-
[7/7] git commit: DRILL-458: Use GenericAccessor for accessing RepeatedTypes in jdbc
DRILL-458: Use GenericAccessor for accessing RepeatedTypes in jdbc
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/f63f47f2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/f63f47f2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/f63f47f2

Branch: refs/heads/master
Commit: f63f47f29a55d03f68130c3628cef4b50c917458
Parents: 0b85baa
Author: Steven Phillips <[EMAIL PROTECTED]>
Authored: Wed Mar 26 19:16:06 2014 -0700
Committer: Jacques Nadeau <[EMAIL PROTECTED]>
Committed: Sat Mar 29 11:28:38 2014 -0700

 .../src/main/codegen/templates/TypeHelper.java  |  2 +-
 .../exec/vector/accessor/GenericAccessor.java   | 45 ++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f63f47f2/exec/java-exec/src/main/codegen/templates/TypeHelper.java
diff --git a/exec/java-exec/src/main/codegen/templates/TypeHelper.java b/exec/java-exec/src/main/codegen/templates/TypeHelper.java
index 84b5f70..02f608a 100644
+++ b/exec/java-exec/src/main/codegen/templates/TypeHelper.java
@@ -58,7 +58,7 @@ public class TypeHelper {
         case OPTIONAL:
           return new Nullable${minor.class}Accessor((Nullable${minor.class}Vector) vector);
         case REPEATED:
-          throw new UnsupportedOperationException();
+          return new GenericAccessor(vector);
       }
     </#list>
     </#list>

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f63f47f2/exec/java-exec/src/main/java/org/apache/drill/exec/vector/accessor/GenericAccessor.java
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/accessor/GenericAccessor.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/accessor/GenericAccessor.java
new file mode 100644
index 0000000..32f08b0
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/accessor/GenericAccessor.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.exec.vector.accessor;
+
+import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.exec.vector.ValueVector;
+
+public class GenericAccessor extends AbstractSqlAccessor {
+
+  private ValueVector v;
+
+  public GenericAccessor(ValueVector v) {
+    this.v = v;
+  }
+
+  @Override
+  public boolean isNull(int index) {
+    throw new UnsupportedOperationException();
+  }
+
+  @Override
+  public Object getObject(int index) throws InvalidAccessException {
+    return v.getAccessor().getObject(index);
+  }
+
+  @Override
+  TypeProtos.MajorType getType() {
+    return v.getMetadata().getDef().getMajorType();
+  }
+}