diff --git a/cpp/daal/src/algorithms/dbscan/dbscan_dense_default_distr_impl.i b/cpp/daal/src/algorithms/dbscan/dbscan_dense_default_distr_impl.i old mode 100755 new mode 100644 index 965e7ea5ff7..b6c81951f4a --- a/cpp/daal/src/algorithms/dbscan/dbscan_dense_default_distr_impl.i +++ b/cpp/daal/src/algorithms/dbscan/dbscan_dense_default_distr_impl.i @@ -183,6 +183,16 @@ Status DBSCANDistrStep3Kernel::compute(const DataC DAAL_OVERFLOW_CHECK_BY_MULTIPLICATION(size_t, totalNRows, sizeof(algorithmFPType)); + if (totalNRows == 0) + { + WriteRows splitRows(ntSplit, 0, 1); + DAAL_CHECK_BLOCK_STATUS(splitRows); + algorithmFPType * const split = splitRows.get(); + split[0] = 0; + split[1] = (algorithmFPType)(-1); + return Status(); + } + TArray splitColumnArray(totalNRows); DAAL_CHECK_MALLOC(splitColumnArray.get()); algorithmFPType * const splitColumn = splitColumnArray.get(); @@ -235,7 +245,8 @@ Status DBSCANDistrStep4Kernel::compute(const DataC int result = 0; - size_t splitDim = -1; + size_t splitDim = -1; + size_t valuedPart = 0; for (size_t part = 0; part < nBlocks; part++) { NumericTablePtr ntPartialSplit = NumericTable::cast((*dcPartialSplits)[part]); @@ -243,7 +254,13 @@ Status DBSCANDistrStep4Kernel::compute(const DataC DAAL_CHECK_BLOCK_STATUS(partialSplitRows); const algorithmFPType * const partialSplit = partialSplitRows.get(); - partialSplitValues[part] = partialSplit[0]; + if ((size_t)partialSplit[1] == -1) + { + continue; + } + + partialSplitValues[valuedPart] = partialSplit[0]; + valuedPart++; DAAL_ASSERT(partialSplit[1] >= 0) if (part == 0) @@ -256,7 +273,7 @@ Status DBSCANDistrStep4Kernel::compute(const DataC } } - algorithmFPType splitValue = findKthStatistic(partialSplitValues, nBlocks, nBlocks / 2); + algorithmFPType splitValue = findKthStatistic(partialSplitValues, valuedPart, valuedPart / 2); DAAL_OVERFLOW_CHECK_BY_MULTIPLICATION(size_t, nBlocks, sizeof(int)); @@ -779,7 +796,10 @@ Status DBSCANDistrStep6Kernel::computeNoMemSave(co NeighborhoodEngine nHaloEngine(ntData.get(), ntHaloData.get(), ntHaloWeights.get(), epsilon, minkowskiPower); DAAL_CHECK_STATUS_VAR(nHaloEngine.queryFull(haloNeighs.get())); - DAAL_CHECK_STATUS_VAR(ntClusterStructure->resize(nRows)); + if (nRows) + { + DAAL_CHECK_STATUS_VAR(ntClusterStructure->resize(nRows)) + } WriteRows clusterStructureRows(ntClusterStructure, 0, nRows); if (nRows) @@ -952,7 +972,10 @@ Status DBSCANDistrStep6Kernel::computeMemSave(cons NeighborhoodEngine nEngine(ntData.get(), ntData.get(), ntWeights.get(), epsilon, minkowskiPower); NeighborhoodEngine nHaloEngine(ntData.get(), ntHaloData.get(), ntHaloWeights.get(), epsilon, minkowskiPower); - DAAL_CHECK_STATUS_VAR(ntClusterStructure->resize(nRows)); + if (nRows) + { + DAAL_CHECK_STATUS_VAR(ntClusterStructure->resize(nRows)) + } WriteRows clusterStructureRows(ntClusterStructure, 0, nRows); if (nRows) diff --git a/cpp/daal/src/algorithms/dbscan/dbscan_distributed_input_types.cpp b/cpp/daal/src/algorithms/dbscan/dbscan_distributed_input_types.cpp index 858b0a24335..4f18050dda3 100644 --- a/cpp/daal/src/algorithms/dbscan/dbscan_distributed_input_types.cpp +++ b/cpp/daal/src/algorithms/dbscan/dbscan_distributed_input_types.cpp @@ -129,21 +129,23 @@ services::Status DistributedInput::check(const daal::algorithms::Par const size_t nBlocks = dcPartialData->size(); DAAL_CHECK_EX(nBlocks > 0, ErrorIncorrectNumberOfInputNumericTables, ArgumentName, partialDataStr()); - size_t nFeatures = 0; - for (size_t i = 0; i < nBlocks; i++) + if (NumericTable::cast((*dcPartialData)[0])->getNumberOfRows() == 0) { - DAAL_CHECK_EX((*dcPartialData)[i], ErrorNullNumericTable, ArgumentName, partialDataStr()); - NumericTablePtr ntPartialData = NumericTable::cast((*dcPartialData)[i]); - DAAL_CHECK_EX(ntPartialData, ErrorIncorrectElementInNumericTableCollection, ArgumentName, partialDataStr()); - - if (i == 0) + size_t nFeatures = 0; + for (size_t i = 0; i < nBlocks; i++) { - nFeatures = ntPartialData->getNumberOfColumns(); - } + DAAL_CHECK_EX((*dcPartialData)[i], ErrorNullNumericTable, ArgumentName, partialDataStr()); + NumericTablePtr ntPartialData = NumericTable::cast((*dcPartialData)[i]); + DAAL_CHECK_EX(ntPartialData, ErrorIncorrectElementInNumericTableCollection, ArgumentName, partialDataStr()); - DAAL_CHECK_STATUS_VAR(checkNumericTable(ntPartialData.get(), partialDataStr(), 0, 0, nFeatures, 0)); - } + if (i == 0) + { + nFeatures = ntPartialData->getNumberOfColumns(); + } + DAAL_CHECK_STATUS_VAR(checkNumericTable(ntPartialData.get(), partialDataStr(), 0, 0, nFeatures, 0)); + } + } return services::Status(); } @@ -249,19 +251,17 @@ services::Status DistributedInput::check(const daal::algorithms::Par const size_t nDataBlocks = dcPartialData->size(); DAAL_CHECK_EX(nDataBlocks > 0, ErrorIncorrectNumberOfInputNumericTables, ArgumentName, partialDataStr()); - size_t nFeatures = 0; - for (size_t i = 0; i < nDataBlocks; i++) + size_t nFeatures = NumericTable::cast((*dcPartialData)[0])->getNumberOfColumns(); + if (NumericTable::cast((*dcPartialData)[0])->getNumberOfRows() != 0) { - DAAL_CHECK_EX((*dcPartialData)[i], ErrorNullNumericTable, ArgumentName, partialDataStr()); - NumericTablePtr ntPartialData = NumericTable::cast((*dcPartialData)[i]); - DAAL_CHECK_EX(ntPartialData, ErrorIncorrectElementInNumericTableCollection, ArgumentName, partialDataStr()); - - if (i == 0) + for (size_t i = 0; i < nDataBlocks; i++) { - nFeatures = ntPartialData->getNumberOfColumns(); - } + DAAL_CHECK_EX((*dcPartialData)[i], ErrorNullNumericTable, ArgumentName, partialDataStr()); + NumericTablePtr ntPartialData = NumericTable::cast((*dcPartialData)[i]); + DAAL_CHECK_EX(ntPartialData, ErrorIncorrectElementInNumericTableCollection, ArgumentName, partialDataStr()); - DAAL_CHECK_STATUS_VAR(checkNumericTable(ntPartialData.get(), partialDataStr(), 0, 0, nFeatures, 0)); + DAAL_CHECK_STATUS_VAR(checkNumericTable(ntPartialData.get(), partialDataStr(), 0, 0, nFeatures, 0)); + } } DataCollectionPtr dcBoundindBoxes = get(step3PartialBoundingBoxes); @@ -388,24 +388,24 @@ services::Status DistributedInput::check(const daal::algorithms::Par const int unexpectedLayouts = (int)packed_mask; - size_t nFeatures = 0; - for (size_t i = 0; i < nDataBlocks; i++) + size_t nFeatures = NumericTable::cast((*dcPartialData)[0])->getNumberOfColumns(); + if (NumericTable::cast((*dcPartialData)[0])->getNumberOfRows() != 0) { - DAAL_CHECK_EX((*dcPartialData)[i], ErrorNullNumericTable, ArgumentName, partialDataStr()); - NumericTablePtr ntPartialData = NumericTable::cast((*dcPartialData)[i]); - DAAL_CHECK_EX(ntPartialData, ErrorIncorrectElementInNumericTableCollection, ArgumentName, partialDataStr()); - if (i == 0) + for (size_t i = 0; i < nDataBlocks; i++) { - nFeatures = ntPartialData->getNumberOfColumns(); - } - DAAL_CHECK_STATUS_VAR(checkNumericTable(ntPartialData.get(), partialDataStr(), 0, 0, nFeatures, 0)); + DAAL_CHECK_EX((*dcPartialData)[i], ErrorNullNumericTable, ArgumentName, partialDataStr()); + NumericTablePtr ntPartialData = NumericTable::cast((*dcPartialData)[i]); + DAAL_CHECK_EX(ntPartialData, ErrorIncorrectElementInNumericTableCollection, ArgumentName, partialDataStr()); - const size_t nRows = ntPartialData->getNumberOfRows(); + DAAL_CHECK_STATUS_VAR(checkNumericTable(ntPartialData.get(), partialDataStr(), 0, 0, nFeatures, 0)); - DAAL_CHECK_EX((*dcPartialOrders)[i], ErrorNullNumericTable, ArgumentName, step4PartialOrdersStr()); - NumericTablePtr ntPartialOrder = NumericTable::cast((*dcPartialOrders)[i]); - DAAL_CHECK_EX(ntPartialOrder, ErrorIncorrectElementInNumericTableCollection, ArgumentName, step4PartialOrdersStr()); - DAAL_CHECK_STATUS_VAR(checkNumericTable(ntPartialOrder.get(), step4PartialOrdersStr(), unexpectedLayouts, 0, 2, nRows)); + const size_t nRows = ntPartialData->getNumberOfRows(); + + DAAL_CHECK_EX((*dcPartialOrders)[i], ErrorNullNumericTable, ArgumentName, step4PartialOrdersStr()); + NumericTablePtr ntPartialOrder = NumericTable::cast((*dcPartialOrders)[i]); + DAAL_CHECK_EX(ntPartialOrder, ErrorIncorrectElementInNumericTableCollection, ArgumentName, step4PartialOrdersStr()); + DAAL_CHECK_STATUS_VAR(checkNumericTable(ntPartialOrder.get(), step4PartialOrdersStr(), unexpectedLayouts, 0, 2, nRows)); + } } DataCollectionPtr dcSplits = get(step4PartialSplits); @@ -526,19 +526,17 @@ services::Status DistributedInput::check(const daal::algorithms::Par const size_t nDataBlocks = dcPartialData->size(); DAAL_CHECK_EX(nDataBlocks > 0, ErrorIncorrectNumberOfInputNumericTables, ArgumentName, partialDataStr()); - size_t nFeatures = 0; - for (size_t i = 0; i < nDataBlocks; i++) + size_t nFeatures = NumericTable::cast((*dcPartialData)[0])->getNumberOfColumns(); + if (NumericTable::cast((*dcPartialData)[0])->getNumberOfRows() != 0) { - DAAL_CHECK_EX((*dcPartialData)[i], ErrorNullNumericTable, ArgumentName, partialDataStr()); - NumericTablePtr ntPartialData = NumericTable::cast((*dcPartialData)[i]); - DAAL_CHECK_EX(ntPartialData, ErrorIncorrectElementInNumericTableCollection, ArgumentName, partialDataStr()); - - if (i == 0) + for (size_t i = 0; i < nDataBlocks; i++) { - nFeatures = ntPartialData->getNumberOfColumns(); - } + DAAL_CHECK_EX((*dcPartialData)[i], ErrorNullNumericTable, ArgumentName, partialDataStr()); + NumericTablePtr ntPartialData = NumericTable::cast((*dcPartialData)[i]); + DAAL_CHECK_EX(ntPartialData, ErrorIncorrectElementInNumericTableCollection, ArgumentName, partialDataStr()); - DAAL_CHECK_STATUS_VAR(checkNumericTable(ntPartialData.get(), partialDataStr(), 0, 0, nFeatures, 0)); + DAAL_CHECK_STATUS_VAR(checkNumericTable(ntPartialData.get(), partialDataStr(), 0, 0, nFeatures, 0)); + } } DataCollectionPtr dcBoundindBoxes = get(step5PartialBoundingBoxes); @@ -659,19 +657,17 @@ services::Status DistributedInput::check(const daal::algorithms::Par const size_t nDataBlocks = dcPartialData->size(); DAAL_CHECK_EX(nDataBlocks > 0, ErrorIncorrectNumberOfInputNumericTables, ArgumentName, partialDataStr()); - size_t nFeatures = 0; - for (size_t i = 0; i < nDataBlocks; i++) + size_t nFeatures = NumericTable::cast((*dcPartialData)[0])->getNumberOfColumns(); + if (NumericTable::cast((*dcPartialData)[0])->getNumberOfRows() != 0) { - DAAL_CHECK_EX((*dcPartialData)[i], ErrorNullNumericTable, ArgumentName, partialDataStr()); - NumericTablePtr ntPartialData = NumericTable::cast((*dcPartialData)[i]); - DAAL_CHECK_EX(ntPartialData, ErrorIncorrectElementInNumericTableCollection, ArgumentName, partialDataStr()); - - if (i == 0) + for (size_t i = 0; i < nDataBlocks; i++) { - nFeatures = ntPartialData->getNumberOfColumns(); - } + DAAL_CHECK_EX((*dcPartialData)[i], ErrorNullNumericTable, ArgumentName, partialDataStr()); + NumericTablePtr ntPartialData = NumericTable::cast((*dcPartialData)[i]); + DAAL_CHECK_EX(ntPartialData, ErrorIncorrectElementInNumericTableCollection, ArgumentName, partialDataStr()); - DAAL_CHECK_STATUS_VAR(checkNumericTable(ntPartialData.get(), partialDataStr(), 0, 0, nFeatures, 0)); + DAAL_CHECK_STATUS_VAR(checkNumericTable(ntPartialData.get(), partialDataStr(), 0, 0, nFeatures, 0)); + } } DataCollectionPtr dcHaloData = get(haloData); @@ -853,10 +849,12 @@ services::Status DistributedInput::check(const daal::algorithms::Par { NumericTablePtr ntClusterStructure = get(step8InputClusterStructure); - DAAL_CHECK_EX(ntClusterStructure, ErrorNullNumericTable, ArgumentName, step8InputClusterStructureStr()); - int unexpectedLayouts = (int)packed_mask; - DAAL_CHECK_STATUS_VAR(checkNumericTable(ntClusterStructure.get(), step8InputClusterStructureStr(), unexpectedLayouts, 0, 4, 0)); + if (ntClusterStructure->getNumberOfRows() != 0) + { + int unexpectedLayouts = (int)packed_mask; + DAAL_CHECK_STATUS_VAR(checkNumericTable(ntClusterStructure.get(), step8InputClusterStructureStr(), unexpectedLayouts, 0, 4, 0)); + } } { @@ -990,10 +988,11 @@ services::Status DistributedInput::check(const daal::algorithms::Pa { NumericTablePtr ntClusterStructure = get(step10InputClusterStructure); - DAAL_CHECK_EX(ntClusterStructure, ErrorNullNumericTable, ArgumentName, step10InputClusterStructureStr()); - - int unexpectedLayouts = (int)packed_mask; - DAAL_CHECK_STATUS_VAR(checkNumericTable(ntClusterStructure.get(), step10InputClusterStructureStr(), unexpectedLayouts, 0, 4, 0)); + if (ntClusterStructure->getNumberOfRows() != 0) + { + int unexpectedLayouts = (int)packed_mask; + DAAL_CHECK_STATUS_VAR(checkNumericTable(ntClusterStructure.get(), step10InputClusterStructureStr(), unexpectedLayouts, 0, 4, 0)); + } } { @@ -1084,10 +1083,11 @@ services::Status DistributedInput::check(const daal::algorithms::Pa { NumericTablePtr ntClusterStructure = get(step11InputClusterStructure); - DAAL_CHECK_EX(ntClusterStructure, ErrorNullNumericTable, ArgumentName, step11InputClusterStructureStr()); - - int unexpectedLayouts = (int)packed_mask; - DAAL_CHECK_STATUS_VAR(checkNumericTable(ntClusterStructure.get(), step11InputClusterStructureStr(), unexpectedLayouts, 0, 4, 0)); + if (ntClusterStructure->getNumberOfRows() != 0) + { + int unexpectedLayouts = (int)packed_mask; + DAAL_CHECK_STATUS_VAR(checkNumericTable(ntClusterStructure.get(), step11InputClusterStructureStr(), unexpectedLayouts, 0, 4, 0)); + } } DataCollectionPtr dcQueries = get(step11PartialQueries); @@ -1185,10 +1185,11 @@ services::Status DistributedInput::check(const daal::algorithms::Pa { NumericTablePtr ntClusterStructure = get(step12InputClusterStructure); - DAAL_CHECK_EX(ntClusterStructure, ErrorNullNumericTable, ArgumentName, step12InputClusterStructureStr()); - - int unexpectedLayouts = (int)packed_mask; - DAAL_CHECK_STATUS_VAR(checkNumericTable(ntClusterStructure.get(), step12InputClusterStructureStr(), unexpectedLayouts, 0, 4, 0)); + if (ntClusterStructure->getNumberOfRows() != 0) + { + int unexpectedLayouts = (int)packed_mask; + DAAL_CHECK_STATUS_VAR(checkNumericTable(ntClusterStructure.get(), step12InputClusterStructureStr(), unexpectedLayouts, 0, 4, 0)); + } } DataCollectionPtr dcOrders = get(step12PartialOrders); @@ -1197,14 +1198,17 @@ services::Status DistributedInput::check(const daal::algorithms::Pa const size_t nQueriesBlocks = dcOrders->size(); DAAL_CHECK_EX(nQueriesBlocks > 0, ErrorIncorrectNumberOfInputNumericTables, ArgumentName, step12PartialOrdersStr()); - for (size_t i = 0; i < nQueriesBlocks; i++) + if (NumericTable::cast((*dcOrders)[0])->getNumberOfRows() != 0) { - DAAL_CHECK_EX((*dcOrders)[i], ErrorNullNumericTable, ArgumentName, step12PartialOrdersStr()); - NumericTablePtr ntOrders = NumericTable::cast((*dcOrders)[i]); - DAAL_CHECK_EX(ntOrders, ErrorIncorrectElementInNumericTableCollection, ArgumentName, step12PartialOrdersStr()); + for (size_t i = 0; i < nQueriesBlocks; i++) + { + DAAL_CHECK_EX((*dcOrders)[i], ErrorNullNumericTable, ArgumentName, step12PartialOrdersStr()); + NumericTablePtr ntOrders = NumericTable::cast((*dcOrders)[i]); + DAAL_CHECK_EX(ntOrders, ErrorIncorrectElementInNumericTableCollection, ArgumentName, step12PartialOrdersStr()); - int unexpectedLayouts = (int)packed_mask; - DAAL_CHECK_STATUS_VAR(checkNumericTable(ntOrders.get(), step12PartialOrdersStr(), unexpectedLayouts, 0, 2, 0)); + int unexpectedLayouts = (int)packed_mask; + DAAL_CHECK_STATUS_VAR(checkNumericTable(ntOrders.get(), step12PartialOrdersStr(), unexpectedLayouts, 0, 2, 0)); + } } return services::Status(); diff --git a/cpp/daal/src/algorithms/dbscan/dbscan_partial_result.h b/cpp/daal/src/algorithms/dbscan/dbscan_partial_result.h index d25156c6534..43a53797dc5 100644 --- a/cpp/daal/src/algorithms/dbscan/dbscan_partial_result.h +++ b/cpp/daal/src/algorithms/dbscan/dbscan_partial_result.h @@ -179,7 +179,14 @@ DAAL_EXPORT services::Status DistributedPartialResultStep6::allocate(const daal: services::Status status; - set(step6ClusterStructure, HomogenNumericTable::create(4, nRows, NumericTable::doAllocate, &status)); + if (nRows != 0) + { + set(step6ClusterStructure, HomogenNumericTable::create(4, nRows, NumericTable::doAllocate, &status)); + } + else + { + set(step6ClusterStructure, HomogenNumericTable::create(4, 0, NumericTable::notAllocate, &status)); + } set(step6FinishedFlag, HomogenNumericTable::create(1, 1, NumericTable::doAllocate, &status)); set(step6NClusters, HomogenNumericTable::create(1, 1, NumericTable::doAllocate, &status)); @@ -229,7 +236,14 @@ DAAL_EXPORT services::Status DistributedPartialResultStep8::allocate(const daal: services::Status status; - set(step8ClusterStructure, HomogenNumericTable::create(4, nRows, NumericTable::doAllocate, &status)); + if (nRows != 0) + { + set(step8ClusterStructure, HomogenNumericTable::create(4, nRows, NumericTable::doAllocate, &status)); + } + else + { + set(step8ClusterStructure, HomogenNumericTable::create(4, 0, NumericTable::notAllocate, &status)); + } set(step8FinishedFlag, HomogenNumericTable::create(1, 1, NumericTable::doAllocate, &status)); set(step8NClusters, HomogenNumericTable::create(1, 1, NumericTable::doAllocate, &status)); @@ -307,7 +321,14 @@ DAAL_EXPORT services::Status DistributedPartialResultStep10::allocate(const daal services::Status status; - set(step10ClusterStructure, HomogenNumericTable::create(4, nRows, NumericTable::doAllocate, &status)); + if (nRows != 0) + { + set(step10ClusterStructure, HomogenNumericTable::create(4, nRows, NumericTable::doAllocate, &status)); + } + else + { + set(step10ClusterStructure, HomogenNumericTable::create(4, 0, NumericTable::notAllocate, &status)); + } set(step10FinishedFlag, HomogenNumericTable::create(1, 1, NumericTable::doAllocate, &status)); DataCollectionPtr dcQueries(new DataCollection(nBlocks)); @@ -341,7 +362,14 @@ DAAL_EXPORT services::Status DistributedPartialResultStep11::allocate(const daal services::Status status; - set(step11ClusterStructure, HomogenNumericTable::create(4, nRows, NumericTable::doAllocate, &status)); + if (nRows != 0) + { + set(step11ClusterStructure, HomogenNumericTable::create(4, nRows, NumericTable::doAllocate, &status)); + } + else + { + set(step11ClusterStructure, HomogenNumericTable::create(4, 0, NumericTable::notAllocate, &status)); + } set(step11FinishedFlag, HomogenNumericTable::create(1, 1, NumericTable::doAllocate, &status)); DataCollectionPtr dcQueries(new DataCollection(nBlocks)); diff --git a/cpp/daal/src/algorithms/dbscan/dbscan_partial_result_types.cpp b/cpp/daal/src/algorithms/dbscan/dbscan_partial_result_types.cpp index 121540681a7..a9956937cd5 100644 --- a/cpp/daal/src/algorithms/dbscan/dbscan_partial_result_types.cpp +++ b/cpp/daal/src/algorithms/dbscan/dbscan_partial_result_types.cpp @@ -152,26 +152,35 @@ Status DistributedPartialResultStep4::check(const daal::algorithms::Input * inpu DataCollectionPtr dcPartitionedPartialOrders = get(partitionedPartialOrders); DAAL_CHECK_EX(dcPartitionedData.get(), ErrorNullPartialResult, ArgumentName, partitionedDataStr()); - DAAL_CHECK_EX(dcPartitionedData->size() == nBlocks, ErrorIncorrectDataCollectionSize, ArgumentName, partitionedDataStr()); + if (NumericTable::cast((*dcPartitionedData)[0])->getNumberOfRows() != 0) + { + DAAL_CHECK_EX(dcPartitionedData->size() == nBlocks, ErrorIncorrectDataCollectionSize, ArgumentName, partitionedDataStr()); + } DAAL_CHECK_EX(dcPartitionedPartialOrders.get(), ErrorNullPartialResult, ArgumentName, partitionedPartialOrdersStr()); - DAAL_CHECK_EX(dcPartitionedPartialOrders->size() == nBlocks, ErrorIncorrectDataCollectionSize, ArgumentName, partitionedPartialOrdersStr()); + if (NumericTable::cast((*dcPartitionedPartialOrders)[0])->getNumberOfRows() != 0) + { + DAAL_CHECK_EX(dcPartitionedPartialOrders->size() == nBlocks, ErrorIncorrectDataCollectionSize, ArgumentName, partitionedPartialOrdersStr()); + } const int unexpectedLayouts = (int)packed_mask; - for (size_t i = 0; i < nBlocks; i++) + if (NumericTable::cast((*dcPartitionedData)[0])->getNumberOfRows() != 0) { - DAAL_CHECK_EX((*dcPartitionedData)[i], ErrorNullNumericTable, ArgumentName, partitionedDataStr()); - NumericTablePtr ntPartitionedData = NumericTable::cast((*dcPartitionedData)[i]); - DAAL_CHECK_EX(ntPartitionedData, ErrorIncorrectElementInNumericTableCollection, ArgumentName, partitionedDataStr()); - DAAL_CHECK_STATUS_VAR(checkNumericTable(ntPartitionedData.get(), partitionedDataStr(), unexpectedLayouts, 0, nFeatures, 0, false)); - - DAAL_CHECK_EX((*dcPartitionedPartialOrders)[i], ErrorNullNumericTable, ArgumentName, partitionedPartialOrdersStr()); - NumericTablePtr ntPartitionedPartialOrders = NumericTable::cast((*dcPartitionedPartialOrders)[i]); - DAAL_CHECK_EX(ntPartitionedPartialOrders, ErrorIncorrectElementInNumericTableCollection, ArgumentName, partitionedPartialOrdersStr()); - DAAL_CHECK_STATUS_VAR(checkNumericTable(ntPartitionedPartialOrders.get(), partitionedPartialOrdersStr(), unexpectedLayouts, 0, 2, 0, false)); + for (size_t i = 0; i < nBlocks; i++) + { + DAAL_CHECK_EX((*dcPartitionedData)[i], ErrorNullNumericTable, ArgumentName, partitionedDataStr()); + NumericTablePtr ntPartitionedData = NumericTable::cast((*dcPartitionedData)[i]); + DAAL_CHECK_EX(ntPartitionedData, ErrorIncorrectElementInNumericTableCollection, ArgumentName, partitionedDataStr()); + DAAL_CHECK_STATUS_VAR(checkNumericTable(ntPartitionedData.get(), partitionedDataStr(), unexpectedLayouts, 0, nFeatures, 0, false)); + + DAAL_CHECK_EX((*dcPartitionedPartialOrders)[i], ErrorNullNumericTable, ArgumentName, partitionedPartialOrdersStr()); + NumericTablePtr ntPartitionedPartialOrders = NumericTable::cast((*dcPartitionedPartialOrders)[i]); + DAAL_CHECK_EX(ntPartitionedPartialOrders, ErrorIncorrectElementInNumericTableCollection, ArgumentName, partitionedPartialOrdersStr()); + DAAL_CHECK_STATUS_VAR( + checkNumericTable(ntPartitionedPartialOrders.get(), partitionedPartialOrdersStr(), unexpectedLayouts, 0, 2, 0, false)); + } } - return Status(); } @@ -260,6 +269,7 @@ Status DistributedPartialResultStep6::check(const daal::algorithms::Input * inpu nRows += NumericTable::cast((*dcPartialData)[i])->getNumberOfRows(); } + if (nRows != 0) { NumericTablePtr ntClusterStructure = get(step6ClusterStructure); DAAL_CHECK_EX(ntClusterStructure, ErrorNullNumericTable, ArgumentName, step6ClusterStructureStr()); @@ -356,6 +366,7 @@ Status DistributedPartialResultStep8::check(const daal::algorithms::Input * inpu const DistributedInput * algInput = static_cast *>(input); const size_t nRows = algInput->get(step8InputClusterStructure)->getNumberOfRows(); + if (nRows != 0) { NumericTablePtr ntClusterStructure = get(step8ClusterStructure); DAAL_CHECK_EX(ntClusterStructure, ErrorNullNumericTable, ArgumentName, step8ClusterStructureStr()); @@ -488,6 +499,7 @@ Status DistributedPartialResultStep10::check(const daal::algorithms::Input * inp const DistributedInput * algInput = static_cast *>(input); const size_t nRows = algInput->get(step10InputClusterStructure)->getNumberOfRows(); + if (nRows != 0) { NumericTablePtr ntClusterStructure = get(step10ClusterStructure); DAAL_CHECK_EX(ntClusterStructure, ErrorNullNumericTable, ArgumentName, step10ClusterStructureStr()); @@ -554,6 +566,7 @@ Status DistributedPartialResultStep11::check(const daal::algorithms::Input * inp const DistributedInput * algInput = static_cast *>(input); const size_t nRows = algInput->get(step11InputClusterStructure)->getNumberOfRows(); + if (nRows != 0) { NumericTablePtr ntClusterStructure = get(step11ClusterStructure); DAAL_CHECK_EX(ntClusterStructure, ErrorNullNumericTable, ArgumentName, step11ClusterStructureStr()); diff --git a/samples/daal/cpp/mpi/sources/dbscan_dense_distributed_mpi.cpp b/samples/daal/cpp/mpi/sources/dbscan_dense_distributed_mpi.cpp index 88aa58442ee..d8c66595d9d 100644 --- a/samples/daal/cpp/mpi/sources/dbscan_dense_distributed_mpi.cpp +++ b/samples/daal/cpp/mpi/sources/dbscan_dense_distributed_mpi.cpp @@ -184,6 +184,11 @@ void geometricPartitioning() sendCollectionAllToAll(beginId, endId, rankId, step4ResultPartitionedDataTag, curPartitionedData, partitionedData); sendCollectionAllToAll(beginId, endId, rankId, step4ResultPartitionedPartialOrdersTag, curPartitionedPartialOrders, partitionedPartialOrders); + if (partitionedData->size() == 0) + partitionedData->push_back(NumericTable::cast((*curPartitionedData)[0])); + if (partitionedPartialOrders->size() == 0) + partitionedPartialOrders->push_back(NumericTable::cast((*curPartitionedPartialOrders)[0])); + if (rankId < beginId + leftPartitions) { endId = beginId + leftPartitions;