Skip to content

Commit

Permalink
GEODE-1577: Unhelpful generic types on Execution.execute
Browse files Browse the repository at this point in the history
  * Replaced wildcards with <T, S> for non-deprecated Execution.execute methods.
  * descriptions added for params <T, S> in javadoc
  * explicit type casting removed
  * This closes apache#321
  • Loading branch information
dalyssakim authored and jhuynh1 committed Apr 12, 2017
1 parent 3a64b57 commit 4816d39
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@
* <p>
* This interface is implemented by GemFire. To obtain an instance of it use
* {@link FunctionService}.
*
*
*
* @param <IN> The type of the argument passed into the function, if any
* @param <OUT> The type of results sent by the function
* @param <AGG> The type of the aggregated result returned by the ResultCollector
*
* @since GemFire 6.0
*
* @see FunctionService
* @see Function
*/
public interface Execution {
public interface Execution<IN, OUT, AGG> {

/**
* Specifies a data filter of routing objects for selecting the GemFire members to execute the
Expand All @@ -48,7 +51,7 @@ public interface Execution {
* {@link FunctionService#onRegion(org.apache.geode.cache.Region)}
* @since GemFire 6.0
*/
public Execution withFilter(Set<?> filter);
public Execution<IN, OUT, AGG> withFilter(Set<?> filter);

/**
* Specifies the user data passed to the function when it is executed. The function can retrieve
Expand All @@ -60,7 +63,7 @@ public interface Execution {
* @since GemFire 6.0
*
*/
public Execution withArgs(Object args);
public Execution<IN, OUT, AGG> withArgs(IN args);

/**
* Specifies the {@link ResultCollector} that will receive the results after the function has been
Expand All @@ -72,15 +75,14 @@ public interface Execution {
* @see ResultCollector
* @since GemFire 6.0
*/
public Execution withCollector(ResultCollector<?, ?> rc);
public Execution<IN, OUT, AGG> withCollector(ResultCollector<OUT, AGG> rc);

/**
* Executes the function using its {@linkplain Function#getId() id}
* <p>
* {@link Function#execute(FunctionContext)} is called on the instance retrieved using
* {@link FunctionService#getFunction(String)} on the executing member.
*
* @param functionId the {@link Function#getId()} of the function
*
* @throws LowMemoryException if the {@link Function#optimizeForWrite()} returns true and there is
* a low memory condition
* @return ResultCollector to retrieve the results received. This is different object than the
Expand All @@ -89,7 +91,7 @@ public interface Execution {
*
* @since GemFire 6.0
*/
public ResultCollector<?, ?> execute(String functionId) throws FunctionException;
public ResultCollector<OUT, AGG> execute(String functionId) throws FunctionException;

/**
* Executes the function instance provided.
Expand All @@ -106,7 +108,7 @@ public interface Execution {
*
* @since GemFire 6.0
*/
public ResultCollector<?, ?> execute(Function function) throws FunctionException;
public ResultCollector<OUT, AGG> execute(Function function) throws FunctionException;

/**
* Executes the function using its {@linkplain Function#getId() id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ public void clearResults() {
}

((AbstractExecution) execution).setIgnoreDepartedMembers(true);
collector = (ResultCollector<HashSet<Dependency>, Serializable>) execution
.execute(new CollectDependencyFunction());
collector = execution.execute(new CollectDependencyFunction());

// Wait for results
collector.getResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,8 @@ public static void serverBucketFilterExecution(Set<Integer> bucketFilterSet) thr
}

List l = null;
ResultCollector<Integer, List<Integer>> rc = (ResultCollector<Integer, List<Integer>>) dataSet
.withBucketFilter(bucketFilterSet).execute(function.getId());
ResultCollector<Integer, List<Integer>> rc =
dataSet.withBucketFilter(bucketFilterSet).execute(function.getId());
List<Integer> results = rc.getResult();
assertEquals(bucketFilterSet.size(), results.size());
for (Integer bucket : results) {
Expand Down Expand Up @@ -754,8 +754,8 @@ public static void serverBucketFilterOverrideExecution(Set<Integer> bucketFilter
}

List l = null;
ResultCollector<Integer, List<Integer>> rc = (ResultCollector<Integer, List<Integer>>) dataSet
.withBucketFilter(bucketFilterSet).withFilter(ketFilterSet).execute(function.getId());
ResultCollector<Integer, List<Integer>> rc = dataSet.withBucketFilter(bucketFilterSet)
.withFilter(ketFilterSet).execute(function.getId());
List<Integer> results = rc.getResult();
assertEquals(expectedBucketSet.size(), results.size());
for (Integer bucket : results) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1580,8 +1580,7 @@ public Object call() throws Exception {
Set<Integer> bucketSet = new HashSet<Integer>();
bucketSet.add(2);
ResultCollector<Integer, List<Integer>> rc =
(ResultCollector<Integer, List<Integer>>) dataSet.withBucketFilter(bucketSet)
.execute(function);
dataSet.withBucketFilter(bucketSet).execute(function);

List<Integer> results = rc.getResult();
assertEquals(bucketSet.size(), results.size());
Expand All @@ -1604,8 +1603,7 @@ public Object call() throws Exception {
bucketSet.add(2);
bucketSet.add(3);
ResultCollector<Integer, List<Integer>> rc =
(ResultCollector<Integer, List<Integer>>) dataSet.withBucketFilter(bucketSet)
.execute(function);
dataSet.withBucketFilter(bucketSet).execute(function);

List<Integer> results = rc.getResult();
assertEquals(bucketSet.size(), results.size());
Expand All @@ -1631,8 +1629,7 @@ public Object call() throws Exception {
bucketSet.add(0);
bucketSet.add(4);
ResultCollector<Integer, List<Integer>> rc =
(ResultCollector<Integer, List<Integer>>) dataSet.withBucketFilter(bucketSet)
.execute(function);
dataSet.withBucketFilter(bucketSet).execute(function);

List<Integer> results = rc.getResult();
assertEquals(bucketSet.size(), results.size());
Expand Down Expand Up @@ -1713,8 +1710,7 @@ public Object call() throws Exception {
expectedBucketSet.add(3);
expectedBucketSet.add(4);
ResultCollector<Integer, List<Integer>> rc =
(ResultCollector<Integer, List<Integer>>) dataSet.withBucketFilter(bucketSet)
.withFilter(keySet).execute(function);
dataSet.withBucketFilter(bucketSet).withFilter(keySet).execute(function);

List<Integer> results = rc.getResult();
assertEquals(keySet.size(), results.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private TopEntries<K> findTopEntries() throws LuceneQueryException {
try {
TopEntriesFunctionCollector collector = new TopEntriesFunctionCollector(context);
ResultCollector<TopEntriesCollector, TopEntries<K>> rc =
(ResultCollector<TopEntriesCollector, TopEntries<K>>) onRegion().withArgs(context)
onRegion().withArgs(context)
.withCollector(collector).execute(LuceneQueryFunction.ID);
entries = rc.getResult();
} catch (FunctionException e) {
Expand Down

0 comments on commit 4816d39

Please sign in to comment.