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:58 UTC

svn commit: r1458036 - /pig/trunk/test/org/apache/pig/test/utils/UDFContextTestLoaderWithSignature.java

Author: daijy
Date: Mon Mar 18 22:02:58 2013
New Revision: 1458036

URL: http://svn.apache.org/r1458036
Log:
PIG-3132:  NPE when illustrating a relation with HCatLoader (check in missing UDFContextTestLoaderWithSignature.java)

Added:
    pig/trunk/test/org/apache/pig/test/utils/UDFContextTestLoaderWithSignature.java

Added: pig/trunk/test/org/apache/pig/test/utils/UDFContextTestLoaderWithSignature.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/utils/UDFContextTestLoaderWithSignature.java?rev=1458036&view=auto
==============================================================================
--- pig/trunk/test/org/apache/pig/test/utils/UDFContextTestLoaderWithSignature.java (added)
+++ pig/trunk/test/org/apache/pig/test/utils/UDFContextTestLoaderWithSignature.java Mon Mar 18 22:02:58 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;
+    }
+}