* the index file is deleted (in line with {@link LzoIndexer} behavior).
*/
public static DataOutputStream
getIndexedLzoOutputStream(Configuration conf, Path path) throws IOException {
LzopCodec codec = new LzopCodec();
codec.setConf(conf);
final Path file = path;
final FileSystem fs = file.getFileSystem(conf);
FSDataOutputStream fileOut = fs.create(file, false);
FSDataOutputStream indexOut = null;
if (conf.getBoolean("elephantbird.lzo.output.index", false)) {
if ( isLzopIndexSupported ) {
Path indexPath = file.suffix(LzoIndex.LZO_TMP_INDEX_SUFFIX);
indexOut = fs.create(indexPath, false);
} else {
LOG.warn("elephantbird.lzo.output.index is enabled, but LzopCodec "
+ "does not have createIndexedOutputStream method. "
+ "Please upgrade hadoop-lzo.");
}
}
final boolean isIndexed = indexOut != null;
OutputStream out = ( isIndexed ?
codec.createIndexedOutputStream(fileOut, indexOut) :
codec.createOutputStream(fileOut) );
return new DataOutputStream(out) {
// override close() to handle renaming index file.
public void close() throws IOException {