diff options
author | David Storch <david.storch@10gen.com> | 2014-02-12 17:21:12 -0500 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2014-02-14 19:17:18 -0500 |
commit | b855e3e54b2cbe9e93ab97866b37beef53d12696 (patch) | |
tree | 91a0632c365c38628c4c5b3749083ecdf144a932 /jstests | |
parent | 5a7ecde80c028947a9b29e82fe461013991e3d07 (diff) | |
download | mongo-b855e3e54b2cbe9e93ab97866b37beef53d12696.tar.gz |
SERVER-12532 negated predicates can use an index
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/ne2.js | 11 | ||||
-rw-r--r-- | jstests/not2.js | 63 |
2 files changed, 2 insertions, 72 deletions
diff --git a/jstests/ne2.js b/jstests/ne2.js index 53b2651dd5e..a69bfd6a114 100644 --- a/jstests/ne2.js +++ b/jstests/ne2.js @@ -10,14 +10,7 @@ t.save( { a:0 } ); t.save( { a:0.5 } ); e = t.find( { a: { $ne: 0 } } ).explain( true ); -// QUERY_MIGRATION -//assert.eq( "BtreeCursor a_1 multi", e.cursor ); -//assert.eq( 0, e.indexBounds.a[ 0 ][ 1 ] ); -//assert.eq( 0, e.indexBounds.a[ 1 ][ 0 ] ); -//assert.eq( 3, e.nscanned ); +assert.eq( 2, e.n, 'A' ); e = t.find( { a: { $gt: -1, $lt: 1, $ne: 0 } } ).explain(); -// QUERY_MIGRATION -//assert.eq( "BtreeCursor a_1 multi", e.cursor ); -//assert.eq( { a: [ [ -1, 0 ], [ 0, 1 ] ] }, e.indexBounds ); -//assert.eq( 3, e.nscanned ); +assert.eq( 2, e.n, 'B' ); diff --git a/jstests/not2.js b/jstests/not2.js index 3e9145c9054..23108ee9d52 100644 --- a/jstests/not2.js +++ b/jstests/not2.js @@ -81,66 +81,3 @@ check( {i:{$not:{$elemMatch:{j:"f"}}}}, [{j:"a"}], 2 ); doTest(); t.ensureIndex( {i:1} ); doTest(); - -t.drop(); -t.save( {i:"a"} ); -t.save( {i:"b"} ); -t.ensureIndex( {i:1} ); - -indexed = function( query, min, max ) { - exp = t.find( query ).explain( true ); - // printjson( exp ); - assert( exp.cursor.match( /Btree/ ), tojson( query ) ); - // QUERY MIGRATION - // New system consider collection scans as well - // assert( exp.allPlans.length == 1, tojson( query ) ); - // just expecting one element per key - for( i in exp.indexBounds ) { - assert.eq( exp.indexBounds[ i ][0][0], min ); - } - for( i in exp.indexBounds ) { - assert.eq( exp.indexBounds[ i ][exp.indexBounds[ i ].length - 1][1], max ); - } -} - -not = function( query ) { - exp = t.find( query ).explain( true ); -// printjson( exp ); - assert( !exp.cursor.match( /Btree/ ), tojson( query ) ); - assert( exp.allPlans.length == 1, tojson( query ) ); -} - -indexed( {i:1}, 1, 1 ); -// QUERY_MIGRATION: we don't index negation queries yet -//indexed( {i:{$ne:1}}, {$minElement:1}, {$maxElement:1} ); - -//indexed( {i:{$not:{$ne:"a"}}}, "a", "a" ); -not( {i:{$not:/^a/}} ); - -indexed( {i:{$gt:"a"}}, "a", {} ); -//indexed( {i:{$not:{$gt:"a"}}}, "", "a" ); - -indexed( {i:{$gte:"a"}}, "a", {} ); -//indexed( {i:{$not:{$gte:"a"}}}, "", "a" ); - -indexed( {i:{$lt:"b"}}, "", "b" ); -//indexed( {i:{$not:{$lt:"b"}}}, "b", {} ); - -indexed( {i:{$lte:"b"}}, "", "b" ); -//indexed( {i:{$not:{$lte:"b"}}}, "b", {} ); - -//indexed( {i:{$not:{$lte:"b",$gte:"f"}}}, "b", "f" ); - -not( {i:{$not:{$all:["a"]}}} ); -not( {i:{$not:{$mod:[2,1]}}} ); -not( {i:{$not:{$type:2}}} ); - -indexed( {i:{$in:[1]}}, 1, 1 ); -not( {i:{$not:{$in:[1]}}} ); - -t.drop(); -t.ensureIndex( {"i.j":1} ); -indexed( {i:{$elemMatch:{j:1}}}, 1, 1 ); -//indexed( {i:{$not:{$elemMatch:{j:1}}}}, {$minElement:1}, {$maxElement:1} ); -not( {i:{$not:{$elemMatch:{j:1}}}} ); -not( {i:{$not:{$elemMatch:{j:{$ne:1}}}}}, 1, 1 ); |