this.inputRowType = inputRowType;
this.keepInput = flag == API.InputPreservationOption.KEEP_INPUT;
this.lookaheadQuantum = lookaheadQuantum;
ArgumentValidation.notEmpty("outputRowTypes", outputRowTypes);
TableRowType tableRowType;
if (inputRowType instanceof TableRowType) {
tableRowType = (TableRowType)inputRowType;
} else if (inputRowType instanceof IndexRowType) {
// Keeping index rows not supported
ArgumentValidation.isTrue("flag == API.InputPreservationOption.DISCARD_INPUT",
flag == API.InputPreservationOption.DISCARD_INPUT);
tableRowType = ((IndexRowType) inputRowType).tableType();
} else if (inputRowType instanceof HKeyRowType) {
ArgumentValidation.isTrue("flag == API.InputPreservationOption.DISCARD_INPUT",
flag == API.InputPreservationOption.DISCARD_INPUT);
tableRowType = ((Schema) inputRowType.schema()).tableRowType(((HKeyRowType) inputRowType).hKey().table());
} else {
ArgumentValidation.isTrue("invalid rowType", false);
tableRowType = null;
}
Table inputTable = tableRowType.table();
this.ancestors = new ArrayList<>(outputRowTypes.size());
List<TableRowType> branchOutputRowTypes = null;
Table branchRoot = null;
boolean outputInputTable = false;
for (TableRowType outputRowType : outputRowTypes) {
if (outputRowType == tableRowType) {
ArgumentValidation.isTrue("flag == API.InputPreservationOption.DISCARD_INPUT",
flag == API.InputPreservationOption.DISCARD_INPUT);
outputInputTable = true;
} else if (outputRowType.ancestorOf(tableRowType)) {
ancestors.add(outputRowType.table());
} else if (tableRowType.ancestorOf(outputRowType)) {
if (branchOutputRowTypes == null)
branchOutputRowTypes = new ArrayList<>();
branchOutputRowTypes.add(outputRowType);
if (branchRoot != inputTable) {
// Get immediate child of input above desired output.