DRILL-5993: Adding generic copiers which do not require codegen

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

Branch: refs/heads/master
Commit: c8fdfd6d7ea46b13e5409b482ff5ec2ab962ac5d
Parents: 5c8e80d
Author: Paul Rogers <[email protected]>
Authored: Thu Nov 30 09:39:16 2017 -0800
Committer: Ben-Zvi <[email protected]>
Committed: Fri Feb 2 17:45:53 2018 -0800

----------------------------------------------------------------------
 .../impl/svremover/GenericSV2Copier.java        | 56 +++++++++++++++++++
 .../impl/svremover/GenericSV4Copier.java        | 58 ++++++++++++++++++++
 2 files changed, 114 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/c8fdfd6d/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/GenericSV2Copier.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/GenericSV2Copier.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/GenericSV2Copier.java
new file mode 100644
index 0000000..2fc17a3
--- /dev/null
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/GenericSV2Copier.java
@@ -0,0 +1,56 @@
+/*
+ * 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.physical.impl.svremover;
+
+import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.ops.FragmentContext;
+import org.apache.drill.exec.record.RecordBatch;
+import org.apache.drill.exec.record.VectorWrapper;
+import org.apache.drill.exec.vector.ValueVector;
+
+public class GenericSV2Copier extends CopierTemplate2 {
+
+  private ValueVector[] vvOut;
+  private ValueVector[] vvIn;
+
+  @SuppressWarnings("unused")
+  @Override
+  public void doSetup(FragmentContext context, RecordBatch incoming,
+                      RecordBatch outgoing) throws SchemaChangeException {
+
+    int count = 0;
+    for(VectorWrapper<?> vv : incoming) {
+      count++;
+    }
+    vvIn = new ValueVector[count];
+    vvOut = new ValueVector[count];
+    int i = 0;
+    for(VectorWrapper<?> vv : incoming) {
+      vvIn[i] = incoming.getValueAccessorById(ValueVector.class, 
i).getValueVector();
+      vvOut[i] = outgoing.getValueAccessorById(ValueVector.class, 
i).getValueVector();
+      i++;
+    }
+  }
+
+  @Override
+  public void doEval(int inIndex, int outIndex) throws SchemaChangeException {
+    for ( int i = 0;  i < vvIn.length;  i++ ) {
+      vvOut[i].copyEntry(outIndex, vvIn[i], inIndex);
+    }
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/drill/blob/c8fdfd6d/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/GenericSV4Copier.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/GenericSV4Copier.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/GenericSV4Copier.java
new file mode 100644
index 0000000..0950791
--- /dev/null
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/GenericSV4Copier.java
@@ -0,0 +1,58 @@
+/*
+ * 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.physical.impl.svremover;
+
+import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.ops.FragmentContext;
+import org.apache.drill.exec.record.RecordBatch;
+import org.apache.drill.exec.record.VectorWrapper;
+import org.apache.drill.exec.vector.ValueVector;
+
+public class GenericSV4Copier extends CopierTemplate4 {
+
+  private ValueVector[] vvOut;
+  private ValueVector[][] vvIn;
+
+  @SuppressWarnings("unused")
+  @Override
+  public void doSetup(FragmentContext context, RecordBatch incoming,
+                      RecordBatch outgoing) throws SchemaChangeException {
+
+    int count = 0;
+    for(VectorWrapper<?> vv : incoming) {
+      count++;
+    }
+    vvIn = new ValueVector[count][];
+    vvOut = new ValueVector[count];
+    int i = 0;
+    for(VectorWrapper<?> vv : incoming) {
+      vvIn[i] = incoming.getValueAccessorById(ValueVector.class, 
i).getValueVectors();
+      vvOut[i] = outgoing.getValueAccessorById(ValueVector.class, 
i).getValueVector();
+      i++;
+    }
+  }
+
+  @Override
+  public void doEval(int inIndex, int outIndex) throws SchemaChangeException {
+    int inOffset = inIndex & 0xFFFF;
+    int inVector = inIndex >>> 16;
+    for ( int i = 0;  i < vvIn.length;  i++ ) {
+      vvOut[i].copyEntry(outIndex, vvIn[i][inVector], inOffset);
+    }
+  }
+}
\ No newline at end of file

Reply via email to