Пример #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);
                   });
}
Пример #2
0
    void run() {
        const ServiceContext::UniqueOperationContext opCtxPtr = cc().makeOperationContext();
        OperationContext& opCtx = *opCtxPtr;
        dbtests::WriteContextForTests ctx(&opCtx, _nss.ns());

        int numFinishedIndexesStart = _catalog->numIndexesReady(&opCtx);

        dbtests::createIndex(&opCtx, _nss.ns(), BSON("x" << 1)).transitional_ignore();
        dbtests::createIndex(&opCtx, _nss.ns(), BSON("y" << 1)).transitional_ignore();

        ASSERT_TRUE(_catalog->numIndexesReady(&opCtx) == numFinishedIndexesStart + 2);

        std::unique_ptr<IndexCatalog::IndexIterator> ii = _catalog->getIndexIterator(&opCtx, false);
        int indexesIterated = 0;
        bool foundIndex = false;
        while (ii->more()) {
            auto indexDesc = ii->next()->descriptor();
            indexesIterated++;
            BSONObjIterator boit(indexDesc->infoObj());
            while (boit.more() && !foundIndex) {
                BSONElement e = boit.next();
                if (e.fieldNameStringData() == "name" && e.valueStringDataSafe() == "y_1") {
                    foundIndex = true;
                    break;
                }
            }
        }

        ASSERT_TRUE(indexesIterated == _catalog->numIndexesReady(&opCtx));
        ASSERT_TRUE(foundIndex);
    }
Пример #3
0
static Poco::JSON::Object::Ptr portInfoToObj(const Pothos::PortInfo &portInfo)
{
    Poco::JSON::Object::Ptr infoObj(new Poco::JSON::Object());
    infoObj->set("name", portInfo.name);
    infoObj->set("alias", portInfo.alias);
    infoObj->set("dtype", portInfo.dtype.toMarkup());
    infoObj->set("size", Poco::UInt64(portInfo.dtype.size()));
    infoObj->set("isSigSlot", portInfo.isSigSlot);
    return infoObj;
}
Пример #4
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;
    }