Map:
public static class HibMapper extends Mapper{
public void map(Object key,Object value,Context context) throws IOException,InterruptedException {
Configuration conf=new Configuration();
conf.set("fs.defaultFS", "hdfs://192.168.10.2:9000");
HipiImageBundle hib = new HipiImageBundle(new Path("/test/output/corel/test/coreltest.hib"), conf);
hib.open(AbstractImageBundle.FILE_MODE_WRITE,true);
String path = value.toString();
try{
File file = new File(path);
FileInputStream fis=new FileInputStream(file);
hib.addImage(fis,ImageType.JPEG_IMAGE);
}catch (IOException e) {
System.err.println("Connection error to image !" );
}
hib.close();
System.out.println(path);
context.write(new Text(path.toString()), new Text(hib.getPath().toString()));
}
}
Reduce 空,得到的hib文件只包括最后一张图片,System.out.println(path)中可以输出所有路径,原因出在哪里?
每次创建的hib都覆盖掉前一次了,应用hib.addImage()方法,每次添加