[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to use a comparator?



Hi Neil,
>
>Don:
>
>I retrieved the objects in a non-update method, which
>used a read-only transaction on the server.  As I interpret
>it, any modificaitons to the objects will not be updated
>in the database in this scenario.  Is this correct?

If the methods used to update the ozone database objects are designated as 
update methods the objects will be updated in the database. Regardless of 
whether they are retrieved using an update method or not, since the TreeSet 
is not a ozone object any members that are added or deleted directly to the 
TreeSet will not be added or deleted in the database.

>Well, what I want to do is to have an ordering to my
>objects.  They are added one-at-a-time to the database
>and I wanted to retrieve a set of the ones added so far.
>
>I want to keep them in order when I use them on the client.
>
> > What is the cardinality of the sets?
>
>I dont understand this statement, please explain.

How many objects in the TreeSets?
>
> > Will the sets be updated?
> >Will  set member attributes involved in the sorting be updated?
>
>No, the set is just a way to step-thru all of the objects
>in the database.
>

>
> > How will the set be
> > used? e.g. Values are displayed and members selected in a GUI.
>
>Yes, this is exactly what I want to do.
>If the person wants to update a member, I will have to call
>an update method on the member object and then re-load the set from
>the server since I read it out in a read-only transaction.
>

Performance may be a problem since to display values in a GUI methods will 
be invokes on the client for each attribute in each element. So if your 
TreeSet contains 100 objects and 3 attributes are displayed there will be 
300 RMI calls to get the data.

The approach I am using in this situation was recently discussed on the 
list. When the collection is built on the server it is populated with a 
lightweight object for each ozone object that contains the values to be 
displayed and the associated ozone-object which will be in the form of a 
proxy on the client side. This way a single RMI call is made, the values can 
be displayed without any additional RMI calls, and any updates can still be 
done by invoking methods through the proxy.

It takes a little longer to build the TreeSet on the server but since all 
objects are on the server side it's dramaticaly faster than retrieving each 
display value from the client. The lightweight object can have its own 
compareTo() method for the ordering. If the sets are large it will probably 
be faster to put the objects in an ArrayList and then sort it using the 
Collections class sort() method before return it. Otherwise the TreeSet must 
be reshuffled each time a new element is added during the building process.

I'm in the process of addressing the update issues with this strategy. For 
the moment my application just gets a new collection as you mentioned.

Hope this helps.

cheers,

don
_____________________________________________________________________________________
Get more from the Web.  FREE MSN Explorer download : http://explorer.msn.com