8 Replies Latest reply on Jun 4, 2008 10:04 AM by Peter Kovgan

    parametrizing

    Peter Kovgan Newbie


      What do parameters mean?

      I can't figure out it myself, almost...

      public interface CacheFactory<K, V>

      public interface Cache<K, V>

      public interface Node<K, V>


      Thank you!






        • 1. Re: parametrizing
          Mircea Markus Master

          K is the Key type in the Node's attribute map.
          V is \Value's type

          • 2. Re: parametrizing
            Peter Kovgan Newbie

            Thanks!
            What about Cache and Factory?

            • 4. Re: parametrizing
              Peter Kovgan Newbie

              Sorry, I'm a new and so absolutely ignorant in what supposed to be clear to you!

              What do you mean, when you tell:

              "attributes" of node?
              "attributes" of cache?
              "attributes" of the cache factory?

              You said that K,V - it's types of key and value of attributes of those respected 3 players.

              Ok,

              1)
              could you, please , clarify, how can I know, what type of attributes will be used by me in Node for example?

              If in Node it's approximately clear, because node is analog to Map, then in Cache is absolutely unclear to me, because Cache may have several attributes of several different types? No?
              Cache Factory also?

              Consider I have Node, that I decided to parametrize <String, Nana>, because I need save several Nanas with key-String, it's clear.

              But, what is Cache parameters?
              In entire cache I have different nodes, how could I know what is better for cache?

              2)
              I do not understand at all, why you chose Node as a controlled unit of work(configurable evictions on node level, not on level of node's entries in map(node.put(...))), suppose I created a node to save a Map of objects, if I manage eviction by maxNodes=10, but I have this 1 node, I will never reach max, but map of objects in Node will grow and at the end will go out of memory. So Why Node is last controllable limit, why not amount of objects in node's map?

              3) I do node.removeChild(..) and in JMX console I see, that number of nodes did not change. although this method returns TRUE, so I can assume node was removed?

              Thanks!!!!!!!



              • 5. Re: parametrizing
                Mircea Markus Master

                 

                "attributes" of node?

                each node has an associated Map<K,V> of objects. This are attributes of the node.

                "attributes" of cache?
                "attributes" of the cache factory?

                The cache and cache factory is parametrized with the same type as the attribute map, there are only two parameters used in all Cache api - K,V, and in all cases they refer to the type of node's attributes
                2)
                I do not understand at all, why you chose Node as a controlled unit of work(configurable evictions on node level, not on level of node's entries in map(node.put(...))), suppose I created a node to save a Map of objects, if I manage eviction by maxNodes=10, but I have this 1 node, I will never reach max, but map of objects in Node will grow and at the end will go out of memory. So Why Node is last controllable limit, why not amount of objects in node's map?

                This was brought into discussion in past. You can use only one element pet node and achieve the same effect. The idea of having an eviction based on the number of attributes in a node/region sounds interesting, though at a second thought it might be achieved by using only one attribute per node.


                • 6. Re: parametrizing
                  Peter Kovgan Newbie

                  Thank you, Markus

                  I just do not understand completely,

                  do you mean, if I have Node<A,B>, then Cache must be <A,B> too, and it's CacheFactory<A,B> ?

                  It sound's like a limitation and means, I need use entire cache only for A,B...

                  Please, be forgiving to my ignorance... :)

                  • 7. Re: parametrizing
                    Mircea Markus Master

                     

                    do you mean, if I have Node<A,B>, then Cache must be <A,B> too, and it's CacheFactory<A,B> ?

                    on the short - yes

                    It sound's like a limitation and means, I need use entire cache only for A,B...
                    Please, be forgiving to my ignorance... :)

                    It is not a limitation at all, as you can declare both K and V of type Object. It comes with all the benefits Java Generics brings :)
                    (conceptually, the Cache is a collection of objects. Much nicer working with parametrized collections.)