6 Replies Latest reply on Feb 24, 2012 4:10 PM by Nikolay Kondrashov

    Do AtomicMap's support Query?

    Graham Gear Newbie

      Using ISPN 5.1.0.FINAL and after configuring the infinispan-query module, on a AtomicMapLookup.getAtomicMap() call I get the following exception:


      2012-02-14 23:04:51,133 ERROR ISPN000136: Execution error

      org.hibernate.search.SearchException: Unable to perform work. Entity Class is not @Indexed nor hosts @ContainedIn: class org.infinispan.atomic.AtomicHashMap

                at org.hibernate.search.backend.impl.TransactionalWorker.performWork(TransactionalWorker.java:69)

                at org.infinispan.query.backend.QueryInterceptor.addToIndexes(QueryInterceptor.java:220)

                at org.infinispan.query.backend.QueryInterceptor.visitPutKeyValueCommand(QueryInterceptor.java:127)

                at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:76)

                at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)

                at org.infinispan.interceptors.locking.OptimisticLockingInterceptor.visitPutKeyValueCommand(OptimisticLockingInterceptor.java:111)

                at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:76)


      Am I to assume AtomicMaps are not supported by Query, or is there a way to externally index them?




        • 1. Re: Do AtomicMap's support Query?
          Sanne Grinovero Master


          indeed that's currently not supported, but I could work on it.


          How would you expect the query to look like? We have two levels of keys in this case, the key identifying the AtomicMap and the key identifying the entry in the AtomicMap.

          One approach would be to consider all entries of the same AtomicMap as part of the same entry - so you would search for an AtomicMap and retrive the full map as a result; another approach would be to be able to search for the specific entry as contained in the AtomicMap.


          A third approach would be that AtomicMaps are ignored by the indexing layer, so no errors thrown but also no query options.


          I think I would implement the first model but would appreciate hearing back from you about what expectations you would have, and what your use case is.

          • 2. Re: Do AtomicMap's support Query?
            Graham Gear Newbie

            Thanks Sanne.


            I could see value in implementing all 3 senarios you oultine, but I was specifically looking for the 2nd instance, ie


            search for the specific entry as contained in the AtomicMap


            I have only just started looking at how to structure queries, perhaps I need to revisit my cache architecture. To date I had latched onto AtomicMaps and have been using them to namespace my keys for different typed values, perhaps I need to build composite keys with type prefixes or maybe use multilpe cache instances. More research required.



            • 3. Re: Do AtomicMap's support Query?
              Sanne Grinovero Master

              Hi Graham,


              you might also want to explore the option of storing entries directly in the cache, and have multiple caches.

              It's not advisable to have too many caches, but a cache is likely more efficient than an AtomicMap - so it depends on how many namespaces you're expecting.


              Another option is to create your custom key object; it's very common to implement a key as something like


              class Key {

              final String namespace;

              final long id;

              // constructor

              // equals

              // hashcode


              That pretty much provides you complete isolation across namespaces in the same cache, and is easy to use for indexing.

              • 4. Re: Do AtomicMap's support Query?
                Nikolay Kondrashov Newbie



                Is it good solution to have 1 cache per domain object like in a case of using oracle coherence?  Theoretically it should improve perfomance  in terms of  to iteration over cache or running jobs against cache.


                Is there any potential impact on transactions and replication? I have transactions with a few domain objects involved.


                Thank you.

                • 5. Re: Do AtomicMap's support Query?
                  Sanne Grinovero Master

                  Nikolay, is this a general question or is it in the context of queries ?


                  For Queries it should not be a significant difference to have indexed domain objects in separate caches, but you're correct for the scope of the Infinispan container this might reduce contention on the internal container structures. Carefull however as having too many caches might also not scale, they take quite some memory: don't create thousands of caches.


                  Both transactions and replications should work the same, no matter if you store objects in the same cache or in different caches.

                  • 6. Re: Do AtomicMap's support Query?
                    Nikolay Kondrashov Newbie

                    Yes. This was a general question. I'm going to have a few business objects residing in separate caches. Let say User, Address, Company and correspondent caches UserCache, AddressCache, CompanyCache. As few business objects of different types might be involved into a transaction I want to make sure that all caches will be consistent and transaction will be propagated to recovery site node in a proper way.


                    Thank you for your reply.