File: orq.js

package info (click to toggle)
mongodb 1%3A2.4.10-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 82,464 kB
  • sloc: cpp: 740,225; ansic: 152,098; sh: 13,820; python: 11,864; makefile: 1,012; perl: 922; pascal: 617; java: 452; lisp: 222; asm: 174
file content (43 lines) | stat: -rw-r--r-- 1,275 bytes parent folder | download | duplicates (3)
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
// $or clause deduping with result set sizes > 101 (smaller result sets are now also deduped by the
// query optimizer cursor).

t = db.jstests_orq;
t.drop();

t.ensureIndex( { a:1 } );
t.ensureIndex( { b:1 } );
t.ensureIndex( { c:1 } );

for( i = 0; i < 200; ++i ) {
    t.save( { a:1, b:1 } );
}

// Deduping results from the previous clause.
assert.eq( 200, t.count( { $or:[ { a:1 }, { b:1 } ] } ) );

// Deduping results from a prior clause.
assert.eq( 200, t.count( { $or:[ { a:1 }, { c:1 }, { b:1 } ] } ) );
t.save( { c:1 } );
assert.eq( 201, t.count( { $or:[ { a:1 }, { c:1 }, { b:1 } ] } ) );

// Deduping results that would normally be index only matches on overlapping and double scanned $or
// field regions.
t.drop();
t.ensureIndex( { a:1, b:1 } );
for( i = 0; i < 16; ++i ) {
    for( j = 0; j < 16; ++j ) {
        t.save( { a:i, b:j } );
    }
}
assert.eq( 16 * 16,
          t.count( { $or:[ { a:{ $gte:0 }, b:{ $gte:0 } }, { a:{ $lte:16 }, b:{ $lte:16 } } ] } ) );

// Deduping results from a clause that completed before the multi cursor takeover.
t.drop();
t.ensureIndex( { a:1 } );
t.ensureIndex( { b:1 } );
t.save( { a:1,b:200 } );
for( i = 0; i < 200; ++i ) {
    t.save( { b:i } );
}
assert.eq( 201, t.count( { $or:[ { a:1 }, { b:{ $gte:0 } } ] } ) );