MCPcopy Create free account
hub / github.com/apache/pig / setTmpFileCompressionOnConf

Method setTmpFileCompressionOnConf

src/org/apache/pig/impl/util/Utils.java:415–453  ·  view source on GitHub ↗
(PigContext pigContext, Configuration conf)

Source from the content-addressed store, hash-verified

413 }
414
415 public static void setTmpFileCompressionOnConf(PigContext pigContext, Configuration conf) throws IOException{
416 // PIG-3741 This is also called for non-intermediate jobs, do not set any mapred properties here
417 if (pigContext == null) {
418 return;
419 }
420 TEMPFILE_STORAGE storage = getTmpFileStorage(pigContext.getProperties());
421 String codec = pigContext.getProperties().getProperty(
422 PigConfiguration.PIG_TEMP_FILE_COMPRESSION_CODEC, "");
423 switch (storage) {
424 case INTER:
425 break;
426 case SEQFILE:
427 conf.set(PigConfiguration.PIG_TEMP_FILE_COMPRESSION_STORAGE, "seqfile");
428 if ("".equals(codec)) {
429 // codec is not specified, ensure is set
430 log.warn("Temporary file compression codec is not specified. Using " +
431 MRConfiguration.OUTPUT_COMPRESSION_CODEC + " property.");
432 if(conf.get(MRConfiguration.OUTPUT_COMPRESSION_CODEC) == null) {
433 throw new IOException(MRConfiguration.OUTPUT_COMPRESSION_CODEC + " is not set");
434 }
435 } else if(storage.ensureCodecSupported(codec)) {
436 // do nothing
437 } else {
438 throw new IOException("Invalid temporary file compression codec [" + codec + "]. " +
439 "Expected compression codecs for " + storage.getStorageClass().getName() +
440 " are " + storage.supportedCodecsToString() + ".");
441 }
442 break;
443 case TFILE:
444 if(storage.ensureCodecSupported(codec)) {
445 conf.set(PigConfiguration.PIG_TEMP_FILE_COMPRESSION_CODEC, codec.toLowerCase());
446 } else {
447 throw new IOException("Invalid temporary file compression codec [" + codec + "]. " +
448 "Expected compression codecs for " + storage.getStorageClass().getName() +
449 " are " + storage.supportedCodecsToString() + ".");
450 }
451 break;
452 }
453 }
454
455 public static String getStringFromArray(String[] arr) {
456 StringBuilder str = new StringBuilder();

Callers 2

initMethod · 0.95
getJobMethod · 0.95

Calls 11

getTmpFileStorageMethod · 0.95
ensureCodecSupportedMethod · 0.95
getStorageClassMethod · 0.95
getPropertyMethod · 0.80
setMethod · 0.65
warnMethod · 0.65
getMethod · 0.65
getPropertiesMethod · 0.45
equalsMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected