成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

學(xué)習(xí)日志---partitioner和采樣器

Mapreduce中:

成都創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作、盤龍網(wǎng)絡(luò)推廣、重慶小程序開發(fā)、盤龍網(wǎng)絡(luò)營(yíng)銷、盤龍企業(yè)策劃、盤龍品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);成都創(chuàng)新互聯(lián)公司為所有大學(xué)生創(chuàng)業(yè)者提供盤龍建站搭建服務(wù),24小時(shí)服務(wù)熱線:18982081108,官方網(wǎng)址:jinyejixie.com

shuffle階段是在map和reduce之間,可以自定義排序,自定義分區(qū)和自定義分組!

Mapreduce中,map出的數(shù)據(jù)是鍵值對(duì),默認(rèn)的是hashPatitionner來(lái)對(duì)map出的數(shù)據(jù)進(jìn)行分區(qū);

分區(qū)的方法還有其他幾個(gè):

RandomSampler<Text, Text> sampler = 
                     new InputSampler.RandomSampler<Text, Text>(0.5, 3000, 10);
IntervalSampler<Text, Text> sampler2 = 
                    new InputSampler.IntervalSampler<Text, Text>(0.333, 10);
SplitSampler<Text, Text> sampler3 = 
                    new InputSampler.SplitSampler<Text, Text>(reduceNumber);

實(shí)現(xiàn)和細(xì)節(jié)

public class TotalSortMR { 
      
    @SuppressWarnings("deprecation")
    public static int runTotalSortJob(String[] args) throws Exception {  
        Path inputPath = new Path(args[0]);  
        Path outputPath = new Path(args[1]);  
        Path partitionFile = new Path(args[2]);  
        int reduceNumber = Integer.parseInt(args[3]);  
          

        //三種采樣器
        RandomSampler<Text, Text> sampler = new InputSampler.RandomSampler<Text, Text>(1, 3000, 10);
        IntervalSampler<Text, Text> sampler2 = new InputSampler.IntervalSampler<Text, Text>(0.333, 10);
        SplitSampler<Text, Text> sampler3 = new InputSampler.SplitSampler<Text, Text>(reduceNumber);
        
        //任務(wù)初始化
        Configuration conf = new Configuration();  
        Job job = Job.getInstance(conf);
        
        job.setJobName("Total-Sort");  
        job.setJarByClass(TotalSortMR.class);  
        job.setInputFormatClass(KeyValueTextInputFormat.class);  
        job.setMapOutputKeyClass(Text.class);  
        job.setMapOutputValueClass(Text.class);  
        job.setNumReduceTasks(reduceNumber);  

        //設(shè)置所有的分區(qū)類
        job.setPartitionerClass(TotalOrderPartitioner.class);  
        //分區(qū)類參考的分區(qū)文件
        TotalOrderPartitioner.setPartitionFile(conf, partitionFile);  
        //分區(qū)使用哪種采樣器
        InputSampler.writePartitionFile(job, sampler); 
        
        //job的輸入和輸出路徑
        FileInputFormat.setInputPaths(job, inputPath);  
        FileOutputFormat.setOutputPath(job, outputPath);  
        outputPath.getFileSystem(conf).delete(outputPath, true);  
          
        return job.waitForCompletion(true)? 0 : 1;
    }  
      
    public static void main(String[] args) throws Exception{  
        System.exit(runTotalSortJob(args));  
    }
}

job默認(rèn)的輸入格式是TextInputFormat,這個(gè)是key-value的形式,key是每行的行標(biāo),value是每行的內(nèi)容??梢愿?/p>

job.setInputFormatClass(,....)

一般要設(shè)置mapper的輸出格式,以備后面使用。

新聞標(biāo)題:學(xué)習(xí)日志---partitioner和采樣器
文章位置:http://jinyejixie.com/article32/psphsc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航自適應(yīng)網(wǎng)站、關(guān)鍵詞優(yōu)化網(wǎng)站制作、做網(wǎng)站、用戶體驗(yàn)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)
弥勒县| 雅江县| 孝义市| 孝义市| 泸西县| 广饶县| 克东县| 安龙县| 凭祥市| 惠安县| 明星| 琼海市| 准格尔旗| 白山市| 徐闻县| 山西省| 四会市| 页游| 保山市| 文成县| 鹤壁市| 聂拉木县| 门头沟区| 江西省| 丹东市| 海宁市| 长春市| 建平县| 敦化市| 徐汇区| 界首市| 霍州市| 禄劝| 大兴区| 高台县| 阳西县| 莱西市| 武邑县| 剑川县| 大埔县| 文化|