You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by da...@apache.org on 2013/03/18 23:02:46 UTC
svn commit: r1458035 -
/pig/branches/branch-0.11/test/org/apache/pig/test/utils/UDFContextTestLoaderWithSignature.java
Author: daijy
Date: Mon Mar 18 22:02:45 2013
New Revision: 1458035
URL: http://svn.apache.org/r1458035
Log:
PIG-3132: NPE when illustrating a relation with HCatLoader (check in missing UDFContextTestLoaderWithSignature.java)
Added:
pig/branches/branch-0.11/test/org/apache/pig/test/utils/UDFContextTestLoaderWithSignature.java
Added: pig/branches/branch-0.11/test/org/apache/pig/test/utils/UDFContextTestLoaderWithSignature.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.11/test/org/apache/pig/test/utils/UDFContextTestLoaderWithSignature.java?rev=1458035&view=auto
==============================================================================
--- pig/branches/branch-0.11/test/org/apache/pig/test/utils/UDFContextTestLoaderWithSignature.java (added)
+++ pig/branches/branch-0.11/test/org/apache/pig/test/utils/UDFContextTestLoaderWithSignature.java Mon Mar 18 22:02:45 2013
@@ -0,0 +1,37 @@
+package org.apache.pig.test.utils;
+
+import java.io.IOException;
+import java.util.Properties;
+
+import org.apache.hadoop.mapreduce.Job;
+import org.apache.pig.builtin.PigStorage;
+import org.apache.pig.data.Tuple;
+import org.apache.pig.impl.util.UDFContext;
+
+public class UDFContextTestLoaderWithSignature extends PigStorage {
+ private String val;
+
+ public UDFContextTestLoaderWithSignature(String v1) {
+ val = v1;
+ }
+
+ @Override
+ public void setLocation(String location, Job job)
+ throws IOException {
+ super.setLocation(location, job);
+ Properties p = UDFContext.getUDFContext().getUDFProperties(this.getClass());
+ if (p.get(signature)==null) {
+ p.put("test_" + signature, val);
+ }
+ }
+
+ @Override
+ public Tuple getNext() throws IOException {
+ Tuple t = super.getNext();
+ if (t!=null) {
+ Properties p = UDFContext.getUDFContext().getUDFProperties(this.getClass());
+ t.append(p.get("test_" + signature));
+ }
+ return t;
+ }
+}