diff options
author | Steven Phillips <sphillips@maprtech.com> | 2014-01-23 18:32:03 -0800 |
---|---|---|
committer | Jacques Nadeau <jacques@apache.org> | 2014-03-03 23:21:50 -0800 |
commit | cdf46fd36fdfc2e3029a6b2e077330c665e43c2e (patch) | |
tree | d69cb592765321c67c1c6571e89c840772e2c7f8 /exec/java-exec/src/test/java/org/apache | |
parent | a9a7ea84c99d8a9efcccc7d9a870121a26212b49 (diff) |
DRILL-357: Hive Storage Engine phase 2 - hive record reader
Diffstat (limited to 'exec/java-exec/src/test/java/org/apache')
3 files changed, 115 insertions, 93 deletions
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/TestPlan.java b/exec/java-exec/src/test/java/org/apache/drill/exec/TestPlan.java new file mode 100644 index 000000000..71e6283e7 --- /dev/null +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/TestPlan.java @@ -0,0 +1,48 @@ +/** + * 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; + +import org.apache.drill.exec.client.QuerySubmitter; +import org.junit.Ignore; +import org.junit.Test; + +import java.io.IOException; + +/** + * Created with IntelliJ IDEA. + * User: sphillips + * Date: 1/24/14 + * Time: 3:46 PM + * To change this template use File | Settings | File Templates. + */ +public class TestPlan { + + String location = "/Users/sphillips/hive-lineitem-orderkey"; + String type = "physical"; + String zkQuorum = null; + boolean local = true; + int bits = 1; + + + @Test + @Ignore + public void testSubmitPlan() throws Exception { + QuerySubmitter submitter = new QuerySubmitter(); + submitter.submitQuery(location, type, zkQuorum, local, bits); + } +} diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/hive/TestHiveScan.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/hive/TestHiveScan.java new file mode 100644 index 000000000..c6edc2000 --- /dev/null +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/hive/TestHiveScan.java @@ -0,0 +1,67 @@ +/** + * 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.store.hive; + +import com.google.common.base.Charsets; +import com.google.common.io.Files; +import org.apache.drill.common.util.FileUtils; +import org.apache.drill.exec.client.DrillClient; +import org.apache.drill.exec.pop.PopUnitTestBase; +import org.apache.drill.exec.proto.UserProtos; +import org.apache.drill.exec.rpc.user.QueryResultBatch; +import org.apache.drill.exec.server.Drillbit; +import org.apache.drill.exec.server.RemoteServiceSet; +import org.junit.Ignore; +import org.junit.Test; + +import java.util.List; + +import static org.junit.Assert.assertEquals; + +/** + * Created with IntelliJ IDEA. + * User: sphillips + * Date: 1/23/14 + * Time: 5:22 AM + * To change this template use File | Settings | File Templates. + */ +public class TestHiveScan extends PopUnitTestBase { + @Ignore + @Test + public void twoBitTwoExchangeTwoEntryRun() throws Exception { + RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); + + try(Drillbit bit1 = new Drillbit(CONFIG, serviceSet); + Drillbit bit2 = new Drillbit(CONFIG, serviceSet); + DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator());) { + + bit1.run(); + bit2.run(); + client.connect(); + List<QueryResultBatch> results = client.runQuery(UserProtos.QueryType.PHYSICAL, + Files.toString(FileUtils.getResourceAsFile("/hive/test.json"), + Charsets.UTF_8)); + int count = 0; + for(QueryResultBatch b : results) { + if (b.getHeader().getRowCount() != 0) + count += b.getHeader().getRowCount(); + } + assertEquals(100, count); + } + } +} diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/util/BatchPrinter.java b/exec/java-exec/src/test/java/org/apache/drill/exec/util/BatchPrinter.java deleted file mode 100644 index aa68752b7..000000000 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/util/BatchPrinter.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * 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.util; - -import com.beust.jcommander.internal.Lists; -import org.apache.commons.lang.StringUtils; -import org.apache.drill.exec.exception.SchemaChangeException; -import org.apache.drill.exec.record.VectorAccessible; -import org.apache.drill.exec.record.VectorWrapper; -import org.apache.drill.exec.record.selection.SelectionVector4; -import org.apache.drill.exec.rpc.RpcException; -import org.apache.drill.exec.vector.ValueVector; - -import java.util.List; - -/** - * This is a tool for printing the content of record batches to screen. Used for debugging. - */ -public class BatchPrinter { - public static void printHyperBatch(VectorAccessible batch) { - List<String> columns = Lists.newArrayList(); - List<ValueVector> vectors = Lists.newArrayList(); - int numBatches = 0; - for (VectorWrapper vw : batch) { - columns.add(vw.getValueVectors()[0].getField().getName()); - numBatches = vw.getValueVectors().length; - } - int width = columns.size(); - for (int i = 0; i < numBatches; i++) { - int rows = batch.iterator().next().getValueVectors()[i].getMetadata().getValueCount(); - for (int j = 0; j < rows; j++) { - for (VectorWrapper vw : batch) { - Object o = vw.getValueVectors()[i].getAccessor().getObject(j); - if (o instanceof byte[]) { - String value = new String((byte[]) o); - System.out.printf("| %-15s",value.length() <= 15 ? value : value.substring(0, 14)); - } else { - String value = o.toString(); - System.out.printf("| %-15s",value.length() <= 15 ? value : value.substring(0,14)); - } - } - System.out.printf("|\n"); - } - } - System.out.printf("|\n"); - } - public static void printBatch(VectorAccessible batch) { - List<String> columns = Lists.newArrayList(); - List<ValueVector> vectors = Lists.newArrayList(); - for (VectorWrapper vw : batch) { - columns.add(vw.getValueVector().getField().getName()); - vectors.add(vw.getValueVector()); - } - int width = columns.size(); - int rows = vectors.get(0).getMetadata().getValueCount(); - for (int row = 0; row < rows; row++) { - if (row%50 == 0) { - System.out.println(StringUtils.repeat("-", width * 17 + 1)); - for (String column : columns) { - System.out.printf("| %-15s", width <= 15 ? column : column.substring(0, 14)); - } - System.out.printf("|\n"); - System.out.println(StringUtils.repeat("-", width*17 + 1)); - } - for (ValueVector vv : vectors) { - Object o = vv.getAccessor().getObject(row); - if (o instanceof byte[]) { - String value = new String((byte[]) o); - System.out.printf("| %-15s",value.length() <= 15 ? value : value.substring(0, 14)); - } else { - String value = o.toString(); - System.out.printf("| %-15s",value.length() <= 15 ? value : value.substring(0,14)); - } - } - System.out.printf("|\n"); - } - } -} |