Review Board 1.7.22


Refactor physical operators to remove methods parameters that are always null

Review Request #11203 - Created May 16, 2013 and updated

Julien Le Dem
PIG-3307
Reviewers
pig
billgraham, cheolsoo, daijy, dvryaboy
pig-git
Refactor physical operators to remove methods parameters that are always null
test-commit

Diff revision 1 (Latest)

  1. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POBinCond.java: Loading...
  2. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POCast.java: Loading...
  3. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POIsNull.java: Loading...
  4. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POMapLookUp.java: Loading...
  5. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/PONegative.java: Loading...
  6. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/PONot.java: Loading...
  7. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POOr.java: Loading...
  8. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POProject.java: Loading...
  9. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/PORegexp.java: Loading...
  10. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/PORelationToExprProject.java: Loading...
  11. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POUserComparisonFunc.java: Loading...
  12. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POUserFunc.java: Loading...
  13. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/Subtract.java: Loading...
  14. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/POCollectedGroup.java: Loading...
  15. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/POCombinerPackage.java: Loading...
  16. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/POCounter.java: Loading...
  17. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/POCross.java: Loading...
  18. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/PODemux.java: Loading...
  19. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/PODistinct.java: Loading...
  20. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/POFRJoin.java: Loading...
This diff has been split across 5 pages: < 1 2 3 4 5 >
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POBinCond.java
Revision 312f3ac New Change
[20] 14 lines
[+20]
15
 * See the License for the specific language governing permissions and
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
16
 * limitations under the License.
17
 */
17
 */
18
package org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators;
18
package org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators;
19

    
   
19

   
20
import java.math.BigDecimal;

   
21
import java.math.BigInteger;

   
22
import java.util.ArrayList;
20
import java.util.ArrayList;
23
import java.util.List;
21
import java.util.List;
24
import java.util.Map;

   
25

    
   
22

   
26
import org.joda.time.DateTime;

   
27

    
   
23

   
28
import org.apache.pig.backend.executionengine.ExecException;
24
import org.apache.pig.backend.executionengine.ExecException;
29
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.POStatus;
25
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.POStatus;
30
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.Result;
26
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.Result;
31
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.plans.PhyPlanVisitor;
27
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.plans.PhyPlanVisitor;
32
import org.apache.pig.data.DataBag;

   
33
import org.apache.pig.data.DataByteArray;

   
34
import org.apache.pig.data.DataType;
28
import org.apache.pig.data.DataType;
35
import org.apache.pig.data.Tuple;
29
import org.apache.pig.data.Tuple;
36
import org.apache.pig.impl.plan.NodeIdGenerator;
30
import org.apache.pig.impl.plan.NodeIdGenerator;
37
import org.apache.pig.impl.plan.OperatorKey;
31
import org.apache.pig.impl.plan.OperatorKey;
38
import org.apache.pig.impl.plan.VisitorException;
32
import org.apache.pig.impl.plan.VisitorException;
[+20] [20] 19 lines
[+20] [+] public class POBinCond extends ExpressionOperator {
58
        this.cond = cond;
52
        this.cond = cond;
59
        this.lhs = lhs;
53
        this.lhs = lhs;
60
        this.rhs = rhs;
54
        this.rhs = rhs;
61
    }
55
    }
62

    
   
