if (outputConstraints.cardinality() > 0) { // there's one or more output constraints; propagate them backwards through the projection
for (Iterator<Tuple> it = outputConstraints.iterator(); it.hasNext(); ) {
Tuple outputConstraint = it.next();
Tuple inputConst = BackPropConstraint(outputConstraint, cols, inputSchema);
ExampleTuple inputConstraint = new ExampleTuple();
inputConstraint.copyFrom(inputConst);
if (inputConstraint != null) inputConstraints.add(inputConstraint);
}
}
// note: if there are no output constraints, we don't have to do anything because the input operator
// will ensure that we get at least one input tuple, which in turns ensures that we output at least one tuple
} else if (spec instanceof FilterSpec) {
FilterSpec fSpec = (FilterSpec) spec;
Cond filterCond = fSpec.cond;
// if necessary, insert one or more positive examples (i.e. tuples that pass the filter)
if (outputConstraints.cardinality() > 0) { // there's one or more output constraints; generate corresponding input constraints
for (Iterator<Tuple> it = outputConstraints.iterator(); it.hasNext(); ) {
Tuple outputConstraint = it.next();
Tuple inputConst = GenerateMatchingTuple(outputConstraint, filterCond);
ExampleTuple inputConstraint = new ExampleTuple();
inputConstraint.copyFrom(inputConst);
if (inputConstraint != null) inputConstraints.add(inputConstraint);
}
} else if (outputData.cardinality() == 0) { // no output constraints, but output is empty; generate one input that will pass the filter
Tuple inputConst = GenerateMatchingTuple(inputSchema, filterCond);
ExampleTuple inputConstraint = new ExampleTuple();
inputConstraint.copyFrom(inputConst);
if (inputConstraint != null) inputConstraints.add(inputConstraint);
}
// if necessary, insert a negative example (i.e. a tuple that does not pass the filter)
if (outputData.cardinality() == inputData.cardinality()) { // all tuples pass the filter; generate one input that will not pass the filter
ExampleTuple inputConstraint = new ExampleTuple();
Tuple inputConst = GenerateMatchingTuple(inputSchema, new NotCond(filterCond));
//inputConstraint.copyFrom(inputConst);
if (inputConst != null) {
inputConstraint.copyFrom(inputConst);
inputConstraints.add(inputConstraint);
}
}
} else {