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

Kyungho Jeon commented on PIG-3793:
-----------------------------------

I guess it depends on how the class LogicalPlanData is used, but wouldn't it be 
safer to compute the number of LogicalRelationOperators (sources and sinks too) 
on the fly? Then, it doesn't need to assume that the LogicalPlan is not 
changed. 

For example, getNumLogicalRelationOperators() can be changed as follows: 

diff --git a/src/org/apache/pig/newplan/logical/relational/LogicalPlanData.java 
b/src/org/apache/pi
index 17a2045..82df2a8 100644
--- a/src/org/apache/pig/newplan/logical/relational/LogicalPlanData.java
+++ b/src/org/apache/pig/newplan/logical/relational/LogicalPlanData.java
@@ -80,7 +80,16 @@ public class LogicalPlanData {
      * 
      */
     public int getNumLogicalRelationOperators() {
-        return this.numLogicalRelationalOperators;
+        int numLogicalRelationalOperators = 0;
+        Iterator<Operator> ops = this.lp.getOperators();
+
+        while (ops.hasNext()) {
+            Operator op = ops.next();
+            if (op instanceof LogicalRelationalOperator)
+                numLogicalRelationalOperators++;
+        }
+
+        return numLogicalRelationalOperators;
     }
 
     /**



> Provide info on number of LogicalRelationalOperator(s) used in the script 
> through LogicalPlanData
> -------------------------------------------------------------------------------------------------
>
>                 Key: PIG-3793
>                 URL: https://issues.apache.org/jira/browse/PIG-3793
>             Project: Pig
>          Issue Type: Improvement
>          Components: data
>    Affects Versions: 0.13.0
>            Reporter: Prashant Kommireddi
>            Assignee: Prashant Kommireddi
>             Fix For: 0.13.0
>
>         Attachments: PIG-3793.patch, PIG-3793_2.patch
>
>
> Its useful to have an understanding of how many operators are being used in 
> the script via the API. This could allow admins to enforce 
> checks/restrictions on the length/complexity of the plan in user scripts.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to