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

Method registerCode

src/org/apache/pig/PigServer.java:657–695  ·  view source on GitHub ↗

Universal Scripting Language Support, see PIG-928 @param path path of the script file @param scriptingLang language keyword or scriptingEngine used to interpret the script @param namespace namespace defined for functions of this script @throws IOException

(String path, String scriptingLang, String namespace)

Source from the content-addressed store, hash-verified

655 * @throws IOException
656 */
657 public void registerCode(String path, String scriptingLang, String namespace)
658 throws IOException {
659 if (pigContext.scriptingUDFs.containsKey(path) &&
660 pigContext.scriptingUDFs.get(path).equals(namespace)) {
661 log.debug("Ignoring duplicate registration for scripting udf file " + path + " in namespace " + namespace);
662 return;
663 } else {
664 pigContext.scriptingUDFs.put(path, namespace);
665 }
666
667 FetchFileRet ret = FileLocalizer.fetchFile(pigContext.getProperties(), path);
668 File f = ret.file;
669 if (!f.canRead()) {
670 int errCode = 4002;
671 String msg = "Can't read file: " + path;
672 throw new FrontendException(msg, errCode,
673 PigException.USER_ENVIRONMENT);
674 }
675 String cwd = new File(".").getCanonicalPath();
676 String filePath = f.getCanonicalPath();
677 String nameInJar = filePath;
678 // Use the relative path in the jar, if the path specified is relative
679 if (!ret.didFetch) {
680 if (!new File(path).isAbsolute() && path.indexOf("." + File.separator) == -1) {
681 // In case of Oozie, the localized files are in a different
682 // directory symlinked to the current directory. Canonical path will not point to cwd.
683 nameInJar = path;
684 } else if (filePath.equals(cwd + File.separator + path)) {
685 // If user specified absolute path and it refers to cwd
686 nameInJar = filePath.substring(cwd.length() + 1);
687 }
688 }
689
690 pigContext.addScriptFile(nameInJar, filePath);
691 if(scriptingLang != null) {
692 ScriptEngine se = ScriptEngine.getInstance(scriptingLang);
693 se.registerFunctions(nameInJar, namespace, pigContext);
694 }
695 }
696
697 /**
698 * Register a query with the Pig runtime. The query is parsed and registered, but it is not

Calls 11

fetchFileMethod · 0.95
getInstanceMethod · 0.95
registerFunctionsMethod · 0.95
debugMethod · 0.80
lengthMethod · 0.80
addScriptFileMethod · 0.80
getMethod · 0.65
containsKeyMethod · 0.45
equalsMethod · 0.45
putMethod · 0.45
getPropertiesMethod · 0.45