2 Replies Latest reply: Aug 22, 2013 5:31 AM by 1028528 RSS

    Error with KeyExtractor




      When addeding index on a key object in cache using

      cache.addIndex(new KeyExtractor(new PofExtractor(Long.class, Key.GLOBAL_ID)), false, null);


      Am getting

      2013-08-21 17:54:33.978/47.657 Oracle Coherence GE <Warning> (thread=DistributedCache:ContractDistributedCache, member=1): An Exception occurred during index update for key ComponentKey [componentId=5920120219110236070, contractId=5920120219130853322]. The entry will be excluded from the index for cache XYZZZZ...


      2013-08-21 17:54:33.978/47.657 Oracle Coherence GE <Warning> (thread=DistributedCache:ContractDistributedCache, member=1): java.lang.UnsupportedOperationException:

            at com.tangosol.util.extractor.AbstractExtractor.extract(AbstractExtractor.java:56)

            at com.tangosol.util.extractor.KeyExtractor.extract(KeyExtractor.java:101)

            at com.tangosol.util.extractor.AbstractExtractor.extractFromEntry(AbstractExtractor.java:115)

            at com.tangosol.util.InvocableMapHelper.extractFromEntry(InvocableMapHelper.java:327)

            at com.tangosol.util.SimpleMapIndex.extractNewValue(SimpleMapIndex.java:252)

            at com.tangosol.util.SimpleMapIndex.insertInternal(SimpleMapIndex.java:363)

            at com.tangosol.util.SimpleMapIndex.insert(SimpleMapIndex.java:153)


      Is there something obviously wrong am doing? Does PofExtractor doesnt work with KeyExtractor??  After bit of digging I found PofExtractor doesn't override extract() and hence AbstractExtractor.extract() is called which is throwing the exception.


      But if I add index on the same key object using  

      cache.addIndex(new KeyExtractor("getGlobalId"), false, null);

      All works fine....




        • 1. Re: Error with KeyExtractor

          Hi D,


          Your problem is that a PofExtractor is an EntryExtractor and requires the whole BinaryEntry entry to be passed to its evaluateEntry method. When you wrap it in a KeyExtractor then the KeyExtractor takes the Key from the entry and passes it to the PofExtractor.evaluate() method - which is not supported. All you need is a PofExtractor without wrapping it in a KeyExtractor. The PofExtractor has another constructor that takes a third parameter that allows you to specify whether its extraction target is the Key or the Value. There are some constants in PofExtractor to do this, PofExtractor.KEY and PofExtractor.VALUE the default with the two parameter constructor is to target PofExtractor.VALUE.


          cache.addIndex(new PofExtractor(Long.class, Key.GLOBAL_ID, PofExtractor.KEY), false, null);



          • 2. Re: Error with KeyExtractor

            Thanks JK.  Works Perfectly.