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 2012/02/04 02:42:53 UTC
svn commit: r1240435 - in /pig/branches/branch-0.10: CHANGES.txt
src/org/apache/pig/builtin/MonitoredUDF.java
test/org/apache/pig/test/TestMonitoredUDF.java
Author: dvryaboy
Date: Sat Feb 4 01:42:53 2012
New Revision: 1240435
URL: http://svn.apache.org/viewvc?rev=1240435&view=rev
Log:
PIG-2503: Make @MonitoredUDF inherited
Modified:
pig/branches/branch-0.10/CHANGES.txt
pig/branches/branch-0.10/src/org/apache/pig/builtin/MonitoredUDF.java
pig/branches/branch-0.10/test/org/apache/pig/test/TestMonitoredUDF.java
Modified: pig/branches/branch-0.10/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.10/CHANGES.txt?rev=1240435&r1=1240434&r2=1240435&view=diff
==============================================================================
--- pig/branches/branch-0.10/CHANGES.txt (original)
+++ pig/branches/branch-0.10/CHANGES.txt Sat Feb 4 01:42:53 2012
@@ -24,6 +24,8 @@ INCOMPATIBLE CHANGES
IMPROVEMENTS
+PIG-2503: Make @MonitoredUDF inherited (dvryaboy)
+
PIG-2468: Speed up TestBuiltin (dvryaboy)
PIG-2467: Speed up TestCommit (dvryaboy)
Modified: pig/branches/branch-0.10/src/org/apache/pig/builtin/MonitoredUDF.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.10/src/org/apache/pig/builtin/MonitoredUDF.java?rev=1240435&r1=1240434&r2=1240435&view=diff
==============================================================================
--- pig/branches/branch-0.10/src/org/apache/pig/builtin/MonitoredUDF.java (original)
+++ pig/branches/branch-0.10/src/org/apache/pig/builtin/MonitoredUDF.java Sat Feb 4 01:42:53 2012
@@ -19,6 +19,7 @@
package org.apache.pig.builtin;
import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.concurrent.TimeUnit;
@@ -49,6 +50,7 @@ import org.apache.pig.classification.Int
@InterfaceAudience.Public
@InterfaceStability.Unstable
@Documented
+@Inherited
@Retention(value=RetentionPolicy.RUNTIME)
public @interface MonitoredUDF {
/**
Modified: pig/branches/branch-0.10/test/org/apache/pig/test/TestMonitoredUDF.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.10/test/org/apache/pig/test/TestMonitoredUDF.java?rev=1240435&r1=1240434&r2=1240435&view=diff
==============================================================================
--- pig/branches/branch-0.10/test/org/apache/pig/test/TestMonitoredUDF.java (original)
+++ pig/branches/branch-0.10/test/org/apache/pig/test/TestMonitoredUDF.java Sat Feb 4 01:42:53 2012
@@ -51,6 +51,13 @@ public class TestMonitoredUDF {
}
@Test
+ public void testInheritance() throws IOException {
+ InheritedUdf udf = new InheritedUdf();
+ MonitoredUDFExecutor exec = new MonitoredUDFExecutor(udf);
+ assertEquals( SimpleIntUDF.DEFAULT, ((Integer) exec.monitorExec(null)).intValue());
+ }
+
+ @Test
public void testCustomErrorHandler() throws IOException {
ErrorCallbackUDF udf = new ErrorCallbackUDF();
@@ -66,6 +73,12 @@ public class TestMonitoredUDF {
assertTrue((Boolean) exec.monitorExec(null));
}
+ /**
+ * This main method runs a microbenchmark for measuring overhead caused by
+ * annotating a UDF as monitored.
+ * @param args
+ * @throws IOException
+ */
public static void main(String[] args) throws IOException {
long startTime = System.currentTimeMillis();
long unmonitoredTime = 0, monitoredTime = 0;
@@ -132,7 +145,7 @@ public class TestMonitoredUDF {
@MonitoredUDF(timeUnit = TimeUnit.MILLISECONDS, duration = 100, intDefault = SimpleIntUDF.DEFAULT)
- public class SimpleIntUDF extends EvalFunc<Integer> {
+ public static class SimpleIntUDF extends EvalFunc<Integer> {
public static final int DEFAULT = 123;
public static final int NOT_DEFAULT = 321;
@@ -147,6 +160,8 @@ public class TestMonitoredUDF {
}
}
+ public static class InheritedUdf extends SimpleIntUDF {}
+
@MonitoredUDF(timeUnit = TimeUnit.MILLISECONDS, duration = 100, errorCallback = CustomErrorCallback.class)
public class ErrorCallbackUDF extends EvalFunc<Integer> {