} catch (FrontendException e) {
log
.error("Error visiting Load during Augmentation phase of Example Generator! "
+ e.getMessage());
throw new VisitorException(
"Error visiting Load during Augmentation phase of Example Generator! "
+ e.getMessage());
}
DataBag outputConstraints = outputConstraintsMap.get(load);
outputConstraintsMap.remove(load);
// check if the inputData exists
if (inputData == null || inputData.size() == 0) {
log.error("No input data found!");
throw new RuntimeException("No input data found!");
}
// first of all, we are required to guarantee that there is at least one
// output tuple
if (outputConstraints == null || outputConstraints.size() == 0) {
outputConstraints = BagFactory.getInstance().newDefaultBag();
outputConstraints.add(TupleFactory.getInstance().newTuple(
schema.getFields().size()));
}
// create example tuple to steal values from when we encounter
// "don't care" fields (i.e. null fields)
Tuple exampleTuple = inputData.iterator().next();
// run through output constraints; for each one synthesize a tuple and
// add it to the base data
// (while synthesizing individual fields, try to match fields that exist
// in the real data)
for (Iterator<Tuple> it = outputConstraints.iterator(); it.hasNext();) {
Tuple outputConstraint = it.next();
// sanity check:
if (outputConstraint.size() != schema.getFields().size())
throw new RuntimeException(
"Internal error: incorrect number of fields in constraint tuple.");
Tuple inputT = TupleFactory.getInstance().newTuple(
outputConstraint.size());
ExampleTuple inputTuple = new ExampleTuple(inputT);
try {
for (int i = 0; i < inputTuple.size(); i++) {
Object d = outputConstraint.get(i);
if (d == null)
d = exampleTuple.get(i);
inputTuple.set(i, d);
}
} catch (ExecException e) {
log
.error("Error visiting Load during Augmentation phase of Example Generator! "
+ e.getMessage());
throw new VisitorException(
"Error visiting Load during Augmentation phase of Example Generator! "
+ e.getMessage());
}
if (!inputTuple.equals(exampleTuple))