Esempio n. 1
0
bool IndexDescriptor::areIndexOptionsEquivalent(const IndexDescriptor* other) const {
    if (isSparse() != other->isSparse()) {
        return false;
    }

    if (!isIdIndex() && unique() != other->unique()) {
        // Note: { _id: 1 } or { _id: -1 } implies unique: true.
        return false;
    }

    // Then compare the rest of the options.

    std::map<StringData, BSONElement> existingOptionsMap;
    populateOptionsMap(existingOptionsMap, infoObj());

    std::map<StringData, BSONElement> newOptionsMap;
    populateOptionsMap(newOptionsMap, other->infoObj());

    return existingOptionsMap.size() == newOptionsMap.size() &&
        std::equal(existingOptionsMap.begin(),
                   existingOptionsMap.end(),
                   newOptionsMap.begin(),
                   [](const std::pair<StringData, BSONElement>& lhs,
                      const std::pair<StringData, BSONElement>& rhs) {
                       return lhs.first == rhs.first &&
                           SimpleBSONElementComparator::kInstance.evaluate(lhs.second ==
                                                                           rhs.second);
                   });
}
 bool isPushOnly
 (
     void
 )
 {
     return (isSparse() && sparseMeta.pushOnly);
 }
Esempio n. 3
0
int SVMConfiguration::getDataDim() {
    if(isSparse()) {
        return this->sparse_data.n_rows;
    } else {
        return this->data.n_cols;
    }
}
 bool isStaged
 (
     void
 )
 {
     // NOTE: also tested by SPQR/Tcov, but not flagged as such in cov output
     return (isSparse() && sparseMeta.isStaged);
 }
Esempio n. 5
0
    bool IndexDescriptor::areIndexOptionsEquivalent( const IndexDescriptor* other ) const {

        if ( isSparse() != other->isSparse() ) {
            return false;
        }

        if ( !isIdIndex() &&
             unique() != other->unique() ) {
            // Note: { _id: 1 } or { _id: -1 } implies unique: true.
            return false;
        }

        // Then compare the rest of the options.

        std::map<StringData, BSONElement> existingOptionsMap;
        populateOptionsMap( existingOptionsMap, infoObj() );

        std::map<StringData, BSONElement> newOptionsMap;
        populateOptionsMap( newOptionsMap, other->infoObj() );

        return existingOptionsMap == newOptionsMap;
    }
Esempio n. 6
0
cv::SparseMat MxArray::toSparseMat() const
{
    // Check if it's sparse.
    if (!isSparse() || !isDouble())
        mexErrMsgIdAndTxt("mexopencv:error", "MxArray is not sparse");
    // Create cv::SparseMat.
    const mwSize m = mxGetM(p_), n = mxGetN(p_);
    const int dims[] = {m, n};
    cv::SparseMat mat(2, dims, CV_32F);
    // Copy data.
    const mwIndex *ir = mxGetIr(p_);
    const mwIndex *jc = mxGetJc(p_);
    const double *pr = mxGetPr(p_);
    if (!ir || !jc || !pr)
         mexErrMsgIdAndTxt("mexopencv:error", "Null pointer error");
    for (mwIndex j=0; j<n; ++j) {
        const mwIndex start = jc[j], end = jc[j + 1] - 1;
        // (row,col) <= val.
        for (mwIndex i = start; i <= end; ++i)
            mat.ref<float>(ir[i], j) = static_cast<float>(pr[i]);
    }
    return mat;
}