4 Replies Latest reply: Dec 12, 2012 9:15 AM by 958563 RSS

    Pof collection

    958563
      Coherence 3.7.1

      I put a Collection as a Cached Object into Coherence. Come back and read it several times grabbing different segments of the Collection.

      Any ideas which Collection would be most performant (java ArrayList or java elements array or any other option).

      Thanx,
        • 1. Re: Pof collection
          660069
          Hi,

          There are specific serialization functions (I'm talking about POF) for writing arrays and collections. I tend to use ArrayLists, as they're easy to manipulate, fast, and have direct equivalents in both C# and C++.

          Your container choice will always be overshadowed by the cost of class deserialization. I don't know enough about the particulars of what you're dong. However if you're running code in the grid, you might want to consider operating directly on the binary (POF serialized form). This is a slightly more involved process, especially when it comes to collections, however will yield the fastest results.

          Cheers
          Rich
          • 2. Re: Pof collection
            958563
            Hi Rich,

            I access the Cache member from an Entry Processor.

            One thing I've noticed is the first time a the PofCollection segment is accessed (repeatedly calling getChild(n) api),

            it takes somewhat longer then when i come back and repeat the same exact operation.

            So was wondering if the Collection (java.util.ArrayList right now) is getting optimized to something else and I could use that itself from the beginning to get consistent response times.

            Thanx,
            • 3. Re: Pof collection
              660069
              Hi,

              Could you post a section of your code?

              That way I can get a better idea of what you're doing.

              Cheers
              Rich
              • 4. Re: Pof collection
                958563
                Here it is :

                Inside my EntryProcessor class :


                Extract PofValue from BinaryEntry (obtained from BackingMap, BinaryEntry is the Cached PofObject)

                return first 1000 elements from the CachedObject.


                               List<T> payload = new ArrayList<T>(1000);
                               for (int i = 0; i < 1000 ; i++ )
                               {
                                    payload.add((T) ((PofCollection) pofValue).getChild(index).getValue());
                               }


                Pls. let me know if i need to clarify etc.

                Thanx,