Search in sources :

Example 16 with Drillbit

use of org.apache.drill.exec.server.Drillbit in project drill by axbaretto.

the class TestDistributedFragmentRun method oneBitOneExchangeOneEntryRun.

@Test
public void oneBitOneExchangeOneEntryRun() throws Exception {
    RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
    try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet);
        DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) {
        bit1.run();
        client.connect();
        List<QueryDataBatch> results = client.runQuery(QueryType.PHYSICAL, Files.toString(DrillFileUtils.getResourceAsFile("/physical_single_exchange.json"), Charsets.UTF_8));
        int count = 0;
        for (QueryDataBatch b : results) {
            count += b.getHeader().getRowCount();
            b.release();
        }
        assertEquals(100, count);
    }
}
Also used : QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) Drillbit(org.apache.drill.exec.server.Drillbit) RemoteServiceSet(org.apache.drill.exec.server.RemoteServiceSet) DrillClient(org.apache.drill.exec.client.DrillClient) Test(org.junit.Test) SlowTest(org.apache.drill.categories.SlowTest)

Example 17 with Drillbit

use of org.apache.drill.exec.server.Drillbit in project drill by axbaretto.

the class TestDistributedFragmentRun method twoBitOneExchangeTwoEntryRun.

@Test
public void twoBitOneExchangeTwoEntryRun() 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<QueryDataBatch> results = client.runQuery(QueryType.PHYSICAL, Files.toString(DrillFileUtils.getResourceAsFile("/physical_single_exchange_double_entry.json"), Charsets.UTF_8));
        int count = 0;
        for (QueryDataBatch b : results) {
            count += b.getHeader().getRowCount();
            b.release();
        }
        assertEquals(200, count);
    }
}
Also used : QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) Drillbit(org.apache.drill.exec.server.Drillbit) RemoteServiceSet(org.apache.drill.exec.server.RemoteServiceSet) DrillClient(org.apache.drill.exec.client.DrillClient) Test(org.junit.Test) SlowTest(org.apache.drill.categories.SlowTest)

Example 18 with Drillbit

use of org.apache.drill.exec.server.Drillbit in project drill by axbaretto.

the class TestExtractFunctions method testFrom.

private void testFrom(String fromType, String testDataFile, String columnName, long[][] expectedValues) throws Exception {
    try (RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
        Drillbit bit = new Drillbit(CONFIG, serviceSet);
        DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) {
        // run query.
        bit.run();
        client.connect();
        List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(DrillFileUtils.getResourceAsFile("/functions/extractFrom.json"), Charsets.UTF_8).replace("#{TEST_TYPE}", fromType).replace("#{TEST_FILE}", testDataFile).replace("#{COLUMN_NAME}", columnName));
        RecordBatchLoader batchLoader = new RecordBatchLoader(bit.getContext().getAllocator());
        QueryDataBatch batch = results.get(0);
        assertTrue(batchLoader.load(batch.getHeader().getDef(), batch.getData()));
        for (int i = 0; i < expectedValues.length; i++) {
            for (int j = 0; j < expectedValues[i].length; j++) {
                NullableBigIntVector vv = (NullableBigIntVector) batchLoader.getValueAccessorById(NullableBigIntVector.class, j).getValueVector();
                System.out.println("[" + i + "][" + j + "]: Expected: " + expectedValues[i][j] + ", Actual: " + vv.getAccessor().get(i));
                assertEquals(expectedValues[i][j], vv.getAccessor().get(i));
            }
        }
        for (QueryDataBatch b : results) {
            b.release();
        }
        batchLoader.clear();
    }
}
Also used : QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) Drillbit(org.apache.drill.exec.server.Drillbit) NullableBigIntVector(org.apache.drill.exec.vector.NullableBigIntVector) RemoteServiceSet(org.apache.drill.exec.server.RemoteServiceSet) RecordBatchLoader(org.apache.drill.exec.record.RecordBatchLoader) DrillClient(org.apache.drill.exec.client.DrillClient)

Example 19 with Drillbit

use of org.apache.drill.exec.server.Drillbit in project drill by axbaretto.

the class TestOptiqPlans method testJoinPlan.

