ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ilya Lantukh <ilant...@gridgain.com>
Subject Re: restore Java Object from BinaryObject
Date Thu, 09 Feb 2017 11:03:22 GMT
Hi,

In your case you should disable compact footer. See
https://ignite.apache.org/releases/mobile/org/apache/ignite/configuration/BinaryConfiguration.html#isCompactFooter()
.

On Thu, Feb 9, 2017 at 1:28 PM, shawn.du <shawn.du@neulion.com.cn> wrote:

> Hi,
>
> I implement a cacheStore, this cachestore will persist a binaryObject
> into bytes and store in MySQL blob.
> Exceptions occurred when calling loadCache function:
> binaryObject.deserialize() will throw exceptions like "Cannot find
> metadata for object with compact footer: -1615140068"
> If  I just put the binaryObject into the cache without deserialization ,
> it is ok.  when i get it and use it, it will throw the exception again.
> How to fix it? Thanks in advance.
>
> public class BlobCacheStore extends CacheStoreAdapter<String, BinaryObject>
>
> {
>
>    public void loadCache(IgniteBiInClosure<String, BinaryObject> clo, Object...
args)
>
>   {
>     init();
>     String sql = TEMPLATE_LOAD_SQL.replace(FAKE_TABLE_NAME, tableName);
>     try (Connection connection = dataSource.getConnection();
>          Statement statement = connection.createStatement();
>          ResultSet rs = statement.executeQuery(sql))
>     {
>         while (rs.next())
>         {
>             String key = rs.getString("aKey");
>             Blob blob = rs.getBlob("val");
>             BinaryObject binaryObject = ignite.configuration().getMarshaller()
>                     .unmarshal(blob.getBytes(1, (int) blob.length()), getClass().getClassLoader());
>             blob.free();
>             ignite.cache(cacheName).put(key, binaryObject.deserialize()); //here will
throw exceptions
>         }
>     }
>     catch (Exception e)
>     {
>         throw new IgniteException(e);
>     }
>   }
>
> }
>
>
> Thanks
> Shawn
>
>


-- 
Best regards,
Ilya

Mime
View raw message