资源简介
很简单的,面向新手的一个MapReduce实例,对数据进行排序,对大数据理解很有帮助。
代码片段和文件信息
package cn.itcast.hadoop.mr.sort;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import org.apache.hadoop.io.WritableComparable;
public class InfoBean implements WritableComparable{
private String account;
private double income;
private double expenses;
private double surplus;
public void set(String account double income double expenses){
this.account = account;
this.income = income;
this.expenses = expenses;
this.surplus = income - expenses;
}
@Override
public String toString() {
return this.income + “\t“ + this.expenses + “\t“ + this.surplus;
}
/**
* serialize
*/
public void write(DataOutput out) throws IOException {
out.writeUTF(account);
out.writeDouble(income);
out.writeDouble(expenses);
out.writeDouble(surplus);
}
/**
* deserialize
*/
public void readFields(DataInput in) throws IOException {
this.account = in.readUTF();
this.income = in.readDouble();
this.expenses = in.readDouble();
this.surplus = in.readDouble();
}
public int compareTo(InfoBean o) {
if(this.income == o.getIncome()){
return this.expenses > o.getExpenses() ? 1 : -1;
} else {
return this.income > o.getIncome() ? -1 : 1;
}
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public double getIncome() {
return income;
}
public void setIncome(double income) {
this.income = income;
}
public double getExpenses() {
return expenses;
}
public void setExpenses(double expenses) {
this.expenses = expenses;
}
public double getSurplus() {
return surplus;
}
public void setSurplus(double surplus) {
this.surplus = surplus;
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1742 2014-06-03 16:03 sort\InfoBean.java
文件 2114 2014-06-03 15:58 sort\SortStep.java
文件 2184 2014-06-03 15:21 sort\SumStep.java
目录 0 2018-09-11 20:37 sort\
- 上一篇:移远MC20模块调试MPU6050
- 下一篇:基于Labview的用户登录程序
相关资源
- MapReduce数据统计简单
- mapreduce实战
- MapReduce下的k-means算法实验报告广工
- MapReduce字数统计案例
- 基于Apriori算法的频繁项集Hadoop mapre
- MapReduce maven工程WordCount
- KNN mapreduce实现
- hadoop MapReduce案例运营商关于用户基站
- 大数据 hadoop mapreduce 词频统计
- Google大数据三大经典论文
- 基于MapReduce的Apriori算法代码及其使用
- 基于MapReduce的Apriori算法代码
- PageRank算法的mapreduce实现
- Hadoop MapReduce实现tfidf源码
- windows64位平台的hadoop2.5.2插件包(ha
- MapReduce求解物流配送单源最短路径研
- 用MapReduce实现KMeans算法
- 基于mapreduce的并行算法的设计 课件
- 基于MapReduce的Apriori算法
- 林子雨大数据实验答案(包含截图)
- 在Hadoop的MapReduce任务中使用C程序的三
- Hadoop mapreduce 实现MatrixMultiply矩阵相乘
- Hadoop mapreduce 实现InvertedIndexer倒排索引
- NaiveBayesClassify朴素贝叶斯分类法-Map
- Hadoop基础面试题附答案
- 基于MapReduce的矩阵相乘算法代码及其
- Ubuntu安装Hadoop实现MapReduce里的WordCou
评论
共有 条评论