0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

Hints don't clobber sort ordering spec

This commit is contained in:
Aaron 2009-02-09 11:42:39 -05:00
parent 6f78b4ae5e
commit 657c78a08f

View File

@ -93,13 +93,17 @@ namespace mongo {
for (int i = 0; i < d->nIndexes; i++ ) {
IndexDetails& ii = d->indexes[i];
if ( ii.indexName() == hintstr ) {
int direction = matchDirection( ii.keyPattern(), order );
if ( isSorted ) *isSorted = ( direction != 0 );
if ( direction == 0 )
direction = 1;
// NOTE This startKey is incorrect, preserving for the moment so
// we can preserve simpleKeyMatch behavior.
BSONObj startKey = ii.getKeyFromQuery(query);
int direction = 1;
if ( simpleKeyMatch )
*simpleKeyMatch = query.nFields() == startKey.nFields();
if ( isSorted ) *isSorted = false;
return auto_ptr<Cursor>(
new BtreeCursor(ii, startKey, direction, query));
new BtreeCursor(ii, emptyObj, direction, query));
}
}
}
@ -108,13 +112,17 @@ namespace mongo {
for (int i = 0; i < d->nIndexes; i++ ) {
IndexDetails& ii = d->indexes[i];
if( ii.keyPattern().woCompare(hintobj) == 0 ) {
int direction = matchDirection( ii.keyPattern(), order );
if ( isSorted ) *isSorted = ( direction != 0 );
if ( direction == 0 )
direction = 1;
// NOTE This startKey is incorrect, preserving for the moment so
// we can preserve simpleKeyMatch behavior.
BSONObj startKey = ii.getKeyFromQuery(query);
int direction = 1;
if ( simpleKeyMatch )
*simpleKeyMatch = query.nFields() == startKey.nFields();
if ( isSorted ) *isSorted = false;
return auto_ptr<Cursor>(
new BtreeCursor(ii, startKey, direction, query));
new BtreeCursor(ii, emptyObj, direction, query));
}
}
}