6 Replies Latest reply: May 7, 2013 3:28 AM by bish RSS

    CacheStore access to binary value in store/storeAll

      What is the best way to get the raw binary value of the entry(ies) in a store/storeAll CacheStore method?
        • 1. Re: CacheStore access to binary value in store/storeAll
          In actual fact, I would like to still have the key as an Object, but receive the value as binary. I have looked at subclassing BinaryStoreCacheStore, but each time I try and do any ExternalizableHelper call (to or fromBinary), an exception is thrown as it does not appear to understand that it is a POF type. How can I let the cachestore know about the pofcontext?
          • 3. Re: CacheStore access to binary value in store/storeAll

            If you want a cache store that works with Binary keys/values you need to implement BinaryEntryStore http://docs.oracle.com/cd/E24290_01/coh.371/e22843/toc.htm

            The methods of a BinaryEntryStore will be passed BinaryEntry instances which you can then use to get the binary keys and values or the Object keys and values etc...

            • 4. Re: CacheStore access to binary value in store/storeAll
              Hi Jk,

              Thanks. This is actually what i had been trying without any success (although i mistakenly said BinaryStoreCacheStore rather than BinaryEntryStore in the post above). When the BinaryEntryStore.store is called, i try and convert just the key back to object with:

              Object o = ExternalizableHelper.fromBinary(paramBinaryEntry.getBinaryValue());

              but like i mentioned above, this throws the following as it seems to think the binary is not pof.

              java.io.StreamCorruptedException: invalid type: 171
                   at com.tangosol.util.ExternalizableHelper.fromBinary(ExternalizableHelper.java:266)
                   at com.tangosol.util.ExternalizableHelper.fromBinary(ExternalizableHelper.java:230)
                   at com.b.p.coherence.cacheStore.DatabaseCacheStore.store(DatabaseCacheStore.java:139)
                   at com.tangosol.net.cache.ReadWriteBackingMap$BinaryEntryStoreWrapper.storeInternal(ReadWriteBackingMap.java:6035)
                   at com.tangosol.net.cache.ReadWriteBackingMap$StoreWrapper.store(ReadWriteBackingMap.java:4814)
                   at com.tangosol.net.cache.ReadWriteBackingMap.putInternal(ReadWriteBackingMap.java:1236)
                   at com.tangosol.net.cache.ReadWriteBackingMap.put(ReadWriteBackingMap.java:745)

              • 5. Re: CacheStore access to binary value in store/storeAll

                First: you are calling the ExternalizableHelper.fromBinary in the wrong way, which is why it is not working. There are two versions of ExternalizableHelper.fromBinary one that takes just the binary to be deserialized and the second takes the binary and a serializer, it is the second method you need to use to deserialize POF as you need to pass in the POF context as the serializer.

                Second: there is no need to call ExternalizableHelper.fromBinary as the store method is passed a BinaryEntry so you can just call getKey() on that to give you back the Object key; so in your case just use paramBinaryEntry.getKey();