lr.setOutputKey(sortOpers[0].getOperatorKey().toString());
lrSample.setOutputKey(quantJobParallelismPair.first.getOperatorKey().toString());
edge = TezCompilerUtil.connect(tezPlan, quantJobParallelismPair.first, sortOpers[0]);
TezCompilerUtil.configureValueOnlyTupleOutput(edge, DataMovementType.BROADCAST);
POValueOutputTez sampleOut = (POValueOutputTez)quantJobParallelismPair.first.plan.getLeaves().get(0);
sampleOut.addOutputKey(sortOpers[0].getOperatorKey().toString());
sortOpers[0].setSampleOperator(quantJobParallelismPair.first);
edge = TezCompilerUtil.connect(tezPlan, sortOpers[0], sortOpers[1]);
edge.partitionerClass = WeightedRangePartitionerTez.class;
curTezOp = sortOpers[1];
// TODO: Review sort udf
// if(op.isUDFComparatorUsed){
// curTezOp.UDFs.add(op.getMSortFunc().getFuncSpec().toString());
// curTezOp.isUDFComparatorUsed = true;
// }
quantJobParallelismPair.first.setSortOperator(sortOpers[1]);
// If Order by followed by Limit and parallelism of order by is not 1
// add a new vertex for Limit with parallelism 1.
// Equivalent of LimitAdjuster.java in MR
if (op.isLimited() && rp != 1) {
POValueOutputTez output = new POValueOutputTez(OperatorKey.genOpKey(scope));
output.copyAliasFrom(op);
sortOpers[1].plan.addAsLeaf(output);
TezOperator limitOper = getTezOp();
tezPlan.add(limitOper);
curTezOp = limitOper;
// Explicitly set the parallelism for the new vertex to 1.
limitOper.setRequestedParallelism(1);
limitOper.setDontEstimateParallelism(true);
limitOper.markLimitAfterSort();
edge = TezCompilerUtil.connect(tezPlan, sortOpers[1], limitOper);
// LIMIT in this case should be ordered. So we output unordered with key as task index
// and on the input we use OrderedGroupedKVInput to do ordered merge to retain sorted order.
output.addOutputKey(limitOper.getOperatorKey().toString());
output.setTaskIndexWithRecordIndexAsKey(true);
edge = curTezOp.inEdges.get(sortOpers[1].getOperatorKey());
TezCompilerUtil.configureValueOnlyTupleOutput(edge, DataMovementType.SCATTER_GATHER);
// POValueOutputTez will write key (task index, record index) in
// sorted order. So using UnorderedKVOutput instead of OrderedPartitionedKVOutput.
// But input needs to be merged in sorter order and requires OrderedGroupedKVInput