zoukankan      html  css  js  c++  java
  • 022 StringTokenizer替换掉String的操作

    一:说明

    1.说明

      String的操作特别消耗内存,所以可以考虑优化。

    二:程序

    1.程序修改

      这部分程序属于Mapper端的程序,稍微优化一下。

    2.程序

     1 //Mapper
     2     public static class WordCountMapper extends Mapper<LongWritable,Text,Text,IntWritable>{
     3         private Text mapoutputkey=new Text();
     4         private static final IntWritable mapoutputvalue=new IntWritable(1);
     5         @Override
     6         protected void map(LongWritable key, Text value, Context context)throws IOException, InterruptedException {
     7             String lineValue=value.toString();
     8             StringTokenizer stringTokenizer =new StringTokenizer(lineValue);
     9             while(stringTokenizer.hasMoreTokens()){
    10                 mapoutputkey.set(stringTokenizer.nextToken());
    11                 context.write(mapoutputkey, mapoutputvalue);
    12             }        
    13         }
    14         
    15     }
  • 相关阅读:
    [BZOJ1303][CQOI2009]中位数图
    [BZOJ1192][HNOI2006]鬼谷子的钱袋
    9.5题解
    9.3题解
    9.2题解
    9.1题解
    8.29题解
    8.28题解
    8.23<2>题解
    8.23<1>题解
  • 原文地址:https://www.cnblogs.com/juncaoit/p/8214683.html
Copyright © 2011-2022 走看看