blob: af8fef20510fb077a72dafbc5608cb0524257e3e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
'use strict';
/*
* yield_sort.js (extends yield_sort_merge.js)
*
* Intersperse queries which use the SORT stage with updates and deletes of documents they may
* match.
*/
load('jstests/concurrency/fsm_libs/extend_workload.js'); // for extendWorkload
load('jstests/concurrency/fsm_workloads/yield_sort_merge.js'); // for $config
var $config = extendWorkload($config, function($config, $super) {
/*
* Execute a query that will use the SORT stage.
*/
$config.states.query = function sort(db, collName) {
var nMatches = 100;
// Sort on c, since it's not an indexed field.
var cursor =
db[collName].find({a: {$lt: nMatches}}).sort({c: -1}).batchSize(this.batchSize);
var verifier = function sortVerifier(doc, prevDoc) {
var correctOrder = true;
if (prevDoc !== null) {
correctOrder = (doc.c <= prevDoc.c);
}
return doc.a < nMatches && correctOrder;
};
this.advanceCursor(cursor, verifier);
};
$config.data.genUpdateDoc = function genUpdateDoc() {
var newA = Random.randInt(this.nDocs);
var newC = Random.randInt(this.nDocs);
return {$set: {a: newA, c: newC}};
};
return $config;
});
|