ShapeDetails inpShape = def.getInput().getOutputShape();
/*
* 1. setup resolve, make connections
*/
TableFunctionEvaluator tEval = def.getTFunction();
WindowingTableFunctionResolver tResolver =
(WindowingTableFunctionResolver) constructResolver(def.getResolverClassName());
tResolver.initialize(ptfDesc, def, tEval);
/*
* 2. initialize WFns.
*/
if ( def.getWindowFunctions() != null ) {
for(WindowFunctionDef wFnDef : def.getWindowFunctions() ) {
if ( wFnDef.getArgs() != null ) {
for(PTFExpressionDef arg : wFnDef.getArgs()) {
initialize(arg, inpShape);
}
}
if ( wFnDef.getWindowFrame() != null ) {
WindowFrameDef wFrmDef = wFnDef.getWindowFrame();
initialize(wFrmDef.getStart(), inpShape);
initialize(wFrmDef.getEnd(), inpShape);
}
setupWdwFnEvaluator(wFnDef);
}
ArrayList<String> aliases = new ArrayList<String>();
ArrayList<ObjectInspector> fieldOIs = new ArrayList<ObjectInspector>();
for(WindowFunctionDef wFnDef : def.getWindowFunctions()) {
aliases.add(wFnDef.getAlias());
if ( wFnDef.isPivotResult() ) {
fieldOIs.add(((ListObjectInspector)wFnDef.getOI()).getListElementObjectInspector());
} else {
fieldOIs.add(wFnDef.getOI());
}
}
PTFDeserializer.addInputColumnsToList(inpShape, aliases, fieldOIs);
StructObjectInspector wdwOutOI = ObjectInspectorFactory.getStandardStructObjectInspector(
aliases, fieldOIs);
tResolver.setWdwProcessingOutputOI(wdwOutOI);
initialize(def.getOutputFromWdwFnProcessing(), wdwOutOI);
}
else {
def.setOutputFromWdwFnProcessing(inpShape);
}
inpShape = def.getOutputFromWdwFnProcessing();
/*
* 3. initialize WExprs. + having clause
*/
if ( def.getWindowExpressions() != null ) {
for(WindowExpressionDef wEDef : def.getWindowExpressions()) {
initialize(wEDef, inpShape);
}
}
/*
* 4. give Evaluator chance to setup for Output execution; setup Output shape.
*/
tResolver.initializeOutputOI();
initialize(def.getOutputShape(), tEval.getOutputOI());
/*
* If we have windowExpressions then we convert to Std. Object to process;
* we just stream these rows; no need to put in an output Partition.
*/