@Test
public void testJoinPlan() throws Exception {
    final RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
    try (final Drillbit bit1 = new Drillbit(config, serviceSet);
        final DrillClient client = new DrillClient(config, serviceSet.getCoordinator())) {
        bit1.run();
        client.connect();
        final List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Resources.toString(Resources.getResource("physical_join.json"), Charsets.UTF_8));
        final RecordBatchLoader loader = new RecordBatchLoader(bit1.getContext().getAllocator());
        for (final QueryDataBatch b : results) {
            System.out.println(String.format("Got %d results", b.getHeader().getRowCount()));
            loader.load(b.getHeader().getDef(), b.getData());
            for (final VectorWrapper<?> vw : loader) {
                System.out.println(vw.getValueVector().getField().getName());
                final ValueVector vv = vw.getValueVector();
                for (int i = 0; i < vv.getAccessor().getValueCount(); i++) {
                    final Object o = vv.getAccessor().getObject(i);
                    System.out.println(o);
                }
            }
            loader.clear();
            b.release();
        }
        client.close();
    }
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) Drillbit(org.apache.drill.exec.server.Drillbit) RemoteServiceSet(org.apache.drill.exec.server.RemoteServiceSet) RecordBatchLoader(org.apache.drill.exec.record.RecordBatchLoader) DrillClient(org.apache.drill.exec.client.DrillClient) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) ExecTest(org.apache.drill.exec.ExecTest) PlannerTest(org.apache.drill.categories.PlannerTest) Test(org.junit.Test)

Example 20 with Drillbit

use of org.apache.drill.exec.server.Drillbit in project drill by axbaretto.

the class TestSimpleFragmentRun method runNoExchangeFragment.

@Test
public void runNoExchangeFragment() throws Exception {
    try (final RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
        final Drillbit bit = new Drillbit(CONFIG, serviceSet);
        final DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) {
        // run query.
        bit.run();
        client.connect();
        final String path = "/physical_test2.json";
        // String path = "/filter/test1.json";
        final List<QueryDataBatch> results = client.runQuery(QueryType.PHYSICAL, Files.toString(DrillFileUtils.getResourceAsFile(path), Charsets.UTF_8));
        // look at records
        final RecordBatchLoader batchLoader = new RecordBatchLoader(client.getAllocator());
        int recordCount = 0;
        for (final QueryDataBatch batch : results) {
            final boolean schemaChanged = batchLoader.load(batch.getHeader().getDef(), batch.getData());
            boolean firstColumn = true;
            // print headers.
            if (schemaChanged) {
                System.out.println("\n\n========NEW SCHEMA=========\n\n");
                for (final VectorWrapper<?> value : batchLoader) {
                    if (firstColumn) {
                        firstColumn = false;
                    } else {
                        System.out.print("\t");
                    }
                    System.out.print(value.getField().getName());
                    System.out.print("[");
                    System.out.print(value.getField().getType().getMinorType());
                    System.out.print("]");
                }
                System.out.println();
            }
            for (int i = 0; i < batchLoader.getRecordCount(); i++) {
                boolean first = true;
                recordCount++;
                for (final VectorWrapper<?> value : batchLoader) {
                    if (first) {
                        first = false;
                    } else {
                        System.out.print("\t");
                    }
                    System.out.print(value.getValueVector().getAccessor().getObject(i));
                }
                if (!first) {
                    System.out.println();
                }
            }
            batchLoader.clear();
            batch.release();
        }
        logger.debug("Received results {}", results);
        assertEquals(recordCount, 200);
    }
}
Also used : QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) Drillbit(org.apache.drill.exec.server.Drillbit) RemoteServiceSet(org.apache.drill.exec.server.RemoteServiceSet) RecordBatchLoader(org.apache.drill.exec.record.RecordBatchLoader) DrillClient(org.apache.drill.exec.client.DrillClient) Test(org.junit.Test)

Aggregations

Drillbit (org.apache.drill.exec.server.Drillbit)158 RemoteServiceSet (org.apache.drill.exec.server.RemoteServiceSet)132 Test (org.junit.Test)129 DrillClient (org.apache.drill.exec.client.DrillClient)119 QueryDataBatch (org.apache.drill.exec.rpc.user.QueryDataBatch)119 RecordBatchLoader (org.apache.drill.exec.record.RecordBatchLoader)79 SlowTest (org.apache.drill.categories.SlowTest)74 ValueVector (org.apache.drill.exec.vector.ValueVector)66 OperatorTest (org.apache.drill.categories.OperatorTest)47 VectorWrapper (org.apache.drill.exec.record.VectorWrapper)28 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)24 DrillConfig (org.apache.drill.common.config.DrillConfig)20 ExecTest (org.apache.drill.exec.ExecTest)13 VectorTest (org.apache.drill.categories.VectorTest)12 DrillbitContext (org.apache.drill.exec.server.DrillbitContext)11 QueryData (org.apache.drill.exec.proto.UserBitShared.QueryData)10 StoragePluginRegistry (org.apache.drill.exec.store.StoragePluginRegistry)8 VarBinaryVector (org.apache.drill.exec.vector.VarBinaryVector)7 IOException (java.io.IOException)6 ZookeeperHelper (org.apache.drill.exec.ZookeeperHelper)6