You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by dv...@apache.org on 2011/11/30 00:58:59 UTC
svn commit: r1208152 - in /pig/branches/branch-0.10: CHANGES.txt
src/org/apache/pig/builtin/Invoker.java
Author: dvryaboy
Date: Tue Nov 29 23:58:58 2011
New Revision: 1208152
URL: http://svn.apache.org/viewvc?rev=1208152&view=rev
Log:
PIG-2384: Generic Invokers should use PigContext to resolve classes
Modified:
pig/branches/branch-0.10/CHANGES.txt
pig/branches/branch-0.10/src/org/apache/pig/builtin/Invoker.java
Modified: pig/branches/branch-0.10/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.10/CHANGES.txt?rev=1208152&r1=1208151&r2=1208152&view=diff
==============================================================================
--- pig/branches/branch-0.10/CHANGES.txt (original)
+++ pig/branches/branch-0.10/CHANGES.txt Tue Nov 29 23:58:58 2011
@@ -154,6 +154,8 @@ PIG-2228: support partial aggregation in
BUG FIXES
+PIG-2384: PIG-2384: Generic Invokers should use PigContext to resolve classes (dvryaboy)
+
PIG-2379: Bug in Schema.getPigSchema(ResourceSchema rSchema) improperly adds two level access (jcoveney via dvryaboy)
PIG-2184: Not able to provide positional reference to macro invocations (xutingz via daijy)
Modified: pig/branches/branch-0.10/src/org/apache/pig/builtin/Invoker.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.10/src/org/apache/pig/builtin/Invoker.java?rev=1208152&r1=1208151&r2=1208152&view=diff
==============================================================================
--- pig/branches/branch-0.10/src/org/apache/pig/builtin/Invoker.java (original)
+++ pig/branches/branch-0.10/src/org/apache/pig/builtin/Invoker.java Tue Nov 29 23:58:58 2011
@@ -31,6 +31,7 @@ import org.apache.commons.logging.LogFac
import org.apache.pig.backend.executionengine.ExecException;
import org.apache.pig.data.DataBag;
import org.apache.pig.data.Tuple;
+import org.apache.pig.impl.PigContext;
import org.apache.pig.impl.logicalLayer.FrontendException;
import com.google.common.collect.Lists;
@@ -58,16 +59,23 @@ public class Invoker<T> {
private Class<?> selfClass_;
private Type returnType_;
- public Invoker(String fullName, String paramSpecsStr)
+ public Invoker(String fullName, String paramSpecsStr)
throws ClassNotFoundException, FrontendException, SecurityException, NoSuchMethodException {
this(fullName, paramSpecsStr, "true");
}
- public Invoker(String fullName, String paramSpecsStr, String isStatic)
+ public Invoker(String fullName, String paramSpecsStr, String isStatic)
throws ClassNotFoundException, FrontendException, SecurityException, NoSuchMethodException {
String className = fullName.substring(0, fullName.lastIndexOf('.'));
String methodName = fullName.substring(fullName.lastIndexOf('.')+1);
- Class<?> klazz = Class.forName(className);
+ Class<?> klazz;
+ try {
+ klazz = PigContext.resolveClassName(className);
+ } catch (IOException e) {
+ // the amusing part is that PigContext throws this to wrap one of
+ // the exceptions we declare!
+ throw new FrontendException(e);
+ }
String[] paramSpecs = "".equals(paramSpecsStr) ? new String[0] : paramSpecsStr.split(" ");
isStatic_ = "static".equalsIgnoreCase(isStatic) || "true".equals(isStatic);
paramClasses_ = new Class<?>[paramSpecs.length];
@@ -99,7 +107,7 @@ public class Invoker<T> {
return new Object[0];
} else {
return Arrays.copyOfRange(original, 1, original.length-1);
- }
+ }
}
private static Class<?> stringToClass(String klass) throws FrontendException {
@@ -123,7 +131,7 @@ public class Invoker<T> {
return FLOAT_ARRAY_CLASS;
} else if ("string[]".equalsIgnoreCase(klass)) {
return STRING_ARRAY_CLASS;
- } else {
+ } else {
throw new FrontendException("unable to find matching class for " + klass);
}
@@ -203,7 +211,7 @@ public class Invoker<T> {
}
private Object[] tupleToArgs(Tuple t) throws ExecException {
- if ( (t == null && (paramClasses_ != null || paramClasses_.length != 0))
+ if ( (t == null && (paramClasses_ != null || paramClasses_.length != 0))
|| (t != null && t.size() < paramClasses_.length)) {
throw new ExecException("unable to match function arguments to declared signature.");
}