PUT FIRST THING FIRST

本文分享了一次失败的工作计划经历,并探讨了三种不同的任务管理方法:备忘录式、日程表式和优先级式,最终强调了优先处理重要事项的重要性。

今天本来是这么安排的:

1 上午 看课题的东西,论文 MFC或者别的什么,找找思路,找找感觉

2 下午 了解FF和IE在JS应用方面的不同之处,把原来在IE上开发的界面,做成兼容FF的

但是我的计划又没有完成,“又”。

这样下去工作效率低下,而且我最最重要的课题丝毫没有进展,太可怕了。

分析不能执行计划原因所在,是不能安排一个具体的工作,只是笼统的下午×××下午×××

结果看看着看看那儿,时间都溜掉了,什么都没干成。

最近看的一本书上说,做事情的计划安排大体分为3种:

1 备忘录式 把要做的事情事无巨细都记录下来,一一完成。这样的处理方式比较容易得到成就感,但是缺乏规划。

2 日程表式 对时间的安排有一个整体的认识,统一调配时间。

3 优先考虑重要的事情,不必要的事情少做或者不做,或者先不做。所谓要事第一的原则,保持最终要的事情的时间&效率。

显然,第三种方式是被推崇的,生活是一种习惯,思维方式也是,我要时时刻刻提醒自己

PUT FIRST THING FIRST

 

任务描述 本关任务:写一个HBase的MapReduce任务。 相关知识 为了完成本关任务,你需要掌握: 编写自己的MapReduce。 编写自己的MapReduce HBase结合MapReduce可以实现从HBase输入表到HBase输出表、从文件到HBase输出表、从HBase输入表到文件的几种场景。 下面我们来完成一个从HBase输入表到HBase输出表的需求:从HBase表里统计列族comment_info中列名content的字符串单词的出现次数,并把统计结果存到HBase列族为word_info,列名为count的另一个表里。 我们分析一下需求,统计的是字符串中单词的个数,则key应该为Text类型,value 为IntWritable类型,输入表名为args[0]。Map节点配置如下: String tablename = args[0]; String targetTable = args[1]; Scan scan = new Scan(); Job job = Job.getInstance(conf); TableMapReduceUtil.initTableMapperJob(tablename,scan,MyMapper.class, Text.class, IntWritable.class,job); Map节点的目的是切分字符串,获取单词名称,把单词名称当做key值,单词数1当成value值,写到context.write(key,value)方法中,Map方法如下: public class MyMapper extends TableMapper<Text, IntWritable> { private static byte[] family = "comment_info".getBytes(); private static byte[] column = "content".getBytes(); @Override protected void map(ImmutableBytesWritable rowKey, Result result, Context context) throws IOException, InterruptedException { byte[] value = result.getValue(family, column); String content = new String(value,"utf-8"); String[] split = content.split(","); for(String str : split) { Text text = new Text(str); IntWritable v = new IntWritable(1); context.write(text,v); } } } } 接下来我们配置及使用 Reduce 方法,输出表名为args[1], Reduce节点配置如下 TableMapReduceUtil.initTableReducerJob(args[1],MyReducer.class,job); 由于Reduce节点需要把统计结果放到Mutation中,而Mutation是个抽象类,一般都会使用继承它的Put类,进行数据写入,Reduce节点的使用方法如下: public class MyReducer extends TableReducer<Text, IntWritable, ImmutableBytesWritable> { private static byte[] family = "word_info".getBytes(); private static byte[] column = "count".getBytes(); @Override public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException { int sum = 0; for (IntWritable value : values) { sum += value.get(); } Put put = new Put(Bytes.toBytes(key.toString())); put.addColumn(family,column,Bytes.toBytes(sum)); context.write(null,put); } 最后提交任务,并阻塞等待job执行完成: job.waitForCompletion(); 至此你就做完了你的第一个HBase的MapReduce任务啦! 编程要求 根据提示,在右侧Begin - End区域内补充代码,完成一个从文件到HBase输出表的需求:使用MapReduce统计单词个数。 String[] args数组,第一个参数为输入文件, 第二个参数为输出表 输入文件内容如下: There will be no regret and sorrow if you fight with all your strength give a stranger one of your smiles. It might be the only sunshine he sees all day Victory belongs to the most persevering The world is his who enjoys it want it more that anything Love is the greatest refreshment in life The first step is as good as half over My heart is with you Cease to struggle and you cease to live He knows most who speaks least Until you make peace with who you are, you’ll never be content with what you have One needs 3 things to be truly happy living in the world: some thing to do, some one to love, some thing to hope for I lied when I said I didn’t like you. I lied when I said I didn’t care. I lie every time I try to tell myself I will never fall for you 统计文件内容里出现的单词个数,并把统计结果保存到列族为word_info,单词个数为count的字段,单词名称为rowkey的输出表里。 测试说明 补充完代码后,点击测评,平台会对你编写的代码进行测试,当你的结果与预期输出一致时,即为通过。 测试输入:t_comment t_word_count; 预期输出: word:I word_info:count 9 word:be word_info:count 4 word:is word_info:count 4 word:the word_info:count 4 word:to word_info:count 8 word:with word_info:count 4 word:you word_info:count 7
10-31
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值