pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From the...@apache.org
Subject svn commit: r1215029 - in /pig/branches/branch-0.10: CHANGES.txt src/org/apache/pig/Main.java src/org/apache/pig/impl/util/PropertiesUtil.java test/org/apache/pig/test/TestPigServer.java
Date Fri, 16 Dec 2011 02:42:50 GMT
Author: thejas
Date: Fri Dec 16 02:42:50 2011
New Revision: 1215029

URL: http://svn.apache.org/viewvc?rev=1215029&view=rev
Log:
PIG-2425: Aggregate Warning does not work as expected on Embedding Pig in Java 0.9.1 (prkommireddi
via thejas)

Modified:
    pig/branches/branch-0.10/CHANGES.txt
    pig/branches/branch-0.10/src/org/apache/pig/Main.java
    pig/branches/branch-0.10/src/org/apache/pig/impl/util/PropertiesUtil.java
    pig/branches/branch-0.10/test/org/apache/pig/test/TestPigServer.java

Modified: pig/branches/branch-0.10/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.10/CHANGES.txt?rev=1215029&r1=1215028&r2=1215029&view=diff
==============================================================================
--- pig/branches/branch-0.10/CHANGES.txt (original)
+++ pig/branches/branch-0.10/CHANGES.txt Fri Dec 16 02:42:50 2011
@@ -156,6 +156,8 @@ PIG-2228: support partial aggregation in
 
 BUG FIXES
 
+PIG-2425: Aggregate Warning does not work as expected on Embedding Pig in Java 0.9.1 (prkommireddi
via thejas)
+
 PIG-2331: BinStorage in LOAD statement failing when input has curly braces (xutingz via thejas)
 
 PIG-2391: Bzip_2 test is broken (xutingz via daijy)

Modified: pig/branches/branch-0.10/src/org/apache/pig/Main.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.10/src/org/apache/pig/Main.java?rev=1215029&r1=1215028&r2=1215029&view=diff
==============================================================================
--- pig/branches/branch-0.10/src/org/apache/pig/Main.java (original)
+++ pig/branches/branch-0.10/src/org/apache/pig/Main.java Fri Dec 16 02:42:50 2011
@@ -170,20 +170,6 @@ static int run(String args[], PigProgres
             execType = PigServer.parseExecType(execTypeString);
         }
                 
-        if (properties.getProperty("aggregate.warning") == null) {
-            //by default warning aggregation is on
-            properties.setProperty("aggregate.warning", ""+true);
-        }
-                
-        if (properties.getProperty("opt.multiquery") == null) {
-            //by default multiquery optimization is on
-            properties.setProperty("opt.multiquery", ""+true);
-        }
-
-        if (properties.getProperty("stop.on.failure") == null) {
-            //by default we keep going on error on the backend
-            properties.setProperty("stop.on.failure", ""+false);
-        }
         
         // set up client side system properties in UDF context
         UDFContext.getUDFContext().setClientSystemProps(properties);

Modified: pig/branches/branch-0.10/src/org/apache/pig/impl/util/PropertiesUtil.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.10/src/org/apache/pig/impl/util/PropertiesUtil.java?rev=1215029&r1=1215028&r2=1215029&view=diff
==============================================================================
--- pig/branches/branch-0.10/src/org/apache/pig/impl/util/PropertiesUtil.java (original)
+++ pig/branches/branch-0.10/src/org/apache/pig/impl/util/PropertiesUtil.java Fri Dec 16 02:42:50
2011
@@ -43,7 +43,8 @@ public class PropertiesUtil {
                 System.getProperty("user.home") + "/.pigrc");
         loadPropertiesFromClasspath(properties, DEFAULT_PROPERTIES_FILE);
         loadPropertiesFromClasspath(properties, PROPERTIES_FILE);
-
+        setDefaultsIfUnset(properties);
+        
         //Now set these as system properties only if they are not already defined.
         if (log.isDebugEnabled()) {
             for (Object o: properties.keySet()) {
@@ -124,6 +125,27 @@ public class PropertiesUtil {
     }
 
     /**
+     * Sets properties to their default values if not set by Client
+     * @param properties
+     */
+    private static void setDefaultsIfUnset(Properties properties) {
+    	if (properties.getProperty("aggregate.warning") == null) {
+            //by default warning aggregation is on
+            properties.setProperty("aggregate.warning", ""+true);
+        }
+
+        if (properties.getProperty("opt.multiquery") == null) {
+            //by default multiquery optimization is on
+            properties.setProperty("opt.multiquery", ""+true);
+        }
+
+        if (properties.getProperty("stop.on.failure") == null) {
+            //by default we keep going on error on the backend
+            properties.setProperty("stop.on.failure", ""+false);
+        }
+    }
+    
+    /**
      * Loads default properties.
      * @return default properties
      */

Modified: pig/branches/branch-0.10/test/org/apache/pig/test/TestPigServer.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.10/test/org/apache/pig/test/TestPigServer.java?rev=1215029&r1=1215028&r2=1215029&view=diff
==============================================================================
--- pig/branches/branch-0.10/test/org/apache/pig/test/TestPigServer.java (original)
+++ pig/branches/branch-0.10/test/org/apache/pig/test/TestPigServer.java Fri Dec 16 02:42:50
2011
@@ -834,4 +834,46 @@ public class TestPigServer {
         Assert.fail( "Query is supposed to fail." );
     }
 
+    @Test
+	public void testDefaultPigProperties() throws Throwable {
+    	//Test with PigServer
+    	PigServer pigServer = new PigServer(ExecType.MAPREDUCE);
+    	Properties properties = pigServer.getPigContext().getProperties();
+    	
+    	Assert
+		.assertTrue(properties.getProperty(
+				"pig.exec.reducers.max").equals("999"));
+		Assert.assertTrue(properties.getProperty("aggregate.warning").equals("true"));
+		Assert.assertTrue(properties.getProperty("opt.multiquery").equals("true"));
+		Assert.assertTrue(properties.getProperty("stop.on.failure").equals("false"));
+    	
+		//Test with properties file
+		File propertyFile = new File("pig.properties");
+
+		properties = PropertiesUtil.loadDefaultProperties();
+		
+		Assert
+		.assertTrue(properties.getProperty(
+				"pig.exec.reducers.max").equals("999"));
+		Assert.assertTrue(properties.getProperty("aggregate.warning").equals("true"));
+		Assert.assertTrue(properties.getProperty("opt.multiquery").equals("true"));
+		Assert.assertTrue(properties.getProperty("stop.on.failure").equals("false"));
+		
+		PrintWriter out = new PrintWriter(new FileWriter(propertyFile));
+		out.println("aggregate.warning=false");
+		out.println("opt.multiquery=false");
+		out.println("stop.on.failure=true");
+		
+		out.close();
+
+		properties = PropertiesUtil.loadDefaultProperties();
+		Assert.assertTrue(properties.getProperty("aggregate.warning")
+				.equals("false"));
+		Assert.assertTrue(properties.getProperty("opt.multiquery")
+				.equals("false"));
+		Assert.assertTrue(properties.getProperty("stop.on.failure")
+				.equals("true"));
+
+		propertyFile.delete();
+	}
 }



Mime
View raw message