GemFire 5.8

com.gemstone.gemfire.cache.execute
Interface ResultCollector


public interface ResultCollector

Defines the interface for a container that gathers results from function execution.
GemFire provides a default implementation for ResultCollector. Applications can choose to implement their own custom ResultCollector. A custom ResultCollector facilitates result sorting or aggregation. Aggregation functions like sum, minimum, maximum and average can also be applied to the result using a custom ResultCollector.

Example:
  Region region ; 
  Set keySet = Collections.singleton("myKey");
  Function multiGetFunction ;
  Serializable args ;
  ResultCollector rc = FunctionService.onRegion(region)
                                      .withArgs(args)
                                      .withFilter(keySet)
                                      .withCollector(new MyCustomResultCollector())
                                      .execute(multiGetFunction.getId());
  //Application can do something else here before retrieving the result
  Serializable functionResult = rc.getResult();  
 

Since:
5.8LA

Method Summary
 void addResult(Serializable resultOfSingleExecution)
          Adds a single function execution result to the ResultCollector
 void endResults()
          GemFire will invoke this method when function execution has completed and all results for the execution have been obtained and added to the ResultCollector
 Serializable getResult()
          Returns the result of function execution, potentially blocking until all the results are available has been called.
 Serializable getResult(long timeout, com.gemstone.bp.edu.emory.mathcs.backport.java.util.concurrent.TimeUnit unit)
          Returns the result of function execution, blocking for the timeout period until all the results are available.
 

Method Detail

getResult

Serializable getResult()
                       throws FunctionException
Returns the result of function execution, potentially blocking until all the results are available has been called.

Returns:
the result
Throws:
FunctionException - if result retrieval fails
Since:
5.8LA

getResult

Serializable getResult(long timeout,
                       com.gemstone.bp.edu.emory.mathcs.backport.java.util.concurrent.TimeUnit unit)
                       throws FunctionException,
                              InterruptedException
Returns the result of function execution, blocking for the timeout period until all the results are available.

Parameters:
timeout - the maximum time to wait
unit - the time unit of the timeout argument
Returns:
the result
Throws:
FunctionException - if result retrieval fails
InterruptedException - if the current thread was interrupted while waiting
Since:
5.8LA

addResult

void addResult(Serializable resultOfSingleExecution)
Adds a single function execution result to the ResultCollector

Parameters:
resultOfSingleExecution -
Since:
5.8LA

endResults

void endResults()
GemFire will invoke this method when function execution has completed and all results for the execution have been obtained and added to the ResultCollector

Since:
5.8LA

GemFire 5.8

Copyright © 2002-2008 GemStone Systems, Inc. All Rights Reserved.