Ignite with Cassandra integration

心不动则不痛 提交于 2019-12-12 06:58:15

问题


I am trying to integrate Ignite with Cassandra. I am using persistence strategy as BLOB. when i run the program it shows an error like "com.datastax.driver.core.exceptions.CodecNotFoundException: Codec not found for requested operation: [varchar <-> java.nio.HeapByteBuffer] at com.datastax.driver.core.CodecRegistry.notFound(CodecRegistry.java:679) "

here is my persistence xml file

<persistence keyspace="sam" table="key">
<keyPersistence class="java.lang.String" strategy="BLOB" column="key"/>
<valuePersistence class="java.lang.String" strategy="BLOB" column="value"/>
</persistence>

main.cpp

int main()
{
IgniteConfiguration cfg;
cfg.springCfgPath = "apache-ignite-fabric-2.0.0-bin/cassandra-config.xml";
Ignite grid = Ignition::Start(cfg);
Cache<Test, Test> cache = grid.GetCache<Test, Test>("cache1");
Test obj;
cache.LoadCache ();
Test key;
key.key = "123dfsdfs";
obj.value = "sdfsf";
cache.Put (key,obj);
return 0;
}

回答1:


The error means that the type of the column in Cassandra is varchar, but you're trying to write a BLOB into it. Thus the failure.

But why do you use BLOB strategy for strings? You can write a string as is to a varchar column by using PRIMITIVE strategy instead.



来源:https://stackoverflow.com/questions/44254079/ignite-with-cassandra-integration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!