use of org.apache.hadoop.hive.ql.exec.ExtractOperator in project SQLWindowing by hbutani.
the class PTFOperator method initializeOp.
/*
* 1. Find out if the operator is invoked at Map-Side or Reduce-side
* 2. Get the deserialized QueryDef
* 3. Reconstruct the transient variables in QueryDef
* 4. Create input partition to store rows coming from previous operator
*/
@Override
protected void initializeOp(Configuration jobConf) throws HiveException {
hiveConf = new HiveConf(jobConf, PTFOperator.class);
// if the parent is ExtractOperator, this invocation is from reduce-side
Operator<? extends OperatorDesc> parentOp = getParentOperators().get(0);
if (parentOp instanceof ExtractOperator) {
isMapOperator = false;
} else {
isMapOperator = true;
}
// use the string from PTFDesc to get deserialized QueryDef
qDef = (QueryDef) SerializationUtils.deserialize(new ByteArrayInputStream(conf.getQueryDefStr().getBytes()));
try {
reconstructQueryDef(hiveConf);
inputPart = RuntimeUtils.createFirstPartitionForChain(qDef, inputObjInspectors[0], hiveConf, isMapOperator);
} catch (WindowingException we) {
throw new HiveException("Cannot create input partition for PTFOperator.", we);
}
// OI for ReduceSinkOperator is taken from TODO
if (isMapOperator) {
TableFuncDef tDef = RuntimeUtils.getFirstTableFunction(qDef);
outputObjInspector = tDef.getMapOI();
} else {
outputObjInspector = qDef.getSelectList().getOI();
}
setupKeysWrapper(inputObjInspectors[0]);
super.initializeOp(jobConf);
}
Aggregations