Search in sources :

Example 1 with ExtractOperator

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);
}
Also used : HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) ByteArrayInputStream(java.io.ByteArrayInputStream) WindowingException(com.sap.hadoop.windowing.WindowingException) HiveConf(org.apache.hadoop.hive.conf.HiveConf) ExtractOperator(org.apache.hadoop.hive.ql.exec.ExtractOperator) TableFuncDef(com.sap.hadoop.windowing.query2.definition.TableFuncDef)

Aggregations

WindowingException (com.sap.hadoop.windowing.WindowingException)1 TableFuncDef (com.sap.hadoop.windowing.query2.definition.TableFuncDef)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 HiveConf (org.apache.hadoop.hive.conf.HiveConf)1 ExtractOperator (org.apache.hadoop.hive.ql.exec.ExtractOperator)1 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)1