Skip to content

Commit 1221ddb

Browse files
author
arvid
committed
Fixed builder pattern port
1 parent c0ac81c commit 1221ddb

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

sopremo/sopremo-common/src/main/java/eu/stratosphere/sopremo/operator/ElementaryOperator.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717
import eu.stratosphere.pact.common.IdentityMap;
1818
import eu.stratosphere.pact.common.contract.CoGroupContract;
1919
import eu.stratosphere.pact.common.contract.Contract;
20+
import eu.stratosphere.pact.common.contract.CrossContract;
2021
import eu.stratosphere.pact.common.contract.MapContract;
2122
import eu.stratosphere.pact.common.contract.MatchContract;
2223
import eu.stratosphere.pact.common.contract.ReduceContract;
2324
import eu.stratosphere.pact.common.plan.ContractUtil;
2425
import eu.stratosphere.pact.common.plan.PactModule;
2526
import eu.stratosphere.pact.common.stubs.CoGroupStub;
27+
import eu.stratosphere.pact.common.stubs.CrossStub;
28+
import eu.stratosphere.pact.common.stubs.MapStub;
2629
import eu.stratosphere.pact.common.stubs.MatchStub;
2730
import eu.stratosphere.pact.common.stubs.ReduceStub;
2831
import eu.stratosphere.pact.common.stubs.Stub;
@@ -380,9 +383,14 @@ else if (contractClass == MatchContract.class) {
380383
builder.name(this.toString());
381384
PactBuilderUtil.addKeysExceptFirst(builder, keyTypes, keyIndices1, keyIndices2);
382385
return builder.build();
383-
}
384-
return ReflectUtil.newInstance(contractClass, stubClass,
385-
this.toString());
386+
} else if(contractClass == MapContract.class)
387+
return MapContract.builder((Class<? extends MapStub>) stubClass).
388+
name(this.toString()).build();
389+
else if(contractClass == CrossContract.class)
390+
return CrossContract.builder((Class<? extends CrossStub>) stubClass).
391+
name(this.toString()).build();
392+
else throw new UnsupportedOperationException("Unknown contract type");
393+
386394
} catch (final Exception e) {
387395
throw new IllegalStateException("Cannot create contract from stub "
388396
+ stubClass, e);

0 commit comments

Comments
 (0)