(PigContext pigContext, Configuration conf)
| 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(); |
no test coverage detected