RecordStreamFactory factout;
@Override
protected void copyFile(FileSystem fsSource, Path source, FileSystem fsDest, Path target, Reporter reporter) throws IOException {
RecordInputStream fin = factin.getInputStream(fsSource, source);
RecordOutputStream fout = factout.getOutputStream(fsDest, target);
try {
byte[] record;
int bytes = 0;
while((record = fin.readRawRecord()) != null) {
fout.writeRaw(record);
bytes+=record.length;
if(bytes >= 1000000) { //every 1 MB of data report progress so we don't time out on large files
bytes = 0;
reporter.progress();
}
}
} finally {
fin.close();
}
//don't complete files that aren't done yet. prevents partial files from being written
fout.close();
}