use of com.sap.hadoop.windowing.WindowingException 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);
}
use of com.sap.hadoop.windowing.WindowingException in project SQLWindowing by hbutani.
the class PTFOperator method processMapFunction.
protected void processMapFunction() throws HiveException {
try {
TableFuncDef tDef = RuntimeUtils.getFirstTableFunction(qDef);
Partition outPart = tDef.getFunction().transformRawInput(inputPart);
PartitionIterator<Object> pItr = outPart.iterator();
while (pItr.hasNext()) {
Object oRow = pItr.next();
forward(oRow, outputObjInspector);
}
} catch (WindowingException we) {
throw new HiveException("Cannot close PTFOperator.", we);
}
}
use of com.sap.hadoop.windowing.WindowingException in project SQLWindowing by hbutani.
the class WhereTranslation method translate.
public static void translate(QueryDef qDef) throws WindowingException {
QueryTranslationInfo tInfo = qDef.getTranslationInfo();
QuerySpec spec = qDef.getSpec();
ASTNode wExpr = spec.getWhereExpr();
if (wExpr == null)
return;
WhereDef whDef = new WhereDef();
whDef.setExpression(wExpr);
QueryInputDef iDef = qDef.getInput();
InputInfo iInfo = tInfo.getInputInfo(iDef);
ExprNodeDesc exprNode = TranslateUtils.buildExprNode(wExpr, iInfo.getTypeCheckCtx());
ExprNodeEvaluator exprEval = WindowingExprNodeEvaluatorFactory.get(tInfo, exprNode);
ObjectInspector oi = TranslateUtils.initExprNodeEvaluator(qDef, exprNode, exprEval, iInfo);
try {
ObjectInspectorConverters.getConverter(oi, PrimitiveObjectInspectorFactory.javaBooleanObjectInspector);
} catch (Throwable t) {
throw new WindowingException("Where Expr must be convertible to a boolean value", t);
}
whDef.setExprNode(exprNode);
whDef.setExprEvaluator(exprEval);
whDef.setOI(oi);
qDef.setWhere(whDef);
}
use of com.sap.hadoop.windowing.WindowingException in project SQLWindowing by hbutani.
the class WindowSpecTranslation method fillInWindowSpec.
static void fillInWindowSpec(QuerySpec qSpec, String sourceId, WindowSpec destWSpec) throws WindowingException {
if (sourceId != null) {
WindowSpec sourceWSpec = qSpec.getWindowSpecs().get(sourceId);
if (sourceWSpec == null) {
throw new WindowingException(sprintf("Window Spec %s refers to an unknown source", destWSpec));
}
if (destWSpec.getPartition() == null) {
destWSpec.setPartition(sourceWSpec.getPartition());
}
if (destWSpec.getOrder() == null) {
destWSpec.setOrder(sourceWSpec.getOrder());
}
if (destWSpec.getWindow() == null) {
destWSpec.setWindow(sourceWSpec.getWindow());
}
fillInWindowSpec(qSpec, sourceWSpec.getSourceId(), destWSpec);
}
}
use of com.sap.hadoop.windowing.WindowingException in project SQLWindowing by hbutani.
the class IOUtils method createPartition.
public static Partition createPartition(String partitionClass, int partitionMemSize, WindowingInput wIn) throws WindowingException {
try {
SerDe serDe = (SerDe) wIn.getDeserializer();
StructObjectInspector oI = (StructObjectInspector) serDe.getObjectInspector();
Partition p = new Partition(partitionClass, partitionMemSize, serDe, oI);
Writable w = wIn.createRow();
while (wIn.next(w) != -1) {
p.append(w);
}
return p;
} catch (WindowingException we) {
throw we;
} catch (Exception e) {
throw new WindowingException(e);
}
}
Aggregations