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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
'use strict';
/**
* distinct_noindex.js
*
* Runs distinct on a non-indexed field and verifies the result.
* The field contains non-unique values.
* Each thread operates on the same collection.
*/
var $config = (function() {
var data = {
randRange: function randRange(low, high) {
assertAlways.gt(high, low);
return low + Random.randInt(high - low + 1);
},
numDocs: 1000
};
var states = (function() {
function init(db, collName) {
this.modulus = this.randRange(5, 15);
var bulk = db[collName].initializeUnorderedBulkOp();
for (var i = 0; i < this.numDocs; ++i) {
bulk.insert({i: i % this.modulus, tid: this.tid});
}
var res = bulk.execute();
assertAlways.writeOK(res);
assertAlways.eq(this.numDocs, res.nInserted);
}
function distinct(db, collName) {
assertWhenOwnColl.eq(this.modulus, db[collName].distinct('i', {tid: this.tid}).length);
}
return {
init: init,
distinct: distinct
};
})();
var transitions = {
init: {distinct: 1},
distinct: {distinct: 1}
};
return {
data: data,
threadCount: 10,
iterations: 20,
states: states,
transitions: transitions
};
})();
|