[ 
https://issues.apache.org/jira/browse/PIG-2425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13169088#comment-13169088
 ] 

Prashant Kommireddi commented on PIG-2425:
------------------------------------------

That makes sense. Thejas, about naming does "setDefaultsIfUnset(Properties 
properties)" sound ok? This would be a private method within PropertiesUtil and 
called by loadDefaultProperties(Properties properties). 

{code}
 /**
     * 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);
        }
    }
{code}
                
> Aggregate Warning does not work as expected on Embedding Pig in Java 0.9.1
> --------------------------------------------------------------------------
>
>                 Key: PIG-2425
>                 URL: https://issues.apache.org/jira/browse/PIG-2425
>             Project: Pig
>          Issue Type: Bug
>    Affects Versions: 0.9.1
>            Reporter: Prashant Kommireddi
>            Assignee: Prashant Kommireddi
>              Labels: patch
>             Fix For: 0.9.1
>
>         Attachments: aggregateWarning.patch
>
>
> Property "aggregate.warning" is not being set by default when running 
> PigServer, embedding Pig in Java.
> I was initially creating a PigServer object this way:
> {code}
>   PigServer pigServer = new PigServer(ExecType.MAPREDUCE);
> {code}
> But this generated detailed logs in the log directory. To code around this on 
> the client-side you could do
> {code}
> Properties properties = PropertiesUtil.loadDefaultProperties();
> properties.setProperty("aggregate.warning", "true");
> PigServer pigServer = new PigServer(ExecType.MAPREDUCE, properties);
> {code}
> The behavior between Pig scripting and Embedded Pig should be similar. 
> Looking at
> the main constructor of PigServer, it looks like "aggregateWarning" is set
> to false if its not loaded in to Properties object.
> {code}
> public PigServer(PigContext context, boolean connect) throws ExecException {
>          this.pigContext = context;
>          currDAG = new Graph(false);
>          aggregateWarning =
> "true".equalsIgnoreCase(pigContext.getProperties().getProperty("aggregate.warning"));
>          isMultiQuery =
> "true".equalsIgnoreCase(pigContext.getProperties().getProperty("opt.multiquery","true"));
>          jobName = pigContext.getProperties().getProperty(
>                  PigContext.JOB_NAME,
>                  PigContext.JOB_NAME_PREFIX + ":DefaultJobName");
>          if (connect) {
>              pigContext.connect();
>          }
>          addJarsFromProperties();
>      }
> {code}
> I suggest adding "aggregate.warning" to Properties object of PigContext so 
> its picked up across all users of this property (MapReduceLauncher)
> {code}
> public PigServer(PigContext context, boolean connect) throws ExecException {
>         this.pigContext = context;
>         currDAG = new Graph(false);
>         aggregateWarning = 
> "true".equalsIgnoreCase(pigContext.getProperties().getProperty("aggregate.warning",
>  "true"));
>         if(aggregateWarning) {
>               pigContext.getProperties().setProperty("aggregate.warning", 
> "true");
>         }
>               
>         isMultiQuery = 
> "true".equalsIgnoreCase(pigContext.getProperties().getProperty("opt.multiquery","true"));
>         
>         jobName = pigContext.getProperties().getProperty(
>                 PigContext.JOB_NAME,
>                 PigContext.JOB_NAME_PREFIX + ":DefaultJobName");
>         if (connect) {
>             pigContext.connect();
>         }
>         addJarsFromProperties();
>     }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to