diff options
author | Jonathan Abrahams <jonathan@mongodb.com> | 2016-03-09 12:17:50 -0500 |
---|---|---|
committer | Jonathan Abrahams <jonathan@mongodb.com> | 2016-03-09 12:18:14 -0500 |
commit | 4ae691e8edc87d0e3cfb633bb91c328426be007b (patch) | |
tree | 52079a593f54382ca13a2e741633eab1b6271893 /jstests/noPassthrough/geo_mnypts_plus_fields.js | |
parent | a025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff) | |
download | mongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz |
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/noPassthrough/geo_mnypts_plus_fields.js')
-rw-r--r-- | jstests/noPassthrough/geo_mnypts_plus_fields.js | 123 |
1 files changed, 61 insertions, 62 deletions
diff --git a/jstests/noPassthrough/geo_mnypts_plus_fields.js b/jstests/noPassthrough/geo_mnypts_plus_fields.js index 7058d2795c1..801c7dcfc8b 100644 --- a/jstests/noPassthrough/geo_mnypts_plus_fields.js +++ b/jstests/noPassthrough/geo_mnypts_plus_fields.js @@ -1,105 +1,104 @@ // Test sanity of geo queries with a lot of points -load( "jstests/libs/slow_weekly_util.js" ); -testServer = new SlowWeeklyMongod( "geo_mnypts_plus_fields" ); -db = testServer.getDB( "test" ); +load("jstests/libs/slow_weekly_util.js"); +testServer = new SlowWeeklyMongod("geo_mnypts_plus_fields"); +db = testServer.getDB("test"); var maxFields = 3; -for( var fields = 1; fields < maxFields; fields++ ){ - +for (var fields = 1; fields < maxFields; fields++) { var coll = db.testMnyPts; coll.drop(); - + var totalPts = 500 * 1000; var bulk = coll.initializeUnorderedBulkOp(); // Add points in a 100x100 grid - for( var i = 0; i < totalPts; i++ ){ + for (var i = 0; i < totalPts; i++) { var ii = i % 10000; - - var doc = { loc : [ ii % 100, Math.floor( ii / 100 ) ] }; - + + var doc = { + loc: [ii % 100, Math.floor(ii / 100)] + }; + // Add fields with different kinds of data - for( var j = 0; j < fields; j++ ){ - + for (var j = 0; j < fields; j++) { var field = null; - - if( j % 3 == 0 ){ + + if (j % 3 == 0) { // Make half the points not searchable - field = "abcdefg" + ( i % 2 == 0 ? "h" : "" ); - } - else if( j % 3 == 1 ){ + field = "abcdefg" + (i % 2 == 0 ? "h" : ""); + } else if (j % 3 == 1) { field = new Date(); - } - else{ + } else { field = true; } - - doc[ "field" + j ] = field; + + doc["field" + j] = field; } - bulk.insert( doc ); + bulk.insert(doc); } assert.writeOK(bulk.execute()); // Create the query for the additional fields queryFields = {}; - for( var j = 0; j < fields; j++ ){ - + for (var j = 0; j < fields; j++) { var field = null; - - if( j % 3 == 0 ){ + + if (j % 3 == 0) { field = "abcdefg"; - } - else if( j % 3 == 1 ){ - field = { $lte : new Date() }; - } - else{ + } else if (j % 3 == 1) { + field = { + $lte: new Date() + }; + } else { field = true; } - - queryFields[ "field" + j ] = field; + + queryFields["field" + j] = field; } - - coll.ensureIndex({ loc : "2d" }); - + + coll.ensureIndex({loc: "2d"}); + // Check that quarter of points in each quadrant - for( var i = 0; i < 4; i++ ){ + for (var i = 0; i < 4; i++) { var x = i % 2; - var y = Math.floor( i / 2 ); - + var y = Math.floor(i / 2); + var box = [[0, 0], [49, 49]]; - box[0][0] += ( x == 1 ? 50 : 0 ); - box[1][0] += ( x == 1 ? 50 : 0 ); - box[0][1] += ( y == 1 ? 50 : 0 ); - box[1][1] += ( y == 1 ? 50 : 0 ); - + box[0][0] += (x == 1 ? 50 : 0); + box[1][0] += (x == 1 ? 50 : 0); + box[0][1] += (y == 1 ? 50 : 0); + box[1][1] += (y == 1 ? 50 : 0); + // Now only half of each result comes back - assert.eq( totalPts / ( 4 * 2 ), coll.find(Object.extend( { loc : { $within : { $box : box } } }, queryFields ) ).count() ); - assert.eq( totalPts / ( 4 * 2 ), coll.find(Object.extend( { loc : { $within : { $box : box } } }, queryFields ) ).itcount() ); - + assert.eq(totalPts / (4 * 2), + coll.find(Object.extend({loc: {$within: {$box: box}}}, queryFields)).count()); + assert.eq(totalPts / (4 * 2), + coll.find(Object.extend({loc: {$within: {$box: box}}}, queryFields)).itcount()); } - + // Check that half of points in each half - for( var i = 0; i < 2; i++ ){ - + for (var i = 0; i < 2; i++) { var box = [[0, 0], [49, 99]]; - box[0][0] += ( i == 1 ? 50 : 0 ); - box[1][0] += ( i == 1 ? 50 : 0 ); - - assert.eq( totalPts / ( 2 * 2 ), coll.find(Object.extend( { loc : { $within : { $box : box } } }, queryFields ) ).count() ); - assert.eq( totalPts / ( 2 * 2 ), coll.find(Object.extend( { loc : { $within : { $box : box } } }, queryFields ) ).itcount() ); - + box[0][0] += (i == 1 ? 50 : 0); + box[1][0] += (i == 1 ? 50 : 0); + + assert.eq(totalPts / (2 * 2), + coll.find(Object.extend({loc: {$within: {$box: box}}}, queryFields)).count()); + assert.eq(totalPts / (2 * 2), + coll.find(Object.extend({loc: {$within: {$box: box}}}, queryFields)).itcount()); } - + // Check that all but corner set of points in radius - var circle = [[0, 0], (100 - 1) * Math.sqrt( 2 ) - 0.25 ]; - + var circle = [[0, 0], (100 - 1) * Math.sqrt(2) - 0.25]; + // All [99,x] pts are field0 : "abcdefg" - assert.eq( totalPts / 2 - totalPts / ( 100 * 100 ), coll.find(Object.extend( { loc : { $within : { $center : circle } } }, queryFields ) ).count() ); - assert.eq( totalPts / 2 - totalPts / ( 100 * 100 ), coll.find(Object.extend( { loc : { $within : { $center : circle } } }, queryFields ) ).itcount() ); - + assert.eq(totalPts / 2 - totalPts / (100 * 100), + coll.find(Object.extend({loc: {$within: {$center: circle}}}, queryFields)).count()); + assert.eq(totalPts / 2 - totalPts / (100 * 100), + coll.find(Object.extend({loc: {$within: {$center: circle}}}, queryFields)).itcount()); } testServer.stop(); |