### 第1关:统计每个城市的宾馆平均价格
```
/********** Begin *********/
//1.获取城市id
String cityId = Bytes.toString(result.getValue("cityInfo".getBytes(), "cityId".getBytes()));
byte[] value = result.getValue(family, column);
//获取酒店价格
//String cityId1 = Bytes.toString(result.getValue("hotel_info".getBytes(), "price".getBytes()));
//将价格转换为double
Double ho =Double.parseDouble(Bytes.toString(value));
//将价格转换成()类型
DoubleWritable i = new DoubleWritable(ho);
String key = cityId;
//写出(城市id,酒店价格)
context.write(new Text(key),i);
/********** End *********/
```
```
/********** Begin *********/
double sum=0;
int count=0;
for(DoubleWritable value:values){
count++;
sum+=value.get();
}
double avePrice=sum/count;
//创建pit对象
Put put =new Put(Bytes.toBytes(key.toString()));
put.addColumn("average_infos".getBytes(),"price".getBytes(),Bytes.toBytes(String.valueOf(avePrice)));
context.write(null,put);
/********** End *********/
```
### 第2关:统计酒店评论中词频较高的词
```
/********** Begin *********/
byte[] value = result.getValue(family, column);
String word = new String(value,"utf-8");
if(!word.isEmpty()){
String filter = EmojiParser.removeAllEmojis(word);
List<Word> segs = WordSegmenter.seg(filter);
for(Word cont : segs) {
Text text = new Text(cont.getText());
IntWritable v = new IntWritable(1);
context.write(text,v);
}
}
/********** End *********/
```
```
/********** Begin *********/
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);
/********** End *********/
```