Esempio n. 1
0
 ParallelSortClusteredCursor::ParallelSortClusteredCursor( const set<ServerAndQuery>& servers , const string& ns , 
                                                           const Query& q , 
                                                           int options , const BSONObj& fields  )
     : ClusteredCursor( ns , q.obj , options , fields ) , _servers( servers ){
     _sortKey = q.getSort().copy();
     _needToSkip = 0;
     _finishCons();
 }
TEST(QueryTest, Sort) {
    Query q;
    q.sort(BSON("a" << 1));
    ASSERT_TRUE(q.isComplex());
    BSONObj sort = q.getSort();
    ASSERT_TRUE(sort.hasField("a"));
    ASSERT_EQUALS(sort.getIntField("a"), 1);
}
Esempio n. 3
0
int ConfigDiffTracker<ValType, ShardType>::calculateConfigDiff(CatalogManager* catalogManager) {
    _assertAttached();

    // Get the diff query required
    Query diffQuery = configDiffQuery();

    try {
        std::vector<ChunkType> chunks;
        uassertStatusOK(catalogManager->getChunks(
                            diffQuery.getFilter(), diffQuery.getSort(), boost::none, &chunks));

        return calculateConfigDiff(chunks);
    } catch (DBException& e) {
        // Should only happen on connection errors
        e.addContext(str::stream() << "could not calculate config difference for ns " << _ns);
        throw;
    }
}
Esempio n. 4
0
// LEGACY Constructor
ParallelSortClusteredCursor::ParallelSortClusteredCursor(const set<string>& servers,
                                                         const string& ns,
                                                         const Query& q,
                                                         int options,
                                                         const BSONObj& fields)
    : _servers(servers) {
    _sortKey = q.getSort().copy();
    _needToSkip = 0;

    _done = false;
    _didInit = false;

    // Populate legacy fields
    _ns = ns;
    _query = q.obj.getOwned();
    _options = options;
    _fields = fields.getOwned();
    _batchSize = 0;

    _finishCons();
}