pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject svn commit: r1358483 - in /pig/trunk: CHANGES.txt src/org/apache/pig/impl/util/Utils.java src/org/apache/pig/newplan/logical/relational/LOLoad.java test/commit-tests
Date Sat, 07 Jul 2012 00:41:04 GMT
Author: daijy
Date: Sat Jul  7 00:41:03 2012
New Revision: 1358483

URL: http://svn.apache.org/viewvc?rev=1358483&view=rev
Log:
PIG-2790: After Pig-2699 the script schema (LOAD ... USING ... AS {script schema}) is passed
after getSchema is called

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/impl/util/Utils.java
    pig/trunk/src/org/apache/pig/newplan/logical/relational/LOLoad.java
    pig/trunk/test/commit-tests

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1358483&r1=1358482&r2=1358483&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Sat Jul  7 00:41:03 2012
@@ -186,6 +186,8 @@ OPTIMIZATIONS
 
 BUG FIXES
 
+PIG-2790: After Pig-2699 the script schema (LOAD ... USING ... AS {script schema}) is passed
after getSchema is called (daijy)
+
 PIG-2777: Docs are broken due to malformed xml after PIG-2673 (dvryaboy)
 
 PIG-2593: Filter by a boolean value does not work (jay23jack via daijy)

Modified: pig/trunk/src/org/apache/pig/impl/util/Utils.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/impl/util/Utils.java?rev=1358483&r1=1358482&r2=1358483&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/impl/util/Utils.java (original)
+++ pig/trunk/src/org/apache/pig/impl/util/Utils.java Sat Jul  7 00:41:03 2012
@@ -111,27 +111,32 @@ public class Utils {
         }
     }
 
-	/**
-	 * A helper function for retrieving the script schema set by the LOLoad
-	 * function.
-	 * 
-	 * @param loadFuncSignature
-	 * @param conf
-	 * @return Schema
-	 * @throws IOException
-	 */
-	public static Schema getScriptSchema(String loadFuncSignature,
-			Configuration conf) throws IOException {
-		Schema scriptSchema = null;
-		String scriptField = conf.get(loadFuncSignature + ".scriptSchema");
-
-		if (scriptField != null) {
-			scriptSchema = (Schema) ObjectSerializer.deserialize(scriptField);
-		}
+    /**
+     * A helper function for retrieving the script schema set by the LOLoad
+     * function.
+     * 
+     * @param loadFuncSignature
+     * @param conf
+     * @return Schema
+     * @throws IOException
+     */
+    public static Schema getScriptSchema(
+            String loadFuncSignature,
+            Configuration conf) throws IOException {
+        Schema scriptSchema = null;
+        String scriptField = conf.get(getScriptSchemaKey(loadFuncSignature));
+
+        if (scriptField != null) {
+            scriptSchema = (Schema) ObjectSerializer.deserialize(scriptField);
+        }
+
+        return scriptSchema;
+    }
+
+    public static String getScriptSchemaKey(String loadFuncSignature) {
+      return loadFuncSignature + ".scriptSchema";
+    }
 
-		return scriptSchema;
-	}
-    
     public static ResourceSchema getSchema(LoadFunc wrappedLoadFunc, String location, boolean
checkExistence, Job job)
     throws IOException {
         Configuration conf = job.getConfiguration();

Modified: pig/trunk/src/org/apache/pig/newplan/logical/relational/LOLoad.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/newplan/logical/relational/LOLoad.java?rev=1358483&r1=1358482&r2=1358483&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/newplan/logical/relational/LOLoad.java (original)
+++ pig/trunk/src/org/apache/pig/newplan/logical/relational/LOLoad.java Sat Jul  7 00:41:03
2012
@@ -33,6 +33,7 @@ import org.apache.pig.impl.io.FileSpec;
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.impl.logicalLayer.schema.Schema;
 import org.apache.pig.impl.util.ObjectSerializer;
+import org.apache.pig.impl.util.Utils;
 import org.apache.pig.newplan.Operator;
 import org.apache.pig.newplan.PlanVisitor;
 import org.apache.pig.newplan.logical.Util;
@@ -80,6 +81,7 @@ public class LOLoad extends LogicalRelat
         this.conf = conf;
         this.loadFunc = loadFunc;
         this.signature = signature;
+        storeScriptSchema(conf, scriptSchema, signature);
         if (loadFunc != null) {
             this.loadFunc.setUDFContextSignature(signature);
             try {
@@ -179,14 +181,6 @@ public class LOLoad extends LogicalRelat
         return null;
     }
 
-    @Override
-    public void setAlias(String alias) {
-        super.setAlias(alias);
-
-        // set the schema in this method using the new alias assigned
-        storeScriptSchema();
-    }
-	
 	/**
 	 * This method will store the scriptSchema:Schema using ObjectSerializer to
 	 * the current configuration.<br/>
@@ -198,7 +192,7 @@ public class LOLoad extends LogicalRelat
 	 * ${UDFSignature}.scriptSchema = ObjectSerializer.serialize(scriptSchema)
 	 * </pre>
 	 * <p/>
-	 * Note that this is not the schema the load functiona returns but will
+     * Note that this is not the schema the load function returns but will
 	 * always be the as clause schema.<br/>
 	 * That is a = LOAD 'input' as (a:chararray, b:chararray)<br/>
 	 * The schema wil lbe (a:chararray, b:chararray)<br/>
@@ -207,15 +201,12 @@ public class LOLoad extends LogicalRelat
 	 * TODO Find better solution to make script schema available to LoadFunc see
 	 * https://issues.apache.org/jira/browse/PIG-1717
 	 */
-	private void storeScriptSchema() {
-		String alias = getAlias();
-		if (!(conf == null || alias == null || scriptSchema == null)) {
-
+    private void storeScriptSchema(Configuration conf, LogicalSchema scriptSchema, String
signature) {
+      if (conf != null && scriptSchema != null && signature != null) {
 			try {
-
-				conf.set(alias + ".scriptSchema", ObjectSerializer
-						.serialize(Util.translateSchema(scriptSchema)));
-
+          conf.set(
+              Utils.getScriptSchemaKey(signature),
+              ObjectSerializer.serialize(Util.translateSchema(scriptSchema)));
 			} catch (IOException ioe) {
 				int errCode = 1018;
 				String msg = "Problem serializing script schema";

Modified: pig/trunk/test/commit-tests
URL: http://svn.apache.org/viewvc/pig/trunk/test/commit-tests?rev=1358483&r1=1358482&r2=1358483&view=diff
==============================================================================
--- pig/trunk/test/commit-tests (original)
+++ pig/trunk/test/commit-tests Sat Jul  7 00:41:03 2012
@@ -53,3 +53,4 @@
 **/TestTextDataParse.java
 **/TestTupleFormat.java
 **/TestStringUDFs.java
+**/TestLOLoadDeterminedSchema.java



Mime
View raw message