jstests/aggregation/sources/densify/partitions.js
// Upper bound on range which is off-step from lower bound.
Upper bound on range which is off-step from lower bound.
Upper bound on range which is off - step from lower bound .
function rangeTestThree() {
    coll.drop();
    const testDocs = [
        {val: 0, partition: 0},
        {val: 10, partition: 1},
    ];
    const expectedDocs = [
        {val: 0, partition: 0},
        {val: 10, partition: 1},
        {val: 2, partition: 0},
        {val: 2, partition: 1},
        {val: 4, partition: 0},
        {val: 4, partition: 1},
    ];
    assert.commandWorked(coll.insert(testDocs));
    let result = coll.aggregate([
        {$project: {_id: 0}},
        {
            $densify:
                {field: "val", partitionByFields: ["partition"], range: {step: 2, bounds: [2, 5]}}
        }
    ]);
    const resultArray = result.toArray();
    assert(arrayEq(resultArray, expectedDocs), buildErrorString(resultArray, expectedDocs));
    coll.drop();
}
function rangeTestThree ( ) { coll . drop ( ) ; const testDocs = [ { val : 0 , partition : 0 } , { val : 10 , partition : 1 } , ] ; const expectedDocs = [ { val : 0 , partition : 0 } , { val : 10 , partition : 1 } , { val : 2 , partition : 0 } , { val : 2 , partition : 1 } , { val : 4 , partition : 0 } , { val : 4 , partition : 1 } , ] ; assert . commandWorked ( coll . insert ( testDocs ) ) ; let result = coll . aggregate ( [ { $project : { _id : 0 } } , { $densify : { field : "val" , partitionByFields : [ "partition" ] , range : { step : 2 , bounds : [ 2 , 5 ] } } } ] ) ; const resultArray = result . toArray ( ) ; assert ( arrayEq ( resultArray , expectedDocs ) , buildErrorString ( resultArray , expectedDocs ) ) ; coll . drop ( ) ; }
Upper bound on range which is off-step from lower bound.
Upper bound on range which is off - step from lower bound .