INNER CODE UNIT · JavaScript

unique3

kingschan1204/istock · src/main/resources/mapreduce/5years_dy/5dy-mapreduce.js:16

        function unique3(arr){
            arr.sort();
            var hash=[arr[0]];
            for (var i = 1; i < arr.length; i++) {
                if(arr[i]!=hash[hash.length-1]){
                    hash.push(arr[i]);
                }
            }
            return hash;
        }

        var arrays=unique3(array);
        return {percent:(total/arrays.length).toFixed(2),years:years,total:total,key:arrays.length};
    },   //reduce 函数
    {
        out: "stock_dy_statistics",
        query:{"title":{$gte:"2014"}},
        sort:{"code":1,"title":-1}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…