You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by kn...@apache.org on 2016/04/12 16:03:22 UTC

svn commit: r1738804 - in /pig/trunk: CHANGES.txt src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POProject.java

Author: knoguchi
Date: Tue Apr 12 14:03:22 2016
New Revision: 1738804

URL: http://svn.apache.org/viewvc?rev=1738804&view=rev
Log:
PIG-4862: POProject slow by creating StackTrace repeatedly (knoguchi)

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POProject.java

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1738804&r1=1738803&r2=1738804&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Tue Apr 12 14:03:22 2016
@@ -24,6 +24,8 @@ INCOMPATIBLE CHANGES
 
 IMPROVEMENTS
 
+PIG-4862: POProject slow by creating StackTrace repeatedly (knoguchi)
+
 PIG-4853: Fetch inputs before starting outputs (rohini)
 
 PIG-4847: POPartialAgg processing and spill improvements (rohini)

Modified: pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POProject.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POProject.java?rev=1738804&r1=1738803&r2=1738804&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POProject.java (original)
+++ pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POProject.java Tue Apr 12 14:03:22 2016
@@ -158,23 +158,19 @@ public class POProject extends Expressio
             illustratorMarkup(inpValue, res.result, -1);
             return res;
         } else if(columns.size() == 1) {
-            try {
+            if ( inpValue == null ) {
+                // the tuple is null, so a dereference should also produce a null
+                res.returnStatus = POStatus.STATUS_OK;
+                ret = null;
+            } else if( inpValue.size() > columns.get(0) ) {
                 ret = inpValue.get(columns.get(0));
-            } catch (IndexOutOfBoundsException ie) {
+            } else {
                 if(pigLogger != null) {
                     pigLogger.warn(this,"Attempt to access field " +
                             "which was not found in the input", PigWarning.ACCESSING_NON_EXISTENT_FIELD);
                 }
                 res.returnStatus = POStatus.STATUS_OK;
                 ret = null;
-            } catch (NullPointerException npe) {
-                // the tuple is null, so a dereference should also produce a null
-                // there is a slight danger here that the Tuple implementation
-                // may have given the exception for a different reason but if we
-                // don't catch it, we will die and the most common case for the
-                // exception would be because the tuple is null
-                res.returnStatus = POStatus.STATUS_OK;
-                ret = null;
             }
         } else if(isProjectToEnd){
             ret = getRangeTuple(inpValue);
@@ -215,23 +211,18 @@ public class POProject extends Expressio
      */
     private void addColumn(ArrayList<Object> objList, Tuple inpValue, int i)
     throws ExecException {
-        try {
+        if( inpValue == null ) {
+            // the tuple is null, so a dereference should also produce a null
+            objList.add(null);
+        } else if( inpValue.size() > i ) {
             objList.add(inpValue.get(i));
-        } catch (IndexOutOfBoundsException ie) {
+        } else {
             if(pigLogger != null) {
                 pigLogger.warn(this,"Attempt to access field " + i +
                         " which was not found in the input", PigWarning.ACCESSING_NON_EXISTENT_FIELD);
             }
             objList.add(null);
         }
-        catch (NullPointerException npe) {
-            // the tuple is null, so a dereference should also produce a null
-            // there is a slight danger here that the Tuple implementation
-            // may have given the exception for a different reason but if we
-            // don't catch it, we will die and the most common case for the
-            // exception would be because the tuple is null
-            objList.add(null);
-        }
     }
 
     @Override
@@ -406,21 +397,17 @@ public class POProject extends Expressio
             Object ret;
 
             if(columns.size() == 1) {
-                try{
+                if( inpValue == null ) {
+                    // the tuple is null, so a dereference should also produce a null
+                    ret = null;
+                } else if( inpValue.size() > columns.get(0) ) {
                     ret = inpValue.get(columns.get(0));
-                } catch (IndexOutOfBoundsException ie) {
+                } else {
                     if(pigLogger != null) {
                         pigLogger.warn(this,"Attempt to access field " +
                                 "which was not found in the input", PigWarning.ACCESSING_NON_EXISTENT_FIELD);
                     }
                     ret = null;
-                } catch (NullPointerException npe) {
-                    // the tuple is null, so a dereference should also produce a null
-                    // there is a slight danger here that the Tuple implementation
-                    // may have given the exception for a different reason but if we
-                    // don't catch it, we will die and the most common case for the
-                    // exception would be because the tuple is null
-                    ret = null;
                 }
             } else if(isProjectToEnd) {
                 ret = getRangeTuple(inpValue);
@@ -428,21 +415,17 @@ public class POProject extends Expressio
                 ArrayList<Object> objList = new ArrayList<Object>(columns.size());
 
                 for(int col: columns) {
-                    try {
+                    if( inpValue == null ) {
+                        // the tuple is null, so a dereference should also produce a null
+                        objList.add(null);
+                    } else if( inpValue.size() > col ) {
                         objList.add(inpValue.get(col));
-                    } catch (IndexOutOfBoundsException ie) {
+                    } else {
                         if(pigLogger != null) {
                             pigLogger.warn(this,"Attempt to access field " +
                                     "which was not found in the input", PigWarning.ACCESSING_NON_EXISTENT_FIELD);
                         }
                         objList.add(null);
-                    } catch (NullPointerException npe) {
-                        // the tuple is null, so a dereference should also produce a null
-                        // there is a slight danger here that the Tuple implementation
-                        // may have given the exception for a different reason but if we
-                        // don't catch it, we will die and the most common case for the
-                        // exception would be because the tuple is null
-                        objList.add(null);
                     }
                 }
                 ret = mTupleFactory.newTuple(objList);