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

Method hadoopify

src/org/apache/pig/impl/io/FileLocalizer.java:556–588  ·  view source on GitHub ↗
(String filename, PigContext pigContext)

Source from the content-addressed store, hash-verified

554 }
555
556 public static String hadoopify(String filename, PigContext pigContext) throws IOException {
557 if (Shell.WINDOWS){
558 filename = filename.replace('\\','/');
559 }
560 if (filename.startsWith(LOCAL_PREFIX)) {
561 filename = filename.substring(LOCAL_PREFIX.length());
562 }
563
564 ElementDescriptor localElem =
565 pigContext.getLfs().asElement(filename);
566
567 if (!localElem.exists()) {
568 throw new FileNotFoundException(filename);
569 }
570
571 ElementDescriptor distribElem = pigContext.getDfs().asElement(
572 getTemporaryPath(pigContext).toString());
573
574 int suffixStart = filename.lastIndexOf('.');
575 if (suffixStart != -1) {
576 distribElem = pigContext.getDfs().asElement(distribElem.toString() +
577 filename.substring(suffixStart));
578 }
579
580 // TODO: currently the copy method in Data Storage does not allow to specify overwrite
581 // so the work around is to delete the dst file first, if it exists
582 if (distribElem.exists()) {
583 distribElem.delete();
584 }
585 localElem.copy(distribElem, null, false);
586
587 return distribElem.toString();
588 }
589
590 public static String fullPath(String filename, PigContext pigContext) throws IOException {
591 try {

Callers 4

generateURIMethod · 0.95
setUpMethod · 0.95
testInputCacheSpecsMethod · 0.95
setUpMethod · 0.95

Calls 10

existsMethod · 0.95
getTemporaryPathMethod · 0.95
deleteMethod · 0.95
copyMethod · 0.95
lengthMethod · 0.80
getLfsMethod · 0.80
getDfsMethod · 0.80
replaceMethod · 0.65
asElementMethod · 0.65
toStringMethod · 0.45

Tested by 4

generateURIMethod · 0.76
setUpMethod · 0.76
testInputCacheSpecsMethod · 0.76
setUpMethod · 0.76