56

   
63
    public Result genericGetNext(Object obj, byte dataType) throws ExecException {
57
    public Result genericGetNext(byte dataType) throws ExecException {
64
        List<ExpressionOperator> list = new ArrayList<ExpressionOperator>();
58
        List<ExpressionOperator> list = new ArrayList<ExpressionOperator>();
65
        list.add(cond);
59
        list.add(cond);
66
        Result r = accumChild(list, dummyBool);
60
        Result r = accumChild(list, DataType.BOOLEAN);
67

    
   
61

   
68
        if (r != null) {
62
        if (r != null) {
69
            if (r.returnStatus != POStatus.STATUS_BATCH_OK) {
63
            if (r.returnStatus != POStatus.STATUS_BATCH_OK) {
70
                return r;
64
                return r;
71
            }
65
            }
72
            list.clear();
66
            list.clear();
73
            list.add(lhs);
67
            list.add(lhs);
74
            list.add(rhs);
68
            list.add(rhs);
75
            r = accumChild(list, obj, dataType);
69
            r = accumChild(list, dataType);
76
            return r;
70
            return r;
77
        }
71
        }
78
        Result res = cond.getNext(dummyBool);
72
        Result res = cond.getNextBoolean();
79
        if (res.result==null || res.returnStatus != POStatus.STATUS_OK) {
73
        if (res.result==null || res.returnStatus != POStatus.STATUS_OK) {
80
            return res;
74
            return res;
81
        }
75
        }
82
        Result result = ((Boolean)res.result) == true ? lhs.getNext(obj, dataType) : rhs.getNext(obj, dataType);
76
        Result result = ((Boolean)res.result) == true ? lhs.getNext(dataType) : rhs.getNext(dataType);
83
        illustratorMarkup(null, result.result, ((Boolean)res.result) ? 0 : 1);
77
        illustratorMarkup(null, result.result, ((Boolean)res.result) ? 0 : 1);
84
        return result;
78
        return result;
85
    }
79
    }
86

    
   
80

   
87
    @Override
81
    @Override
88
    public Result getNext(Boolean b) throws ExecException {
82
    public Result getNextBoolean() throws ExecException {
89
        Result r = accumChild(null, b);
83
        Result r = accumChild(null, DataType.BOOLEAN);
90
        if (r != null) {
84
        if (r != null) {
91
            return r;
85
            return r;
92
        }
86
        }
93

    
   
87

   
94
        Result res = cond.getNext(b);
88
        Result res = cond.getNextBoolean();
95
        if (res.result==null || res.returnStatus != POStatus.STATUS_OK) {
89
        if (res.result==null || res.returnStatus != POStatus.STATUS_OK) {
96
            return res;
90
            return res;
97
        }
91
        }
98
        return ((Boolean)res.result) == true ? lhs.getNext(b) : rhs.getNext(b);
92
        return ((Boolean)res.result) == true ? lhs.getNextBoolean() : rhs.getNextBoolean();
99

    
   
93

   
100
    }
94
    }
101

    
   
95

   
102
    @Override
96
    @Override
103
    public Result getNext(DataBag db) throws ExecException {
97
    public Result getNextDataBag() throws ExecException {
104
        return genericGetNext(db, DataType.BAG);
98
        return genericGetNext(DataType.BAG);
105
    }
99
    }
106

    
   
100

   
107
    @Override
101
    @Override
108
    public Result getNext(DataByteArray ba) throws ExecException {
102
    public Result getNextDataByteArray() throws ExecException {
109
        return genericGetNext(ba, DataType.BYTEARRAY);
103
        return genericGetNext(DataType.BYTEARRAY);
110
    }
104
    }
111

    
   
105

   
112
    @Override
106
    @Override
113
    public Result getNext(Double d) throws ExecException {
107
    public Result getNextDouble() throws ExecException {
114
        return genericGetNext(d, DataType.DOUBLE);
108
        return genericGetNext(DataType.DOUBLE);
115
    }
109
    }
116

    
   
110

   
117
    @Override
111
    @Override
118
    public Result getNext(Float f) throws ExecException {
112
    public Result getNextFloat() throws ExecException {
119
        return genericGetNext(f, DataType.FLOAT);
113
        return genericGetNext(DataType.FLOAT);
120
    }
114
    }
121

    
   
115

   
122
    @Override
116
    @Override
123
    public Result getNext(Integer i) throws ExecException {
117
    public Result getNextInteger() throws ExecException {
124
        return genericGetNext(i, DataType.INTEGER);
118
        return genericGetNext(DataType.INTEGER);
125
    }
119
    }
126

    
   
120

   
127
    @Override
121
    @Override
128
    public Result getNext(Long l) throws ExecException {
122
    public Result getNextLong() throws ExecException {
129
        return genericGetNext(l, DataType.LONG);
123
        return genericGetNext(DataType.LONG);
130
    }
124
    }
131

    
   
125

   
132
    @Override
126
    @Override
133
    public Result getNext(DateTime dt) throws ExecException {
127
    public Result getNextDateTime() throws ExecException {
134
        return genericGetNext(dt, DataType.DATETIME);
128
        return genericGetNext(DataType.DATETIME);
135
    }
129
    }
