ArrayWritable实例
来源:互联网 发布:网络优化推广的宣传语 编辑:程序博客网 时间:2024/05/16 11:59
概述
- 作用
- Array类构造示例
- Array类使用示例
- 类似于java的动态数据ArrayList,可以在不知有多少数据量的情况下,动态向里面加数据
Array类构造示例
- 数组里添加很多歌Text,类似于ArrayList<string>
public class CookieArray extends ArrayWritable{public CookieArray(){super(Text.class);}public String toString() {String[] abc = toStrings();StringBuffer sBuffer = new StringBuffer();for (String string : abc) {sBuffer.append(string + ",");}if (sBuffer.length()==0) {return "";}sBuffer.deleteCharAt(sBuffer.lastIndexOf(","));return sBuffer.toString();}}
Array类构造示例
- Map端用其读取数据对象
public class logMapper extends Mapper<Text, CookieArray, xxx, yyy> {public void map(Text key, CookieArray value, Context context)throws IOException, InterruptedException {Writable[] loglist=value.get();for (Writable writable : loglist) { Text temp=(Text)writable; // do something using this temp}context.write(xxx, yyy);}}
- reduce端用其聚合
public class logReducer extends Reducer<Text, Text, Text, CookieArray> {public void reduce(Text key,Iterable<Text> values, Context context)throws IOException, InterruptedException {CookieArray cookieArray = new CookieArray();List<Text> littleCollection = new ArrayList<Text>();for (Text text : values) {littleCollection.add(text);}cookieArray.set(littleCollection.toArray(new Text[0]));context.write(key, cookieArray);}}
- ArrayWritable实例
- 自定义ArrayWritable
- sequencefile 和arraywritable问题解
- map/reduce 下ArrayWritable 的使用
- NoSuchMethodException: org.apache.hadoop.io.ArrayWritable.<init>问题解决总结
- 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- Linux动态链接库.so文件的创建与使用
- FireBreath插件在IE8上响应不了方向键
- go study first
- 测试
- 对Linux的进程内核栈的认识
- ArrayWritable实例
- ubuntu常用包管理命令
- 密码
- pig对应sql的基本命令
- JAVA设计模式(18) —适配器(Adapter)模式
- 国内外比较
- 改变下拉列表文字显示大小
- 用maven assembly插件打jar包实现依赖包归档
- Android 调试.so库文件