不能说のsecret 7

来源:互联网 发布:seo博客资源 编辑:程序博客网 时间:2024/04/29 18:23

一段混沌时期过去了,有些无奈,有些疯狂,有些欢喜,有些迷失,总之,它是过去了。

之前的一段时间给新来的博士老师查资料,关于列车联网的,什么CTCS3,ETCS,CTC,TDCS,TDMS,TDCS,RSM-R等一系列新名词,还好也算努力的去做然后交工了,如果有这方面需要的,可以提供一些资料(只保证近期不会删除)。

最近在看了老师给的一些资料,主要是hadoop权威指南,对这个平台,包括HDFS和MapReduce有了一些浅显的理解,我知道开始都是比较困难的,慢慢的坚持吧。俗话说好记忆不如烂笔头,看的同时也记录了一些比较重要又不是很容易理解的知识点,防止过后就忘(虽然这样保质期也不长,o(︶︿︶)o 唉)。

说好的hadoop平台被一拖再拖,实在是有点心有愧疚,前天在实验室3台电脑组成的集群上编写了第一个可以被认为是mapreduce程序的小应用,在网上下载了一个云层天气数据集,120个文件作为输入,通过程序查看单个站点十几年的天气变化情况,几分钟处理了几亿条数据还是令我这小菜鸟蛮吃惊的,程序虽然比较简单,类似与wordcount,不过麻雀虽小,五脏还是不少的,至少练习了MapReduce程序的开发过程,这个应该算是比较基础的了,继续熟悉才能深入吧。

附上这个简单实现:

import java.io.IOException;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.fs.Path;import org.apache.hadoop.io.IntWritable;import org.apache.hadoop.io.LongWritable;import org.apache.hadoop.io.Text;import org.apache.hadoop.mapreduce.Job;import org.apache.hadoop.mapreduce.Mapper;import org.apache.hadoop.mapreduce.Reducer;import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;import org.apache.hadoop.util.GenericOptionsParser;/** * 记录同一观测站的天气状况出现的次数 * key=年月+天气状况 value=次数 *      Ppt        precipitation            ww= 50-75,77,79,80-99              .        D          drizzle                    50-59                            .        R          rain                       60-69                            .        S          snow                       70-75,77,79                      .        Ts         thunderstorm,shower        80-99                            . * @author ubuntu * 2012.8.11 */public class WeatherCount {public static class WeatherCountMapper extends Mapper<LongWritable, Text, Text, IntWritable>{private final static IntWritable one = new IntWritable(1);protected void map(LongWritable key, Text value, Context context)throws IOException, InterruptedException {String line = value.toString();//读取一行String time = line.substring(0,4);//年月int station = Integer.parseInt(line.substring(19,24).trim());//站台if(station==71906){String ww = line.substring(25,27);//天气指标int weatherIndex = 0;//天气指数String weather = null;if(!ww.equals("-1")){//-1代表数据丢失weatherIndex = Integer.parseInt(ww.trim());if(weatherIndex>=50&&weatherIndex<=59)weather = "drizzle";else if(weatherIndex>=60&&weatherIndex<=69)weather = "rain";else if((weatherIndex>=70&&weatherIndex<=75)||weatherIndex==77||weatherIndex==79)weather = "snow";else if(weatherIndex>=80&&weatherIndex<=99)weather = "thunderstorm";if(weather!=null){context.write(new Text(time+weather), one);}}}}}public static class WeatherCountReducer extends Reducer<Text, IntWritable, Text, IntWritable>{protected void reduce(Text key, Iterable<IntWritable> values,Context context)throws IOException, InterruptedException {int sum = 0;for(IntWritable value : values){sum += value.get();}context.write(key, new IntWritable(sum));}}public static void main(String[] args) throws Exception{Configuration conf = new Configuration();String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();if(otherArgs.length!=2){System.err.println("Usage:WeatherCount <input path> <output path>");System.exit(-1);}Job job = new Job(conf,"weather count");job.setJarByClass(WeatherCount.class);FileInputFormat.addInputPath(job, new Path(otherArgs[0]));FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));job.setMapperClass(WeatherCountMapper.class);job.setCombinerClass(WeatherCountReducer.class);job.setReducerClass(WeatherCountReducer.class);job.setOutputKeyClass(Text.class);job.setOutputValueClass(IntWritable.class);System.exit(job.waitForCompletion(true)?0:1);}}


今天把系科系统(CxServer)给搭上了,虽然是好久之前老师让改的,但是还是觉得这个系统比较难懂,用wt库加C++编写的网站,实在让我头大,加上不是很熟悉的Linux服务器……不过,由于第一次部署这个系统时比较用心,克服了许多困难,上论坛,搜网页,解决了很多问题,(包括程序自己的!),这次搭的时候还算比较顺利,下午放到了学校的服务器上,加了url转发,外网算是可以登录了,对于这个创新基金管理系统,如果遇到了搭建问题,也可以一起讨论。

至于感情,我想,我是觉得好寂寞了……前两天打球时遇到了她,话说人家现在过的很好,我真是屌丝,就不能也信守承诺,过自己的生活么!?有句话说的好,想要忘记就要“不要见,不要贱”。

人生总是要遇到无可知的路途,暂时的迷失不要紧,大方向不能丢,时常让自己快乐,疯狂,忘我,青春就是用来还债的。

决定去健身了,hold不住了。如果你是宅,请记得有个好身体。

原创粉丝点击