Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
-
None
Description
If you want to operate on the local data set for a function, you have to do this
public void execute(FunctionContext context) { RegionFunctionContext ctx = (RegionFunctionContext) context; //This actually doesn't give you the local data set Region wholePartitionedRegion = ctx.getDataSet(); //This does, using a static function call Region localData = PartitionRegionHelper.getLocalDataForContext(ctx); //This is a bad idea, because it may include some buckets that are also being processed on other nodes Region localDataDontDoThis = PartitionRegionHelper.getLocalData(ctx.getDataSet());
There are several problems with this approach.
- It's not clear that ctx.getDataSet does not return the local data.
- The local data set is not mockable for unit tests, because this static function call extracts it using internal APIs on concrete classes. This prevents this sort of function from being tested in a pure unit test.
- The user has to know that PartitionRegionHelper exists; the API is not obvious
- The various methods on PartitionRegionHelper are confusing, specifically it's unclear to a user why they should use getLocalDataForContext instead of getLocalData
RegionFunctionContext should just provide a getLocalDataSet method. We should add this new method to the RegionFunctionContext interface. We should deprecate the PartitionRegionHelper.getLocalDataForContext.
Attachments
Issue Links
- mentioned in
-
Page Loading...