问题
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