String转Text:
String line="abcdefg";
Text text=new Text(line);
Text转String:
(Text values)
String line=values.toString;
int转IntWritable:
IntWritable one=new IntWritable(1);
IntWritable转int:
int sum=0;
while(values.hasNext()){
sum+=values.next().get();
}
boolean数组转ArrayWritable
ArrayWritable ant=new ArrayWritable(BooleanWritable.class);
BooleanWritable[] arr = new BooleanWritable[obNum];
for (){
arr[i] = new BooleanWritable(true);
}
ant.set(arr);
ArrayWritable转boolean数组
ArrayWritable arr = values.next();
Object[] objs = arr.get();
for (Object obj: objs){
Boolean b = (Boolean)obj;
}
ArrayWritable转其他类型
values是ArrayWritable
Object []d=(Object [])values.toArray();
double mone = (Double)d[0];
boolean数组转化ArrayWritable
ArrayWritable arr;
boolean[] array
try{
this.arr = IO.makeWritableArray(boolean.class, array);
}catch(ClassNotFoundException e){
e.printStackTrace();
}
ArrayWritable转化boolean数组
array=IO.extractBoolArray(arr);
阅读(809) | 评论(0) | 转发(0) |