This discussion is archived
2 Replies Latest reply: Aug 22, 2013 3:31 AM by 82420128-c6b8-49b4-9804-510cbc337b09 RSS

Error with KeyExtractor

82420128-c6b8-49b4-9804-510cbc337b09 Newbie
Currently Being Moderated

Guys,

 

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 3.7.1.6 <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 3.7.1.6 <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....

 

Thanks

D

  • 1. Re: Error with KeyExtractor
    Jonathan.Knight Expert
    Currently Being Moderated

    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);
    
    

     

    JK

  • 2. Re: Error with KeyExtractor
    82420128-c6b8-49b4-9804-510cbc337b09 Newbie
    Currently Being Moderated

    Thanks JK.  Works Perfectly.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points