Is it possible to remove a specific item from the Ignite shared cache (IgniteRDD)?
For example, in the following code, how could you remove the only item (21, 21)?
val cacheRdd = igniteContext.fromCache("partitioned")
cacheRdd.savePairs(sparkContext.parallelize(1 to 10000, 10).map(i => (i, i)))
IgniteRDD provides a method called clear()
that removes all content from the cache. Is there something similar to remove a specific item?
I know several ways to do it:
1)Using SQL delete command
val cacheRdd = igniteContext.fromCache("Person")
val result = cacheRdd.sql(
"DELETE FROM PERSON WHERE ID=1")
2)Using JCache API:
// Creates Ignite context with specific configuration and runs Ignite in the embedded mode.
JavaIgniteContext<Integer, Integer> igniteContext = new JavaIgniteContext<Integer, Integer>(
sparkContext,"examples/config/spark/example-shared-rdd.xml", false);
IgniteCache<Long, Person> personIgniteCache = igniteContext.ignite().getOrCreateCache("Person");
personIgniteCache.remove(1L);
The same from scala:
val igniteContext = new IgniteContext(sparkContext, CONFIG, false)
igniteContext.ignite().getOrCreateCache("Person");
You also can just start Ignite node in your driver application.
BR, Andrei