Skip to content

Commit 134a408

Browse files
author
clang-format-7.0.1
committed
SERVER-41772 Apply clang-format 7.0.1 to the codebase
1 parent 1e46b50 commit 134a408

File tree

3,509 files changed

+188416
-198406
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,509 files changed

+188416
-198406
lines changed

jstests/aggregation/bugs/cond.js

+68-69
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,87 @@
11
// $cond returns the evaluated second argument if the first evaluates to true but the evaluated
22
// third argument if the first evaluates to false.
33
(function() {
4-
"use strict";
5-
load('jstests/aggregation/extras/utils.js');
4+
"use strict";
5+
load('jstests/aggregation/extras/utils.js');
66

7-
const coll = db.jstests_aggregation_cond;
8-
coll.drop();
7+
const coll = db.jstests_aggregation_cond;
8+
coll.drop();
99

10-
coll.save({});
10+
coll.save({});
1111

12-
function assertError(expectedErrorCode, condSpec) {
13-
assertErrorCode(coll, {$project: {a: {$cond: condSpec}}}, expectedErrorCode);
14-
}
12+
function assertError(expectedErrorCode, condSpec) {
13+
assertErrorCode(coll, {$project: {a: {$cond: condSpec}}}, expectedErrorCode);
14+
}
1515

16-
function assertResult(expectedResult, arg) {
17-
assert.eq(expectedResult, coll.aggregate({$project: {a: {$cond: arg}}}).toArray()[0].a);
18-
}
16+
function assertResult(expectedResult, arg) {
17+
assert.eq(expectedResult, coll.aggregate({$project: {a: {$cond: arg}}}).toArray()[0].a);
18+
}
1919

20-
// Wrong number of args.
21-
assertError(16020, []);
22-
assertError(16020, [1]);
23-
assertError(16020, [false]);
24-
assertError(16020, [1, 1]);
25-
assertError(16020, [1, 1, null, 1]);
26-
assertError(16020, [1, 1, 1, undefined]);
20+
// Wrong number of args.
21+
assertError(16020, []);
22+
assertError(16020, [1]);
23+
assertError(16020, [false]);
24+
assertError(16020, [1, 1]);
25+
assertError(16020, [1, 1, null, 1]);
26+
assertError(16020, [1, 1, 1, undefined]);
2727

28-
// Bad object cases.
29-
assertError(17080, {"else": 1, then: 1});
30-
assertError(17081, {"if": 1, "else": 1});
31-
assertError(17082, {"if": 1, then: 1});
32-
assertError(17083, {asdf: 1, then: 1});
28+
// Bad object cases.
29+
assertError(17080, {"else": 1, then: 1});
30+
assertError(17081, {"if": 1, "else": 1});
31+
assertError(17082, {"if": 1, then: 1});
32+
assertError(17083, {asdf: 1, then: 1});
3333

34-
// Literal expressions.
35-
assertResult(1, [true, 1, 2]);
36-
assertResult(2, [false, 1, 2]);
34+
// Literal expressions.
35+
assertResult(1, [true, 1, 2]);
36+
assertResult(2, [false, 1, 2]);
3737

38-
// Order independence for object case.
39-
assertResult(1, {"if": true, "then": 1, "else": 2});
40-
assertResult(1, {"if": true, "else": 2, "then": 1});
41-
assertResult(1, {"then": 1, "if": true, "else": 2});
42-
assertResult(1, {"then": 1, "else": 2, "if": true});
43-
assertResult(1, {"else": 2, "then": 1, "if": true});
44-
assertResult(1, {"else": 2, "if": true, "then": 1});
38+
// Order independence for object case.
39+
assertResult(1, {"if": true, "then": 1, "else": 2});
40+
assertResult(1, {"if": true, "else": 2, "then": 1});
41+
assertResult(1, {"then": 1, "if": true, "else": 2});
42+
assertResult(1, {"then": 1, "else": 2, "if": true});
43+
assertResult(1, {"else": 2, "then": 1, "if": true});
44+
assertResult(1, {"else": 2, "if": true, "then": 1});
4545

46-
// Computed expressions.
47-
assertResult(1, [{$and: []}, {$add: [1]}, {$add: [1, 1]}]);
48-
assertResult(2, [{$or: []}, {$add: [1]}, {$add: [1, 1]}]);
46+
// Computed expressions.
47+
assertResult(1, [{$and: []}, {$add: [1]}, {$add: [1, 1]}]);
48+
assertResult(2, [{$or: []}, {$add: [1]}, {$add: [1, 1]}]);
4949

50-
assert(coll.drop());
51-
assert.writeOK(coll.insert({t: true, f: false, x: 'foo', y: 'bar'}));
50+
assert(coll.drop());
51+
assert.writeOK(coll.insert({t: true, f: false, x: 'foo', y: 'bar'}));
5252

53-
// Field path expressions.
54-
assertResult('foo', ['$t', '$x', '$y']);
55-
assertResult('bar', ['$f', '$x', '$y']);
53+
// Field path expressions.
54+
assertResult('foo', ['$t', '$x', '$y']);
55+
assertResult('bar', ['$f', '$x', '$y']);
5656

57-
assert(coll.drop());
58-
assert.writeOK(coll.insert({}));
57+
assert(coll.drop());
58+
assert.writeOK(coll.insert({}));
5959

60-
// Coerce to bool.
61-
assertResult('a', [1, 'a', 'b']);
62-
assertResult('a', ['', 'a', 'b']);
63-
assertResult('b', [0, 'a', 'b']);
60+
// Coerce to bool.
61+
assertResult('a', [1, 'a', 'b']);
62+
assertResult('a', ['', 'a', 'b']);
63+
assertResult('b', [0, 'a', 'b']);
6464

65-
// Nested.
66-
assert(coll.drop());
67-
assert.writeOK(coll.insert({noonSense: 'am', mealCombined: 'no'}));
68-
assert.writeOK(coll.insert({noonSense: 'am', mealCombined: 'yes'}));
69-
assert.writeOK(coll.insert({noonSense: 'pm', mealCombined: 'yes'}));
70-
assert.writeOK(coll.insert({noonSense: 'pm', mealCombined: 'no'}));
71-
assert.eq(
72-
['breakfast', 'brunch', 'dinner', 'linner'],
73-
coll.aggregate([
74-
{
75-
$project: {
76-
meal: {
77-
$cond: [
78-
{$eq: ['$noonSense', 'am']},
79-
{$cond: [{$eq: ['$mealCombined', 'yes']}, 'brunch', 'breakfast']},
80-
{$cond: [{$eq: ['$mealCombined', 'yes']}, 'linner', 'dinner']}
81-
]
65+
// Nested.
66+
assert(coll.drop());
67+
assert.writeOK(coll.insert({noonSense: 'am', mealCombined: 'no'}));
68+
assert.writeOK(coll.insert({noonSense: 'am', mealCombined: 'yes'}));
69+
assert.writeOK(coll.insert({noonSense: 'pm', mealCombined: 'yes'}));
70+
assert.writeOK(coll.insert({noonSense: 'pm', mealCombined: 'no'}));
71+
assert.eq(['breakfast', 'brunch', 'dinner', 'linner'],
72+
coll.aggregate([
73+
{
74+
$project: {
75+
meal: {
76+
$cond: [
77+
{$eq: ['$noonSense', 'am']},
78+
{$cond: [{$eq: ['$mealCombined', 'yes']}, 'brunch', 'breakfast']},
79+
{$cond: [{$eq: ['$mealCombined', 'yes']}, 'linner', 'dinner']}
80+
]
81+
}
8282
}
83-
}
84-
},
85-
{$sort: {meal: 1}}
86-
])
87-
.map(doc => doc.meal));
83+
},
84+
{$sort: {meal: 1}}
85+
])
86+
.map(doc => doc.meal));
8887
}());

jstests/aggregation/bugs/cursor_timeout.js

+67-68
Original file line numberDiff line numberDiff line change
@@ -7,83 +7,82 @@
77
* ]
88
*/
99
(function() {
10-
'use strict';
10+
'use strict';
1111

12-
// Cursor timeout on mongod is handled by a single thread/timer that will sleep for
13-
// "clientCursorMonitorFrequencySecs" and add the sleep value to each operation's duration when
14-
// it wakes up, timing out those whose "now() - last accessed since" time exceeds. A cursor
15-
// timeout of 2 seconds with a monitor frequency of 1 second means an effective timeout period
16-
// of 1 to 2 seconds.
17-
const cursorTimeoutMs = 2000;
18-
const cursorMonitorFrequencySecs = 1;
12+
// Cursor timeout on mongod is handled by a single thread/timer that will sleep for
13+
// "clientCursorMonitorFrequencySecs" and add the sleep value to each operation's duration when
14+
// it wakes up, timing out those whose "now() - last accessed since" time exceeds. A cursor
15+
// timeout of 2 seconds with a monitor frequency of 1 second means an effective timeout period
16+
// of 1 to 2 seconds.
17+
const cursorTimeoutMs = 2000;
18+
const cursorMonitorFrequencySecs = 1;
1919

20-
const options = {
21-
setParameter: {
22-
internalDocumentSourceCursorBatchSizeBytes: 1,
23-
// We use the "cursorTimeoutMillis" server parameter to decrease how long it takes for a
24-
// non-exhausted cursor to time out. We use the "clientCursorMonitorFrequencySecs"
25-
// server parameter to make the ClientCursorMonitor that cleans up the timed out cursors
26-
// run more often. The combination of these server parameters reduces the amount of time
27-
// we need to wait within this test.
28-
cursorTimeoutMillis: cursorTimeoutMs,
29-
clientCursorMonitorFrequencySecs: cursorMonitorFrequencySecs,
30-
}
31-
};
32-
const conn = MongoRunner.runMongod(options);
33-
assert.neq(null, conn, 'mongod was unable to start up with options: ' + tojson(options));
20+
const options = {
21+
setParameter: {
22+
internalDocumentSourceCursorBatchSizeBytes: 1,
23+
// We use the "cursorTimeoutMillis" server parameter to decrease how long it takes for a
24+
// non-exhausted cursor to time out. We use the "clientCursorMonitorFrequencySecs"
25+
// server parameter to make the ClientCursorMonitor that cleans up the timed out cursors
26+
// run more often. The combination of these server parameters reduces the amount of time
27+
// we need to wait within this test.
28+
cursorTimeoutMillis: cursorTimeoutMs,
29+
clientCursorMonitorFrequencySecs: cursorMonitorFrequencySecs,
30+
}
31+
};
32+
const conn = MongoRunner.runMongod(options);
33+
assert.neq(null, conn, 'mongod was unable to start up with options: ' + tojson(options));
3434

35-
const testDB = conn.getDB('test');
35+
const testDB = conn.getDB('test');
3636

37-
// We use a batch size of 2 to ensure that the mongo shell does not exhaust the cursor on its
38-
// first batch.
39-
const batchSize = 2;
40-
const numMatches = 5;
37+
// We use a batch size of 2 to ensure that the mongo shell does not exhaust the cursor on its
38+
// first batch.
39+
const batchSize = 2;
40+
const numMatches = 5;
4141

42-
function assertCursorTimesOut(collName, pipeline) {
43-
const res = assert.commandWorked(testDB.runCommand({
44-
aggregate: collName,
45-
pipeline: pipeline,
46-
cursor: {
47-
batchSize: batchSize,
48-
},
49-
}));
42+
function assertCursorTimesOut(collName, pipeline) {
43+
const res = assert.commandWorked(testDB.runCommand({
44+
aggregate: collName,
45+
pipeline: pipeline,
46+
cursor: {
47+
batchSize: batchSize,
48+
},
49+
}));
5050

51-
let serverStatus = assert.commandWorked(testDB.serverStatus());
52-
const expectedNumTimedOutCursors = serverStatus.metrics.cursor.timedOut + 1;
51+
let serverStatus = assert.commandWorked(testDB.serverStatus());
52+
const expectedNumTimedOutCursors = serverStatus.metrics.cursor.timedOut + 1;
5353

54-
const cursor = new DBCommandCursor(testDB, res, batchSize);
54+
const cursor = new DBCommandCursor(testDB, res, batchSize);
5555

56-
// Wait until the idle cursor background job has killed the aggregation cursor.
57-
assert.soon(
58-
function() {
59-
serverStatus = assert.commandWorked(testDB.serverStatus());
60-
return +serverStatus.metrics.cursor.timedOut === expectedNumTimedOutCursors;
61-
},
62-
function() {
63-
return "aggregation cursor failed to time out: " +
64-
tojson(serverStatus.metrics.cursor);
65-
});
56+
// Wait until the idle cursor background job has killed the aggregation cursor.
57+
assert.soon(
58+
function() {
59+
serverStatus = assert.commandWorked(testDB.serverStatus());
60+
return +serverStatus.metrics.cursor.timedOut === expectedNumTimedOutCursors;
61+
},
62+
function() {
63+
return "aggregation cursor failed to time out: " + tojson(serverStatus.metrics.cursor);
64+
});
6665

67-
assert.eq(0, serverStatus.metrics.cursor.open.total, tojson(serverStatus));
66+
assert.eq(0, serverStatus.metrics.cursor.open.total, tojson(serverStatus));
6867

69-
// We attempt to exhaust the aggregation cursor to verify that sending a getMore returns an
70-
// error due to the cursor being killed.
71-
let err = assert.throws(function() {
72-
cursor.itcount();
73-
});
74-
assert.eq(ErrorCodes.CursorNotFound, err.code, tojson(err));
75-
}
68+
// We attempt to exhaust the aggregation cursor to verify that sending a getMore returns an
69+
// error due to the cursor being killed.
70+
let err = assert.throws(function() {
71+
cursor.itcount();
72+
});
73+
assert.eq(ErrorCodes.CursorNotFound, err.code, tojson(err));
74+
}
7675

77-
assert.writeOK(testDB.source.insert({local: 1}));
78-
for (let i = 0; i < numMatches; ++i) {
79-
assert.writeOK(testDB.dest.insert({foreign: 1}));
80-
}
76+
assert.writeOK(testDB.source.insert({local: 1}));
77+
for (let i = 0; i < numMatches; ++i) {
78+
assert.writeOK(testDB.dest.insert({foreign: 1}));
79+
}
8180

82-
// Test that a regular aggregation cursor is killed when the timeout is reached.
83-
assertCursorTimesOut('dest', []);
81+
// Test that a regular aggregation cursor is killed when the timeout is reached.
82+
assertCursorTimesOut('dest', []);
8483

85-
// Test that an aggregation cursor with a $lookup stage is killed when the timeout is reached.
86-
assertCursorTimesOut('source', [
84+
// Test that an aggregation cursor with a $lookup stage is killed when the timeout is reached.
85+
assertCursorTimesOut('source', [
8786
{
8887
$lookup: {
8988
from: 'dest',
@@ -97,9 +96,9 @@
9796
},
9897
]);
9998

100-
// Test that an aggregation cursor with nested $lookup stages is killed when the timeout is
101-
// reached.
102-
assertCursorTimesOut('source', [
99+
// Test that an aggregation cursor with nested $lookup stages is killed when the timeout is
100+
// reached.
101+
assertCursorTimesOut('source', [
103102
{
104103
$lookup: {
105104
from: 'dest',
@@ -126,5 +125,5 @@
126125
},
127126
]);
128127

129-
MongoRunner.stopMongod(conn);
128+
MongoRunner.stopMongod(conn);
130129
})();

jstests/aggregation/bugs/explain_options_helper.js

+16-14
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,25 @@
22
// This test was designed to reproduce SERVER-32300".
33

44
(function() {
5-
"use strict";
5+
"use strict";
66

7-
const coll = db.explain_options;
8-
coll.drop();
7+
const coll = db.explain_options;
8+
coll.drop();
99

10-
for (let i = 0; i < 10; ++i) {
11-
assert.writeOK(coll.insert({_id: i}));
12-
}
10+
for (let i = 0; i < 10; ++i) {
11+
assert.writeOK(coll.insert({_id: i}));
12+
}
1313

14-
const collation = {collation: {locale: "zh", backwards: false}};
14+
const collation = {
15+
collation: {locale: "zh", backwards: false}
16+
};
1517

16-
const firstResults = coll.aggregate([{$sort: {_id: 1}}], collation).toArray();
17-
// Issue an explain in order to verify that 'collation' is not modified to include the explain
18-
// flag.
19-
assert.commandWorked(coll.explain().aggregate([], collation));
18+
const firstResults = coll.aggregate([{$sort: {_id: 1}}], collation).toArray();
19+
// Issue an explain in order to verify that 'collation' is not modified to include the explain
20+
// flag.
21+
assert.commandWorked(coll.explain().aggregate([], collation));
2022

21-
const secondResults = coll.aggregate([{$sort: {_id: 1}}], collation).toArray();
22-
// Assert that the result didn't change after an explain helper is issued.
23-
assert.eq(firstResults, secondResults);
23+
const secondResults = coll.aggregate([{$sort: {_id: 1}}], collation).toArray();
24+
// Assert that the result didn't change after an explain helper is issued.
25+
assert.eq(firstResults, secondResults);
2426
}());

0 commit comments

Comments
 (0)