You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Ognen Duzlevski <og...@gmail.com> on 2015/07/06 14:59:00 UTC
Strange compile error with CacheStore / type wrangling in Scala with Ignite
Hello,
I am getting a strange compile error when trying to write my own cache
store in Scala:
[error]
/Users/ognen.duzlevski/code/test/src/main/scala/com/ognenduz/test/Cacheable.scala:79:
type mismatch;
[error] found :
javax.cache.configuration.Factory[com.ognenduz.test.PostCacheStore]
[error] required: javax.cache.configuration.Factory[_ <:
org.apache.ignite.cache.store.CacheStore[_ >: K, _ >: V]]
[error]
cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(classOf[PostCacheStore]))
Here is how the below PostCacheStore is set up with the cache configuration:
cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(classOf[PostCacheStore]))
Below is the basic implementation of the cache store for test purposes - it
just writes and reads from elastic search. In addition, note the required
signature for the write() method - the compiler failed and failed until I
fed it the exact signature/syntax - it seems odd that it would have to be
fed exactly that. I am not much of a Java programmer so any help/hints are
appreciated. Thanks!
class PostCacheStore extends CacheStoreAdapter[String,Post] {
implicit val formats = Serialization.formats(NoTypeHints)
// get client access to eclipse
val e = ElasticClient.remote("localhost", 9300)
// This method is called whenever "get(...)" methods are called on
IgniteCache.
override def load(key:String):Post = {
val r = e.execute {
get id key.toString from "posts"
}.await
read[Post](r.getSourceAsString)
}
override def write(k:javax.cache.Cache.Entry[_<:String,_<:Post]): Unit = {
//println("invoking!")
e.execute({
index into "posts" source k.getValue
})
}
// FIXME: implement the delete method at some point
override def delete(k:Any):Unit = {}
}
Re: Strange compile error with CacheStore / type wrangling in Scala
with Ignite
Posted by Ognen Duzlevski <og...@gmail.com>.
Never mind, stupid, stupid me. Too much work, not enough fun.
Ognen
On Mon, Jul 6, 2015 at 7:59 AM, Ognen Duzlevski <og...@gmail.com>
wrote:
> Hello,
>
> I am getting a strange compile error when trying to write my own cache
> store in Scala:
>
> [error]
> /Users/ognen.duzlevski/code/test/src/main/scala/com/ognenduz/test/Cacheable.scala:79:
> type mismatch;
> [error] found :
> javax.cache.configuration.Factory[com.ognenduz.test.PostCacheStore]
> [error] required: javax.cache.configuration.Factory[_ <:
> org.apache.ignite.cache.store.CacheStore[_ >: K, _ >: V]]
> [error]
> cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(classOf[PostCacheStore]))
>
> Here is how the below PostCacheStore is set up with the cache
> configuration:
>
>
> cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(classOf[PostCacheStore]))
>
> Below is the basic implementation of the cache store for test purposes -
> it just writes and reads from elastic search. In addition, note the
> required signature for the write() method - the compiler failed and failed
> until I fed it the exact signature/syntax - it seems odd that it would have
> to be fed exactly that. I am not much of a Java programmer so any
> help/hints are appreciated. Thanks!
>
> class PostCacheStore extends CacheStoreAdapter[String,Post] {
>
> implicit val formats = Serialization.formats(NoTypeHints)
>
> // get client access to eclipse
> val e = ElasticClient.remote("localhost", 9300)
>
> // This method is called whenever "get(...)" methods are called on
> IgniteCache.
> override def load(key:String):Post = {
> val r = e.execute {
> get id key.toString from "posts"
> }.await
> read[Post](r.getSourceAsString)
> }
>
> override def write(k:javax.cache.Cache.Entry[_<:String,_<:Post]): Unit =
> {
> //println("invoking!")
> e.execute({
> index into "posts" source k.getValue
> })
> }
>
> // FIXME: implement the delete method at some point
> override def delete(k:Any):Unit = {}
> }
>