Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

Recommended Way of Storing a Reference

Lets say I have a partitioned system that contains Persons. Each Person has a unique id and a collection of contacts which reference other Persons. I could store the collection of contacts in two different ways -- one using Java references and the other using the unique ids which I could later use to query my contacts.

ArrayList<person> contacts; // using Java references

ArrayList<string> contacts; // use the ids to query for contacts

If I use Java references I would create a tree like structure of Person references in memory:

{personA {personB, personC {personD, personE, personF}, personG {personH, personI}}}}

In the above example if I were to read personA from the space would it also implicitly read personB, personC, and personG? What about personD, personE, personF, personH, and personI? Does the same logic hold if I were to update personA? Is it safe to assume that you're using lazy loading? As the tree grows would I eventually run into problems with Space boundaries?

My big question is how would you recommend managing my list of contacts considering a partitioned cluster?

Edited by: Vincent Piotrowski on Feb 5, 2008 12:52 PM

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=1984]{quote}

asked 2008-02-05 11:50:18 -0500

vpiotrow gravatar image

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

Vincent,
This should answer your question:
http://www.gigaspaces.com/wiki/display/GS6/JavaSpacesUIDSupport-6.0#JavaSpacesUIDSupport-6.0-ParentChild

This is relevant for very large object graphs. I would recommend this option when you really have large graph , want to update only specific object and want to query the child objects separately.

Other options would include serializing the ArrayList in optimal manner (as byte array) in order the ArrayList would not be de-serialized when stored in the space and when send out to the client when reading it. The client will explicitly de-serilize the byte array data when reading the object just before the business logic accessing the ArrayList.
This will boost the remote operations and replication time , but will not allow fine grain control for specific object update or read. We call this technique lazy serialization. If you are interested with running example let me know. In the future we will provide this capability out of the box.

The simple option involves having as part of the ArrayList application unique value per child object and fetch the child objects using regular query. For more cases this is enough. The query performance using indexed fields is relatively very fast.

Please note:
- UID operations are used mostly with Entry based classes. These are advanced product options.
- We do not support Hibernate lazy load with the HiebernateDataSource - so, if you want to have such , you will need to go for the ArrayList<String> contacts option that will implicitly load the child objects once you read these explicitly via their UID.
- You should have the same routing field value for the parent and child object to make sure all these will be stored within the same partition.
- If your space running in LRU cache policy mode with ExternalDataSource used (e.g HiebernateDataSoruce) and the searched object within the space is not found the space will query the database and fetch the object from the database ( aka space lazy load). - If you use readMultiple + LRU cache policy + ExternalDataSource and the space does not store enough matching objects as the max-objects the database will be queried. This manes the readMultiple should be carefully used when running in this mode.

Shay

answered 2008-02-05 12:36:08 -0500

shay hassidim gravatar image
edit flag offensive delete link more
0

Thanks for the help.

answered 2008-02-11 17:50:41 -0500

vpiotrow gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2008-02-05 11:50:18 -0500

Seen: 153 times

Last updated: Feb 11 '08