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

Ask Your Question
0

Get object by copy or by reference. Confused

Hello

Until recently I think, what "/./testSpace" with "cluster=true" is analog "jini:///testSpace". But today when I read my entities from embedded cluster space by ids and change their in code - I saw - what this objects is changed also in space!!! This means that my objects pass by reference, not by copy! But I don't understand - why gigaspace have embeded cluster and non-cluster spaces? Because in both cases when my object in this processing unit embedded space - always this object passed by reference. I.e.

1) "jini:///testSpace". When I read object from space and change their in my code - it not affected space object.

2) "/./testSpace". When I read object from space and change their in my code - it affected space object(object passed by reference). If embedded space not contains object - gigaspace doesn't see on other partition and return null

3) "/./testSpace cluster=true". When I read object from space and change their in my code - it affected space object(object passed by reference). If embedded space not contains object - gigaspace see on other partition and return copy of object and next changes not affected this object.

I'm right?

asked 2014-03-10 09:30:36 -0500

ssherbakov gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

In embedded mode – non-primitive fields as passed by reference. If you want to change this behavior you should use the binary storage type. This will impact the performance. See more below – don’t miss the “Reading and Changing Object in Embedded Mode without Writing it Back” section: http://docs.gigaspaces.com/xap97/stor...

Shay

answered 2014-03-10 09:36:14 -0500

shay hassidim gravatar image
edit flag offensive delete link more

Comments

But my qyestiob is - if I'm use embedded clustered space - "/./testSpace cluster=true", - all objects from current space was passed by reference, but objects from others cluster members - via serializy-desirialize?

ssherbakov gravatar imagessherbakov ( 2014-03-13 04:36:01 -0500 )edit

This is a special case.

If the clustered proxy accessing a remote or local partition (Afaik) it will perform serialization which means you will get a deep cloned copy. The object will be fully materialized. You will not get non-primitive fields by reference. You can test it to confirm the behavior. We had some changes around this few years ago.

shay hassidim gravatar imageshay hassidim ( 2014-03-13 06:05:09 -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: 2014-03-10 09:30:36 -0500

Seen: 150 times

Last updated: Mar 10 '14