Hi Ilya,

Thank your reply. And for my code it works partially. 

<property name="binaryConfiguration">
          <bean class="org.apache.ignite.configuration.BinaryConfiguration">
<property name="compactFooter" value="false"/>
         </bean>
</property>

above configuration works for the caches which have declared Java Class as the cache value. 
It seems it doesn't work for the caches which created by "setQueryEntities".

My Use case like below:

# 1, I create caches dynamically by calling setQueryEntities.
# 2, I want to load all caches when server start.
# 3, For I create caches dynamically, so I can't use spring XML configuration.
# 4, I save the cache creation parameters somewhere, and in the LifeCyleBean, I create the caches and call loadCache.

 metricCache = ignite.createCache(CacheUtils.createColumnCacheConfiguration(tableSchema.getCacheName(), tableSchema,cacheConf));
if (metricCache != null && cacheConf.isPersistEnable())
{
metricCache.loadCache(null);
}

I guess every time, cache created by setQueryEntities even with the same parameters they have different hashcode. 
please confirm.


                
Thanks
Shawn

On 02/9/2017 19:03Ilya Lantukh<ilant...@gridgain.com> wrote:

On Thu, Feb 9, 2017 at 1:28 PM, shawn.du <shawn...@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

Reply via email to