diff options
Diffstat (limited to 'jstests/core/geo_update_btree2.js')
-rw-r--r-- | jstests/core/geo_update_btree2.js | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/jstests/core/geo_update_btree2.js b/jstests/core/geo_update_btree2.js index e0ddfd2adaa..b4ec059166a 100644 --- a/jstests/core/geo_update_btree2.js +++ b/jstests/core/geo_update_btree2.js @@ -14,53 +14,53 @@ assert.commandWorked( db._adminCommand( { setParameter:1, notablescan:true } ) ); var status = function( msg ){ - print( "\n\n###\n" + msg + "\n###\n\n" ) -} + print( "\n\n###\n" + msg + "\n###\n\n" ); +}; -var coll = db.getCollection( "jstests_geo_update_btree2" ) -coll.drop() +var coll = db.getCollection( "jstests_geo_update_btree2" ); +coll.drop(); -coll.ensureIndex( { loc : '2d' } ) +coll.ensureIndex( { loc : '2d' } ); -status( "Inserting points..." ) +status( "Inserting points..." ); -var numPoints = 10 +var numPoints = 10; Random.setRandomSeed(); for ( i = 0; i < numPoints; i++ ) { coll.insert( { _id : i, loc : [ Random.rand() * 180, Random.rand() * 180 ], i : i % 2 } ); } -status( "Starting long query..." ) +status( "Starting long query..." ); -var query = coll.find({ loc : { $within : { $box : [[-180, -180], [180, 180]] } } }).batchSize( 2 ) -var firstValues = [ query.next()._id, query.next()._id ] -printjson( firstValues ) +var query = coll.find({ loc : { $within : { $box : [[-180, -180], [180, 180]] } } }).batchSize( 2 ); +var firstValues = [ query.next()._id, query.next()._id ]; +printjson( firstValues ); -status( "Removing points not returned by query..." ) +status( "Removing points not returned by query..." ); -var allQuery = coll.find() -var removeIds = [] +var allQuery = coll.find(); +var removeIds = []; while( allQuery.hasNext() ){ - var id = allQuery.next()._id + var id = allQuery.next()._id; if( firstValues.indexOf( id ) < 0 ){ - removeIds.push( id ) + removeIds.push( id ); } } -var updateIds = [] -for( var i = 0, max = removeIds.length / 2; i < max; i++ ) updateIds.push( removeIds.pop() ) +var updateIds = []; +for( var i = 0, max = removeIds.length / 2; i < max; i++ ) updateIds.push( removeIds.pop() ); -printjson( removeIds ) -coll.remove({ _id : { $in : removeIds } }) +printjson( removeIds ); +coll.remove({ _id : { $in : removeIds } }); -status( "Updating points returned by query..." ) +status( "Updating points returned by query..." ); printjson(updateIds); -var big = new Array( 3000 ).toString() +var big = new Array( 3000 ).toString(); for( var i = 0; i < updateIds.length; i++ ) - coll.update({ _id : updateIds[i] }, { $set : { data : big } }) + coll.update({ _id : updateIds[i] }, { $set : { data : big } }); -status( "Counting final points..." ) +status( "Counting final points..." ); // It's not defined whether or not we return documents that are modified during a query. We // shouldn't crash, but it's not defined how many results we get back. This test is modifying every |