@@ -2,69 +2,28 @@ if ((typeof tests === "undefined" ? "undefined" : typeof(tests)) != "object") {
2
2
tests = [ ] ;
3
3
}
4
4
5
- /*
6
- * Inserts value at the location specified by path (using dot notation) in object.
7
- * If there's a common non-object field name this function overwrites the previous values.
8
- */
9
- function setDottedFieldToValue ( object , path , value ) {
10
- if ( typeof path === "string" ) {
11
- var fields = path . split ( "." ) ;
12
- if ( fields . length == 1 ) {
13
- object [ path ] = value ;
14
- } else {
15
- if ( typeof ( object [ fields [ 0 ] ] ) !== "object" ) {
16
- object [ fields [ 0 ] ] = { } ;
17
- }
18
- setDottedFieldToValue (
19
- object [ fields [ 0 ] ] , path . slice ( fields [ 0 ] . length + 1 , path . length ) , value ) ;
20
- }
21
- }
22
- return object ;
23
- }
24
-
25
5
/**
26
- * Creates test cases and adds them to the global testing array. By default,
27
- * each test case
28
- * specification produces several test cases:
6
+ * Creates test cases and adds them to the global testing array.
29
7
*
30
8
* @param {Object } options - Options describing the test case.
31
9
* @param {String } options.type - The name of the type of test case. It is
32
10
* prepended to the test name.
33
11
* @param {String } options.name - The name of the test case.
34
- * `${type}.AllPathsIndex .` is prepended.
12
+ * `${type}.WildCardIndex .` is prepended.
35
13
* @param {Object[] } options.ops - The operations to perform in benchRun.
36
14
* @param {function } options.pre - A function that sets up for the test case.
37
15
* @param {String[] } {options.tags=[] } - Additional tags describing this test.
38
- * The "all_paths ", "indexed", and ">=4.1.3" tags are added automatically.
16
+ * The "wildcard ", "indexed", and ">=4.1.3" tags are added automatically.
39
17
*/
40
18
function addTest ( options ) {
41
19
tests . push ( {
42
- name : options . type + ".AllPathsIndex ." + options . name ,
43
- tags : [ "all_paths " , "indexed" , ">=4.1.3" ] . concat ( options . tags ) ,
20
+ name : options . type + ".WildCardIndex ." + options . name ,
21
+ tags : [ "wildcard_write " , "indexed" , ">=4.1.3" ] . concat ( options . tags ) ,
44
22
pre : options . pre ,
45
23
ops : options . ops
46
24
} ) ;
47
25
}
48
26
49
- function getNFieldNames ( n ) {
50
- var fieldNames = [ ] ;
51
- for ( var i = 0 ; i < n ; i ++ ) {
52
- fieldNames . push ( "field-" + i ) ;
53
- }
54
- return fieldNames ;
55
- }
56
-
57
- /*
58
- * Arbitrary field names.
59
- */
60
- var FIELD_NAMES = getNFieldNames ( 200 ) ;
61
-
62
- /*
63
- * Constant used as a parameter for test cases.
64
- */
65
- var INDEX_FOR_QUERIES = 3111 ;
66
- var NUMBER_FOR_RANGE = 16 ;
67
-
68
27
/*
69
28
* Adds n fields (from fieldNamesArray with offset offset) and assigns values from values.
70
29
*/
@@ -179,9 +138,9 @@ function getDocGeneratorForDeeplyNestedFields(fieldNameArr, documentDepth, nFiel
179
138
function getSetupFunctionForTargetedIndex ( fieldsToIndex ) {
180
139
return function ( collection ) {
181
140
collection . drop ( ) ;
182
- // Instead of creating an allPaths index, creating a normal index for each top-level
141
+ // Instead of creating a wildcard index, creating a normal index for each top-level
183
142
// field used. This way, the same number of index entries are created, regardless of
184
- // whether we use an allPaths index, or a targeted index.
143
+ // whether we use an wildcard index, or a targeted index.
185
144
for ( var i = 0 ; i < fieldsToIndex . length ; i ++ ) {
186
145
var fieldName = fieldsToIndex [ i ] ;
187
146
assert . commandWorked ( collection . createIndex (
@@ -194,24 +153,22 @@ function getSetupFunctionForTargetedIndex(fieldsToIndex) {
194
153
* Returns a function, which when called, will drop the given collection and create a $** index on
195
154
* 'fieldsToIndex'. If 'fieldsToIndex' is empty, it will create a $** index on all fields.
196
155
*/
197
- function getSetupFunctionWithAllPathsIndex ( fieldsToIndex ) {
156
+ function getSetupFunctionWithWildCardIndex ( projectionFields ) {
198
157
return function ( collection ) {
199
158
collection . drop ( ) ;
200
159
var proj = { } ;
201
- for ( var i = 0 ; i < fieldsToIndex . length ; i ++ ) {
202
- proj [ fieldsToIndex [ i ] ] = 1 ;
160
+ for ( var i = 0 ; i < projectionFields . length ; i ++ ) {
161
+ proj [ projectionFields [ i ] ] = 1 ;
203
162
}
204
163
var indexOptions = undefined ;
205
- if ( fieldsToIndex . length > 0 ) {
164
+ if ( projectionFields . length > 0 ) {
206
165
indexOptions = { wildcardProjection : proj } ;
207
166
}
208
167
assert . commandWorked ( collection . createIndex ( { "$**" : 1 } , indexOptions ) ) ;
209
168
} ;
210
169
}
211
170
212
- var kInsertTags = [ "insert" ] ;
213
-
214
- // TODO: SERVER-36214 make read-path tests which include compound & range queries.
171
+ var kInsertTags = [ "wildcard_insert" ] ;
215
172
216
173
/*
217
174
* Make a test that inserts doc.
@@ -235,24 +192,29 @@ function makeInsertTestForDocType(name, pre, documentGenerator, additionalTags)
235
192
}
236
193
237
194
makeInsertTestForDocType ( "MultipleFieldsAllExcluded" ,
238
- getSetupFunctionWithAllPathsIndex ( [ "nonexistent" ] ) ,
195
+ getSetupFunctionWithWildCardIndex ( [ "nonexistent" ] ) ,
239
196
getDocGeneratorForTopLevelFields ( getNFieldNames ( 16 ) ) ,
240
197
[ "regression" ] ) ;
241
198
makeInsertTestForDocType ( "AllDiffFields" ,
242
- getSetupFunctionWithAllPathsIndex ( [ ] ) ,
199
+ getSetupFunctionWithWildCardIndex ( [ ] ) ,
243
200
getDocGeneratorForUniqueLeaves ( getNFieldNames ( 200 ) ) ,
244
201
[ "regression" ] ) ;
202
+ var NUMBER_FOR_RANGE = 16 ;
245
203
makeInsertTestForDocType ( "DeeplyNested" ,
246
- getSetupFunctionWithAllPathsIndex ( [ ] ) ,
204
+ getSetupFunctionWithWildCardIndex ( [ ] ) ,
247
205
getDocGeneratorForDeeplyNestedFields (
248
206
getNFieldNames ( 200 ) , NUMBER_FOR_RANGE , NUMBER_FOR_RANGE - 1 ) ,
249
207
[ "regression" ] ) ;
250
208
251
209
// Comparison tests which use a standard index.
252
210
253
211
function makeComparisonWriteTest ( name , fieldsToIndex , documentGenerator ) {
254
- makeInsertTestForDocType ( name + ".AllPathsIndex" ,
255
- getSetupFunctionWithAllPathsIndex ( fieldsToIndex ) ,
212
+ makeInsertTestForDocType ( name + ".WildCardIndex" ,
213
+ getSetupFunctionWithWildCardIndex ( fieldsToIndex ) ,
214
+ documentGenerator ,
215
+ [ "core" ] ) ;
216
+ makeInsertTestForDocType ( name + ".WildCardIndexNoProjection" ,
217
+ getSetupFunctionWithWildCardIndex ( [ ] ) ,
256
218
documentGenerator ,
257
219
[ "core" ] ) ;
258
220
makeInsertTestForDocType ( name + ".StandardIndex" ,
0 commit comments