diff options
Diffstat (limited to 'jstests/core/sortg.js')
-rw-r--r-- | jstests/core/sortg.js | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/jstests/core/sortg.js b/jstests/core/sortg.js index 3e3c7bf517d..1f5a442fa35 100644 --- a/jstests/core/sortg.js +++ b/jstests/core/sortg.js @@ -4,64 +4,64 @@ // Test that a memory exception is triggered for in memory sorts, but not for indexed sorts. (function() { - "use strict"; +"use strict"; - const t = db.jstests_sortg; - t.drop(); +const t = db.jstests_sortg; +t.drop(); - const big = new Array(1000000).toString(); +const big = new Array(1000000).toString(); - let i; - for (i = 0; i < 100; ++i) { - t.save({b: 0}); - } +let i; +for (i = 0; i < 100; ++i) { + t.save({b: 0}); +} - for (i = 0; i < 110; ++i) { - t.save({a: 0, x: big}); - } +for (i = 0; i < 110; ++i) { + t.save({a: 0, x: big}); +} - function memoryException(sortSpec, querySpec) { - querySpec = querySpec || {}; - var ex = assert.throws(function() { - t.find(querySpec).sort(sortSpec).batchSize(1000).itcount(); - }); - assert(ex.toString().match(/Sort/)); - } - - function noMemoryException(sortSpec, querySpec) { - querySpec = querySpec || {}; +function memoryException(sortSpec, querySpec) { + querySpec = querySpec || {}; + var ex = assert.throws(function() { t.find(querySpec).sort(sortSpec).batchSize(1000).itcount(); - } + }); + assert(ex.toString().match(/Sort/)); +} + +function noMemoryException(sortSpec, querySpec) { + querySpec = querySpec || {}; + t.find(querySpec).sort(sortSpec).batchSize(1000).itcount(); +} - // Unindexed sorts. - memoryException({a: 1}); - memoryException({b: 1}); +// Unindexed sorts. +memoryException({a: 1}); +memoryException({b: 1}); - // Indexed sorts. - noMemoryException({_id: 1}); - noMemoryException({$natural: 1}); +// Indexed sorts. +noMemoryException({_id: 1}); +noMemoryException({$natural: 1}); - assert.eq(1, t.getIndexes().length); +assert.eq(1, t.getIndexes().length); - t.ensureIndex({a: 1}); - t.ensureIndex({b: 1}); - t.ensureIndex({c: 1}); +t.ensureIndex({a: 1}); +t.ensureIndex({b: 1}); +t.ensureIndex({c: 1}); - assert.eq(4, t.getIndexes().length); +assert.eq(4, t.getIndexes().length); - // These sorts are now indexed. - noMemoryException({a: 1}); - noMemoryException({b: 1}); +// These sorts are now indexed. +noMemoryException({a: 1}); +noMemoryException({b: 1}); - // A memory exception is triggered for an unindexed sort involving multiple plans. - memoryException({d: 1}, {b: null, c: null}); +// A memory exception is triggered for an unindexed sort involving multiple plans. +memoryException({d: 1}, {b: null, c: null}); - // With an indexed plan on _id:1 and an unindexed plan on b:1, the indexed plan should succeed - // even if the unindexed one would exhaust its memory limit. - noMemoryException({_id: 1}, {b: null}); +// With an indexed plan on _id:1 and an unindexed plan on b:1, the indexed plan should succeed +// even if the unindexed one would exhaust its memory limit. +noMemoryException({_id: 1}, {b: null}); - // With an unindexed plan on b:1 recorded for a query, the query should be retried when the - // unindexed plan exhausts its memory limit. - noMemoryException({_id: 1}, {b: null}); - t.drop(); +// With an unindexed plan on b:1 recorded for a query, the query should be retried when the +// unindexed plan exhausts its memory limit. +noMemoryException({_id: 1}, {b: null}); +t.drop(); })(); |