This content has been marked as final. Show 3 replies
If you make your ValueExtractor extend com.tangosol.util.extractor.EntryExtractor then you can override the extractFromEntry() method that will be passed the entry for you to extract data from. As this is likely to be a BinaryEntry for a distributed cache you can use the code you have posted inside that extractor.
I assume you are using some form of Key Association to make sure that the Binary key returned by ctx2.getKeyToInternalConverter().convert("SomeObject") is actually located in the same partition as the key of the entry being extracted - otherwise the code will not work.
Yes, those objects are guaranteed to be on the same node.
Would extending EntryExtractor (your way) make more sense (work faster) then something like this in regular ValueExtractor:
BackingMapManagerContext ctx = ((com.tangosol.net.DistributedCacheService)CacheFactory.getService("")).getBackingMapManager().getContext();
Map childCache = ctx.getBackingMapContext(RflxCaches.RflxRiskCache).getBackingMap();
Binary MyObject = (Binary) childCache.get(ctx.getKeyToInternalConverter().convert("SomeObject"));
Yes, it would make more sense to extend EntryExtractor as you are given a BinaryEntry so you can access backing maps etc very easily. Personally I think calling the static CacheFactory methods should be avoided as much as possible. For example, how would you unit test your code that uses CacheFactory.get*() methods? Assuming you do unit testing of course. And yes, I know there are mock frameworks that allow you to mock statics but they are the spawn of the devil and also best avoided.