Skip to content

Commit

Permalink
Fix configureCompression method for FileSystemFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
arhimondr committed Apr 29, 2019
1 parent a62bb04 commit 785a503
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package com.facebook.presto.hive.util;

import com.facebook.presto.hadoop.FileSystemFactory;
import com.facebook.presto.hive.HiveCompressionCodec;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.ql.io.orc.OrcFile;
Expand All @@ -23,6 +24,7 @@
import java.util.Map;

import static com.facebook.hive.orc.OrcConf.ConfVars.HIVE_ORC_COMPRESSION;
import static com.google.common.base.Preconditions.checkArgument;
import static org.apache.hadoop.hive.conf.HiveConf.ConfVars.COMPRESSRESULT;
import static org.apache.hadoop.hive.conf.HiveConf.ConfVars.HIVE_ORC_DEFAULT_COMPRESS;
import static org.apache.hadoop.io.SequenceFile.CompressionType.BLOCK;
Expand Down Expand Up @@ -73,8 +75,19 @@ public static JobConf toJobConf(Configuration conf)

public static JobConf configureCompression(Configuration config, HiveCompressionCodec compression)
{
JobConf result = new JobConf(false);
copy(config, result);
JobConf result;
// FileSystemFactory is used to hack around the abuse of Configuration as a
// cache for FileSystem. See FileSystemFactory class for more details.
//
// It is caller's responsibility to create a copy if FileSystemFactory is used.
if (config instanceof FileSystemFactory) {
checkArgument(config instanceof JobConf, "config is not an instance of JobConf: %s", config.getClass());
result = (JobConf) config;
}
else {
result = new JobConf(false);
copy(config, result);
}
setCompressionProperties(result, compression);
return result;
}
Expand Down

0 comments on commit 785a503

Please sign in to comment.