You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by ja...@apache.org on 2013/04/24 23:25:09 UTC
git commit: bugfix for JoinROP test for JoinROP fix for JoinROP
testcase
Updated Branches:
refs/heads/master 92b98bc6d -> a38856cce
bugfix for JoinROP
test for JoinROP
fix for JoinROP testcase
Signed-off-by: Jacques Nadeau <ja...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/a38856cc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/a38856cc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/a38856cc
Branch: refs/heads/master
Commit: a38856cce83d80791b405009ad6e71c7fe1090c1
Parents: 92b98bc
Author: immars <im...@gmail.com>
Authored: Fri Mar 22 17:00:04 2013 +0800
Committer: Jacques Nadeau <ja...@apache.org>
Committed: Wed Apr 24 14:23:47 2013 -0700
----------------------------------------------------------------------
.../org/apache/drill/exec/ref/rops/JoinROP.java | 7 +-
.../java/org/apache/drill/exec/ref/TestUtils.java | 38 +++++++-
.../apache/drill/exec/ref/rops/JoinROPTest.java | 29 ++++++
.../ref/src/test/resources/join/departments.json | 16 +++
.../ref/src/test/resources/join/employees.json | 24 +++++
.../ref/src/test/resources/join/simple_join.json | 74 +++++++++++++++
6 files changed, 182 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a38856cc/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/rops/JoinROP.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/rops/JoinROP.java b/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/rops/JoinROP.java
index 37c5657..f24a21d 100644
--- a/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/rops/JoinROP.java
+++ b/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/rops/JoinROP.java
@@ -206,6 +206,10 @@ public class JoinROP extends ROPBase<Join> {
}
});
+ if (curIdx >= bufferLength) {
+ curIdx = 0;
+ }
+
if (option.isPresent()) {
setOutputRecord(rightPointer, bufferObj.pointer);
return (bufferObj.schemaChanged || rightOutcome == NextOutcome.INCREMENTED_SCHEMA_CHANGED) ?
@@ -213,9 +217,6 @@ public class JoinROP extends ROPBase<Join> {
NextOutcome.INCREMENTED_SCHEMA_UNCHANGED;
}
- if (curIdx >= bufferLength) {
- curIdx = 0;
- }
}
return NextOutcome.NONE_LEFT;
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a38856cc/sandbox/prototype/exec/ref/src/test/java/org/apache/drill/exec/ref/TestUtils.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/ref/src/test/java/org/apache/drill/exec/ref/TestUtils.java b/sandbox/prototype/exec/ref/src/test/java/org/apache/drill/exec/ref/TestUtils.java
index 611ce16..b942538 100644
--- a/sandbox/prototype/exec/ref/src/test/java/org/apache/drill/exec/ref/TestUtils.java
+++ b/sandbox/prototype/exec/ref/src/test/java/org/apache/drill/exec/ref/TestUtils.java
@@ -1,12 +1,25 @@
package org.apache.drill.exec.ref;
+import com.google.common.base.Charsets;
+import com.google.common.collect.Queues;
+import com.google.common.io.Files;
import org.apache.drill.common.config.DrillConfig;
import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.logical.LogicalPlan;
+import org.apache.drill.common.util.FileUtils;
+import org.apache.drill.exec.ref.eval.BasicEvaluatorFactory;
import org.apache.drill.exec.ref.rse.JSONRecordReader;
+import org.apache.drill.exec.ref.rse.RSERegistry;
+import org.codehaus.jackson.node.ArrayNode;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
public class TestUtils {
public static RecordIterator jsonToRecordIterator(String schemaPath, String j) throws IOException {
@@ -25,4 +38,23 @@ public class TestUtils {
}
return counter;
}
+
+ /**
+ *
+ * @param resourcePath path for json plan file
+ * @param recordCount expected record count
+ * @throws Exception
+ */
+ public static void assertProduceCount(String resourcePath, int recordCount) throws Exception {
+ DrillConfig config = DrillConfig.create();
+ final BlockingQueue<Object> queue = new ArrayBlockingQueue<Object>(100);
+ config.setSinkQueues(0, queue);
+ LogicalPlan plan = LogicalPlan.parse(config, Files.toString(FileUtils.getResourceAsFile(resourcePath), Charsets.UTF_8));
+ IteratorRegistry ir = new IteratorRegistry();
+ ReferenceInterpreter i = new ReferenceInterpreter(plan, ir, new BasicEvaluatorFactory(ir), new RSERegistry(config));
+ i.setup();
+ Collection<RunOutcome> outcomes = i.run();
+ assertEquals(outcomes.iterator().next().records, recordCount);
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a38856cc/sandbox/prototype/exec/ref/src/test/java/org/apache/drill/exec/ref/rops/JoinROPTest.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/ref/src/test/java/org/apache/drill/exec/ref/rops/JoinROPTest.java b/sandbox/prototype/exec/ref/src/test/java/org/apache/drill/exec/ref/rops/JoinROPTest.java
new file mode 100644
index 0000000..c334fc4
--- /dev/null
+++ b/sandbox/prototype/exec/ref/src/test/java/org/apache/drill/exec/ref/rops/JoinROPTest.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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.ref.rops;
+
+import org.apache.drill.exec.ref.TestUtils;
+import org.junit.Test;
+
+public class JoinROPTest {
+
+ @Test
+ public void testJoin() throws Exception{
+ TestUtils.assertProduceCount("/join/simple_join.json", 5);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a38856cc/sandbox/prototype/exec/ref/src/test/resources/join/departments.json
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/ref/src/test/resources/join/departments.json b/sandbox/prototype/exec/ref/src/test/resources/join/departments.json
new file mode 100644
index 0000000..3cf0a85
--- /dev/null
+++ b/sandbox/prototype/exec/ref/src/test/resources/join/departments.json
@@ -0,0 +1,16 @@
+{
+ "deptId": 31,
+ "name": "Sales"
+}
+{
+ "deptId": 33,
+ "name": "Engineering"
+}
+{
+ "deptId": 34,
+ "name": "Clerical"
+}
+{
+ "deptId": 35,
+ "name": "Marketing"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a38856cc/sandbox/prototype/exec/ref/src/test/resources/join/employees.json
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/ref/src/test/resources/join/employees.json b/sandbox/prototype/exec/ref/src/test/resources/join/employees.json
new file mode 100644
index 0000000..567793b
--- /dev/null
+++ b/sandbox/prototype/exec/ref/src/test/resources/join/employees.json
@@ -0,0 +1,24 @@
+{
+ "lastName": "Rafferty",
+ "deptId": 31
+}
+{
+ "lastName": "Jones",
+ "deptId": 33
+}
+{
+ "lastName": "Steinberg",
+ "deptId": 33
+}
+{
+ "lastName": "Robinson",
+ "deptId": 34
+}
+{
+ "lastName": "Smith",
+ "deptId": 36
+}
+{
+ "deptId": 35,
+ "lastName": "John"
+}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a38856cc/sandbox/prototype/exec/ref/src/test/resources/join/simple_join.json
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/ref/src/test/resources/join/simple_join.json b/sandbox/prototype/exec/ref/src/test/resources/join/simple_join.json
new file mode 100644
index 0000000..65c82cf
--- /dev/null
+++ b/sandbox/prototype/exec/ref/src/test/resources/join/simple_join.json
@@ -0,0 +1,74 @@
+{
+ head: {
+ type: "apache_drill_logical_plan",
+ version: "1",
+ generator: {
+ type: "manual",
+ info: "na"
+ }
+ },
+ storage:[
+ {
+ type:"console",
+ name:"console"
+ },
+ {
+ type:"fs",
+ name:"fs1",
+ root:"file:///"
+ },
+ {
+ type:"classpath",
+ name:"cp"
+ },
+ {
+ type: "queue",
+ name: "queue"
+ }
+ ],
+ query: [
+ {
+ @id: 1,
+ op: "scan",
+ memo: "initial_scan",
+ ref: "employees",
+ storageengine: "cp",
+ selection: {
+ path: "/join/employees.json",
+ type: "JSON"
+ }
+ },
+ {
+ @id: 2,
+ op: "scan",
+ memo: "second_scan",
+ ref: "departments",
+ storageengine: "cp",
+ selection: {
+ path: "/join/departments.json",
+ type: "JSON"
+ }
+ },
+ {
+ @id: 3,
+ op: "join",
+ left: 1,
+ right: 2,
+ type: "inner",
+ conditions: [
+ {
+ relationship: "==",
+ left: "employees.deptId",
+ right: "departments.deptId"
+ }
+ ]
+ },
+ {
+ input: 3,
+ op: "store",
+ memo: "output sink",
+ storageengine: "queue",
+ target: {number: 0}
+ }
+ ]
+}
\ No newline at end of file