MCPcopy Create free account
hub / github.com/apache/pig / exec

Method exec

src/org/apache/pig/builtin/COV.java:67–102  ·  view source on GitHub ↗

Function to compute covariance between data sets. @param input input tuple which contains data sets. @return output output dataBag which contain covariance between each pair of data sets.

(Tuple input)

Source from the content-addressed store, hash-verified

65 * @return output output dataBag which contain covariance between each pair of data sets.
66 */
67 @Override
68 public DataBag exec(Tuple input) throws IOException {
69 if (input == null || input.size() == 0)
70 return null;
71 DataBag output = DefaultBagFactory.getInstance().newDefaultBag();
72
73 try{
74 for(int i=0;i<input.size();i++){
75 for(int j=i+1;j<input.size();j++){
76 Tuple temp = TupleFactory.getInstance().newTuple(3);
77 if(flag){
78 temp.set(0, schemaName.elementAt(i));
79 temp.set(1, schemaName.elementAt(j));
80 }
81 else{
82 temp.set(0, "var"+i);
83 temp.set(1, "var"+j);
84 }
85
86 Tuple tempResult = computeAll((DataBag)input.get(i), (DataBag)input.get(j));
87 double size = ((DataBag)input.get(i)).size();
88 double sum_x_y = (Double)tempResult.get(0);
89 double sum_x = (Double)tempResult.get(1);
90 double sum_y = (Double)tempResult.get(2);
91 double result = (size*sum_x_y - sum_x*sum_y)/(size*size);
92 temp.set(2, result);
93 output.add(temp);
94 }
95 }
96 }catch(Exception e){
97 System.err.println("Failed to process input; error - " + e.getMessage());
98 return null;
99 }
100
101 return output;
102 }
103
104
105 //used to pass schema name to Final class constructor

Callers 4

testStatsFuncMethod · 0.95
accumulateMethod · 0.45
getValueMethod · 0.45
executeMethod · 0.45

Calls 10

getInstanceMethod · 0.95
setMethod · 0.95
computeAllMethod · 0.95
getMethod · 0.95
addMethod · 0.95
sizeMethod · 0.65
newTupleMethod · 0.65
newDefaultBagMethod · 0.45
getInstanceMethod · 0.45
getMessageMethod · 0.45

Tested by 1

testStatsFuncMethod · 0.76