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

Ask Your Question
0

Assigned UID for POJOs

Is it possible to generate and assign client generated UIDs for POJO entries?

From the docs: * When a POJO object has no SpaceId property declared, the space generates a UID for the object. * When a POJO object has a property which is declared as SpaceId and marked as auto-generate=false, the UID is generated using the ClientUIDHandler utility class. * When a POJO object has a property which is declared as SpaceId and marked as auto-generate=true, the UID is generated by the space and placed back into the field using the relevant setter method. In this case, the field must be a java.lang.String type.

What I am looking for is to manually create our own UID of a string type and explicitly set it on a POJO like is possible with Entry objects without using the ClientUIDHandler class.

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

asked 2008-09-15 13:06:14 -0500

davebyrne gravatar image

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

jaissefsfex gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

When you have the @SpaceId(autoGenerate = false) for annotated getter method you must provide a value for this field before writing it into the space.
This value will be used as the bases for the entry UID within the space.

You can use this value (the original one you used) later to fetch the object back when used with a template with read/take/readMultiple/takeMultiple operations.

The Space entry UID is a string based identifier and is composed of the following parts:
- Class information - class hashcode and name size.
- Space node name - At clustered environment combined from container-name :space name. At non-clustered environment combined from a dummy name.
- Timestamp.
- Counter

Shay

answered 2008-09-15 17:41:19 -0500

shay hassidim gravatar image
edit flag offensive delete link more

Comments

We have long package names for our space entites which results is very large generated UIDs from ClientUIDHandler. We would like to reduce the overhead of the UID storage by replacing the generated UIDS from ClientUIDHandler with our own implementation. We are currently using @SpaceId(autogenerate=false). Is this possible?

davebyrne gravatar imagedavebyrne ( 2008-09-16 12:29:39 -0500 )edit

If you are using POJO , you should not use the ClientUIDHandler directly.

Shay

shay hassidim gravatar imageshay hassidim ( 2008-09-16 15:58:31 -0500 )edit

We are not using ClientUIDHandler directly. It is called implicitly by annotating the id (autogenerate=false). However, I would like to use a more memory-efficient UID string than is implemented via ClientUIDHandler in gigaspaces. Is it possible to do this with a POJO?

davebyrne gravatar imagedavebyrne ( 2008-09-16 17:51:02 -0500 )edit

The class name and package is not used for the UID.

You can use the @SpaceId(autoGenerate= false) to use your unique value to be the bases for the space UID instead of having the space generating such. This UID will be construced using the following (this is valid for clustered and single space): Class name String hash code + Class Name Length + Your provided Unique ID + ^0^0

If the space you are using is clustered and @SpaceId(autoGenerate= true ) the UID that will be generated will be the following String: Class name String hash code + Class Name Length + Space container name + : + Space Name + Time stamp + Counter

If the space name is very long - it will impact the UID size.

The above means you should use @SpaceId(autoGenerate=false) to reduce the UID size.

Shay

Edited by: Shay Hassidim on Sep 17, 2008 12:33 AM

shay hassidim gravatar imageshay hassidim ( 2008-09-17 00:24:52 -0500 )edit

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-09-15 13:06:14 -0500

Seen: 471 times

Last updated: Sep 15 '08