jstests/aggregation/sources/densify/partitions.js
// Same as test one, but partitions are interleaved.
Same as test one, but partitions are interleaved.
Same as test one but partitions are interleaved .
function testTwo() {
    coll.drop();
    const testDocs = [
        {val: 0, partition: 0},
        {val: 0, partition: 1},
        {val: 2, partition: 1},
        {val: 2, partition: 0}
    ];
    assert.commandWorked(coll.insert(testDocs));
    let result = coll.aggregate([
        {$project: {_id: 0}},
        {
            $densify: {
                field: "val",
                partitionByFields: ["partition"],
                range: {step: 1, bounds: "partition"}
            }
        }
    ]);
    const resultArray = result.toArray();
    const testExpected = testDocs.concat([{val: 1, partition: 0}, {val: 1, partition: 1}]);
    assert(arrayEq(resultArray, testExpected), buildErrorString(resultArray, testExpected));
    coll.drop();
}
function testTwo ( ) { coll . drop ( ) ; const testDocs = [ { val : 0 , partition : 0 } , { val : 0 , partition : 1 } , { val : 2 , partition : 1 } , { val : 2 , partition : 0 } ] ; assert . commandWorked ( coll . insert ( testDocs ) ) ; let result = coll . aggregate ( [ { $project : { _id : 0 } } , { $densify : { field : "val" , partitionByFields : [ "partition" ] , range : { step : 1 , bounds : "partition" } } } ] ) ; const resultArray = result . toArray ( ) ; const testExpected = testDocs . concat ( [ { val : 1 , partition : 0 } , { val : 1 , partition : 1 } ] ) ; assert ( arrayEq ( resultArray , testExpected ) , buildErrorString ( resultArray , testExpected ) ) ; coll . drop ( ) ; }
Same as test one, but partitions are interleaved.
Same as test one but partitions are interleaved .