まず、すべての画像を Hadoop sequenceFile にパックします。
FSDataInputStream in = null;
in = fs.open(new Path(uri)); //uri is the image location in HDFS
byte buffer[] = new byte[in.available()];
in.read(buffer);
context.write(imageID, new BytesWritable(buffer));
次に、リデューサーで元の画像をシーケンス ファイルから取得したいと考えています。
BufferedImage imag;
imag = ImageIO.read(new ByteArrayInputStream(value.getBytes()));
しかし、次のエラーがあるため、画像が正しく取得されません。
Error: javax.imageio.IIOException: Error reading PNG image data
Caused by: java.io.EOFException: Unexpected end of ZLIB input stream
私の質問は、hadoop でシーケンス ファイルから元の画像を取得する方法ですか?