List<Statement> statements = Lists.create();
// shuffle outputs
for (Map.Entry<ShuffleModel.Segment, SimpleName> entry : shuffleNames.entrySet()) {
ShuffleModel.Segment segment = entry.getKey();
SimpleName name = entry.getValue();
Name shuffleTypeName = segment.getCompiled().getCombineOutputType().getQualifiedName();
statements.add(new ExpressionBuilder(factory, factory.newThis())
.field(name)
.assignFrom(new TypeBuilder(factory, importer.toType(shuffleTypeName))
.newObject(context)
.toExpression())
.toStatement());
segments.put(segment.getPort(), segment);
}
// rendezvous
for (Map.Entry<Fragment, SimpleName> entry : rendezvousNames.entrySet()) {
Fragment fragment = entry.getKey();
Type rendezvousType = importer.toType(fragment.getCompiled().getQualifiedName());
List<Expression> arguments = Lists.create();
for (FlowElementInput input : fragment.getInputPorts()) {
Segment segment = segments.get(input);
assert segment != null;
SimpleName shuffleName = shuffleNames.get(segment);
assert shuffleName != null;
arguments.add(new ExpressionBuilder(factory, factory.newThis())
.field(shuffleName)
.toExpression());
}
SimpleName name = entry.getValue();
statements.add(new ExpressionBuilder(factory, factory.newThis())
.field(name)
.assignFrom(new TypeBuilder(factory, rendezvousType)
.newObject(arguments)
.toExpression())