Search in sources :

Example 86 with Drillbit

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

the class TestHashJoin method hjWithExchange1.

@Test
public void hjWithExchange1(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable {
    // Another test for hash join with exchanges
    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 List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(FileUtils.getResourceAsFile("/join/hj_exchanges1.json"), Charsets.UTF_8));
        int count = 0;
        for (final QueryDataBatch b : results) {
            if (b.getHeader().getRowCount() != 0) {
                count += b.getHeader().getRowCount();
            }
            b.release();
        }
        System.out.println("Total records: " + count);
        assertEquals(272, 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)

Example 87 with Drillbit

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

the class TestHashJoin method multipleConditionJoin.

@Test
public void multipleConditionJoin(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable {
    // Function tests hash join with multiple join conditions
    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 List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(FileUtils.getResourceAsFile("/join/hj_multi_condition_join.json"), Charsets.UTF_8).replace("#{TEST_FILE_1}", FileUtils.getResourceAsFile("/build_side_input.json").toURI().toString()).replace("#{TEST_FILE_2}", FileUtils.getResourceAsFile("/probe_side_input.json").toURI().toString()));
        final RecordBatchLoader batchLoader = new RecordBatchLoader(bit.getContext().getAllocator());
        final QueryDataBatch batch = results.get(1);
        assertTrue(batchLoader.load(batch.getHeader().getDef(), batch.getData()));
        final Iterator<VectorWrapper<?>> itr = batchLoader.iterator();
        // Just test the join key
        final long[] colA = { 1, 2, 1 };
        final long[] colC = { 100, 200, 500 };
        // Check the output of decimal9
        final ValueVector.Accessor intAccessor1 = itr.next().getValueVector().getAccessor();
        final ValueVector.Accessor intAccessor2 = itr.next().getValueVector().getAccessor();
        for (int i = 0; i < intAccessor1.getValueCount(); i++) {
            assertEquals(intAccessor1.getObject(i), colA[i]);
            assertEquals(intAccessor2.getObject(i), colC[i]);
        }
        assertEquals(3, intAccessor1.getValueCount());
        batchLoader.clear();
        for (final QueryDataBatch result : results) {
            result.release();
        }
    }
}
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) VectorWrapper(org.apache.drill.exec.record.VectorWrapper) DrillClient(org.apache.drill.exec.client.DrillClient) Test(org.junit.Test)

Example 88 with Drillbit

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

the class TextRecordReaderTest method testFullExecution.

@Test
public void testFullExecution() 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(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(FileUtils.getResourceAsFile("/store/text/test.json"), Charsets.UTF_8).replace("#{DATA_FILE}", FileUtils.getResourceAsFile("/store/text/data/regions.csv").toURI().toString()));
        int count = 0;
        RecordBatchLoader loader = new RecordBatchLoader(bit1.getContext().getAllocator());
        for (QueryDataBatch b : results) {
            if (b.getHeader().getRowCount() != 0) {
                count += b.getHeader().getRowCount();
            }
            loader.load(b.getHeader().getDef(), b.getData());
            VectorUtil.showVectorAccessibleContent(loader);
            loader.clear();
            b.release();
        }
        assertEquals(5, 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) RecordBatchLoader(org.apache.drill.exec.record.RecordBatchLoader) DrillClient(org.apache.drill.exec.client.DrillClient) Test(org.junit.Test)

Example 89 with Drillbit

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

the class TestMergingReceiver method testMultipleProvidersMixedSizes.

@Test
public void testMultipleProvidersMixedSizes() throws Exception {
    @SuppressWarnings("resource") final RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
    try (final Drillbit bit1 = new Drillbit(CONFIG, serviceSet);
        final Drillbit bit2 = new Drillbit(CONFIG, serviceSet);
        final DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) {
        bit1.run();
        bit2.run();
        client.connect();
        final List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(DrillFileUtils.getResourceAsFile("/mergerecv/multiple_providers.json"), Charsets.UTF_8));
        int count = 0;
        final RecordBatchLoader batchLoader = new RecordBatchLoader(client.getAllocator());
        // print the results
        Long lastBlueValue = null;
        for (final QueryDataBatch b : results) {
            final QueryData queryData = b.getHeader();
            final int batchRowCount = queryData.getRowCount();
            count += batchRowCount;
            batchLoader.load(queryData.getDef(), b.getData());
            for (final VectorWrapper<?> vw : batchLoader) {
                @SuppressWarnings("resource") final ValueVector vv = vw.getValueVector();
                final ValueVector.Accessor va = vv.getAccessor();
                final MaterializedField materializedField = vv.getField();
                final int numValues = va.getValueCount();
                for (int valueIdx = 0; valueIdx < numValues; ++valueIdx) {
                    if (materializedField.getName().equals("blue")) {
                        final long longValue = (Long) va.getObject(valueIdx);
                        // check that order is ascending
                        if (lastBlueValue != null) {
                            assertTrue(longValue >= lastBlueValue);
                        }
                        lastBlueValue = longValue;
                    }
                }
            }
            b.release();
            batchLoader.clear();
        }
        assertEquals(400000, count);
    }
}
Also used : QueryData(org.apache.drill.exec.proto.UserBitShared.QueryData) RecordBatchLoader(org.apache.drill.exec.record.RecordBatchLoader) MaterializedField(org.apache.drill.exec.record.MaterializedField) 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) DrillClient(org.apache.drill.exec.client.DrillClient) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test)

Example 90 with Drillbit

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

the class TestMergingReceiver method testMultipleProvidersEmptyBatches.

@Test
public void testMultipleProvidersEmptyBatches() throws Exception {
    @SuppressWarnings("resource") final RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
    try (final Drillbit bit1 = new Drillbit(CONFIG, serviceSet);
        final Drillbit bit2 = new Drillbit(CONFIG, serviceSet);
        final DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) {
        bit1.run();
        bit2.run();
        client.connect();
        final List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(DrillFileUtils.getResourceAsFile("/mergerecv/multiple_providers_empty_batches.json"), Charsets.UTF_8));
        int count = 0;
        final RecordBatchLoader batchLoader = new RecordBatchLoader(client.getAllocator());
        // print the results
        Long lastBlueValue = null;
        for (final QueryDataBatch b : results) {
            final QueryData queryData = b.getHeader();
            final int batchRowCount = queryData.getRowCount();
            count += batchRowCount;
            batchLoader.load(queryData.getDef(), b.getData());
            for (final VectorWrapper<?> vw : batchLoader) {
                @SuppressWarnings("resource") final ValueVector vv = vw.getValueVector();
                final ValueVector.Accessor va = vv.getAccessor();
                final MaterializedField materializedField = vv.getField();
                final int numValues = va.getValueCount();
                for (int valueIdx = 0; valueIdx < numValues; ++valueIdx) {
                    if (materializedField.getName().equals("blue")) {
                        final long longValue = (Long) va.getObject(valueIdx);
                        // check that order is ascending
                        if (lastBlueValue != null) {
                            assertTrue(longValue >= lastBlueValue);
                        }
                        lastBlueValue = longValue;
                    }
                }
            }
            b.release();
            batchLoader.clear();
        }
        assertEquals(300000, count);
    }
}
Also used : QueryData(org.apache.drill.exec.proto.UserBitShared.QueryData) RecordBatchLoader(org.apache.drill.exec.record.RecordBatchLoader) MaterializedField(org.apache.drill.exec.record.MaterializedField) 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) DrillClient(org.apache.drill.exec.client.DrillClient) OperatorTest(org.apache.drill.categories.OperatorTest) 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