136

    
   
130

   
137
    @Override
131
    @Override
138
    public Result getNext(Map m) throws ExecException {
132
    public Result getNextMap() throws ExecException {
139
        return genericGetNext(m, DataType.MAP);
133
        return genericGetNext(DataType.MAP);
140
    }
134
    }
141

    
   
135

   
142
    @Override
136
    @Override
143
    public Result getNext(String s) throws ExecException {
137
    public Result getNextString() throws ExecException {
144
        return genericGetNext(s, DataType.CHARARRAY);
138
        return genericGetNext(DataType.CHARARRAY);
145
    }
139
    }
146

    
   
140

   
147
    @Override
141
    @Override
148
    public Result getNext(Tuple t) throws ExecException {
142
    public Result getNextTuple() throws ExecException {
149
        return genericGetNext(t, DataType.TUPLE);
143
        return genericGetNext(DataType.TUPLE);
150
    }
144
    }
151

    
   
145

   
152
    @Override
146
    @Override
153
    public Result getNext(BigInteger bi) throws ExecException {
147
    public Result getNextBigInteger() throws ExecException {
154
        return genericGetNext(bi, DataType.BIGINTEGER);
148
        return genericGetNext(DataType.BIGINTEGER);
155
    }
149
    }
156

    
   
150

   
157
    @Override
151
    @Override
158
    public Result getNext(BigDecimal bd) throws ExecException {
152
    public Result getNextBigDecimal() throws ExecException {
159
        return genericGetNext(bd, DataType.BIGDECIMAL);
153
        return genericGetNext(DataType.BIGDECIMAL);
160
    }
154
    }
161

    
   
155

   
162
    @Override
156
    @Override
163
    public void visit(PhyPlanVisitor v) throws VisitorException {
157
    public void visit(PhyPlanVisitor v) throws VisitorException {
164
        v.visitBinCond(this);
158
        v.visitBinCond(this);
[+20] [20] 85 lines
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POCast.java
Revision 987cc21 New Change
 
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POIsNull.java
Revision 9ea89f7 New Change
 
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POMapLookUp.java
Revision fd5573f New Change
 
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/PONegative.java
Revision 8d3fcb1 New Change
 
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/PONot.java
Revision 973dfc5 New Change
 
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POOr.java
Revision 498eb12 New Change
 
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POProject.java
Revision 8886df7 New Change
 
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/PORegexp.java
Revision 6634915 New Change
 
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/PORelationToExprProject.java
Revision e400a95 New Change
 
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POUserComparisonFunc.java
Revision 1aa1671 New Change
 
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POUserFunc.java
Revision 167cf06 New Change
 
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/Subtract.java
Revision 4999995 New Change
 
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/POCollectedGroup.java
Revision a5adaf7 New Change
 
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/POCombinerPackage.java
Revision 4a58a7e New Change
 
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/POCounter.java
Revision 30dcea2 New Change
 
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/POCross.java
Revision b90b0a2 New Change
 
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/PODemux.java
Revision e26c611 New Change
 
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/PODistinct.java
Revision ed2d39e New Change
 
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/POFRJoin.java
Revision a4abdd8 New Change
 
  1. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POBinCond.java: Loading...
  2. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POCast.java: Loading...
  3. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POIsNull.java: Loading...
  4. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POMapLookUp.java: Loading...
  5. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/PONegative.java: Loading...
  6. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/PONot.java: Loading...
  7. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POOr.java: Loading...
  8. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POProject.java: Loading...
  9. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/PORegexp.java: Loading...
  10. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/PORelationToExprProject.java: Loading...
  11. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POUserComparisonFunc.java: Loading...
  12. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POUserFunc.java: Loading...
  13. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/Subtract.java: Loading...
  14. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/POCollectedGroup.java: Loading...
  15. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/POCombinerPackage.java: Loading...
  16. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/POCounter.java: Loading...
  17. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/POCross.java: Loading...
  18. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/PODemux.java: Loading...
  19. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/PODistinct.java: Loading...
  20. src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/POFRJoin.java: Loading...
This diff has been split across 5 pages: < 1 2 3 4 5 >