(String fname)
| 396 | } |
| 397 | |
| 398 | private FetchFileRet getMacroFile(String fname) { |
| 399 | FetchFileRet localFileRet = null; |
| 400 | try { |
| 401 | if (fnameMap.get(fname) != null) { |
| 402 | localFileRet = fnameMap.get(fname); |
| 403 | } else { |
| 404 | try { |
| 405 | File localFile = QueryParserUtils.getFileFromImportSearchPath(fname); |
| 406 | localFileRet = localFile == null ? |
| 407 | FileLocalizer.fetchFile(pigContext.getProperties(), fname) |
| 408 | : new FetchFileRet(localFile.getCanonicalFile(), false); |
| 409 | } catch (FileNotFoundException e) { |
| 410 | // ignore this since we'll attempt to load as a resource before failing |
| 411 | LOG.debug(String.format("Macro file %s was not found", fname)); |
| 412 | } |
| 413 | |
| 414 | // try loading the macro file as a resource in case it is packaged in a registered jar |
| 415 | if (localFileRet == null) { |
| 416 | LOG.debug(String.format("Attempting to load macro file %s as a resource", fname)); |
| 417 | |
| 418 | try |
| 419 | { |
| 420 | localFileRet = FileLocalizer.fetchResource(fname); |
| 421 | LOG.debug(String.format("Found macro file %s as resource", fname)); |
| 422 | } |
| 423 | catch (ResourceNotFoundException e) |
| 424 | { |
| 425 | LOG.debug(String.format("Macro file %s was not found as resource either", fname)); |
| 426 | LOG.error(String.format("Failed to find macro file %s", fname)); |
| 427 | throw new ExecException("file '" + fname + "' does not exist.", 101, PigException.INPUT); |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | fnameMap.put(fname, localFileRet); |
| 432 | } |
| 433 | } catch (IOException e) { |
| 434 | throw new RuntimeException("Unable to fetch macro file '" + fname + "'", e); |
| 435 | } |
| 436 | return localFileRet; |
| 437 | } |
| 438 | |
| 439 | /* |
| 440 | * MacroDef node has two child nodes: |
no test coverage detected