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

Ask Your Question

Read objects from space based on other objects of a different type.

Apologies in advance for another stupid question and my poor use of terminology.

I have space full of objects which represent orders for different products. The users of this system can set-up named searches.I'd like to implement a search interface which where the a space is given the name of a filter which returns all the object that match the filter.

The plan was to do this by writing a NamedSearchObject POJO to the space which contains all the details of a given search. The space could build and store a SQLQuery object which will actually do the search.The user client can then access the space with a "search function" providing the search name in a string. On the space the actual NamedSearchObject object is retrieved and executed.

The problem is I cannot work out how to implement search function. All the code which I've seen reads the space by proving a template of the object to be searched for. In my case the template object type and the object to be searched for are different. The template object is a string (the name of the search) and the object to be searched for is a Order.

I've looked at Space Filters, but I cannot see how I can use them as I do not understand how I would pass information to the Space Filter (e.g. the name of the NamedSearchObject).I could implemented by accessing the space twice. Once to retrieve the SQLQuery from NamedSearchObject and then executing the SQLQuery to get the Orders.

But I'd like to fo this all on the server side in one call if possible.

Could anyone give me some hints on how to do this "The Gigaspaces Way".



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

asked 2012-05-17 07:53:53 -0500

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


Here is a simple solution:
Have a Query object that stores the query name (SpaceId), SQL query string and the space class. You will have these stored in the space.

Once you want to query based on a name , Read the query object based on its ID , generate a SQLQuery object using the query oject data and call the readMultiple with the SQLQuery as the template.

Would this work for you?

answered 2012-05-17 09:20:12 -0500

shay hassidim gravatar image
edit flag offensive delete link more



Yes that's more or less what I'd like to do. But when you say "Read the query object based on its ID " do you mean that this query is returned to the client where the read of the data is triggered by calling a second read (based on the returned query) of the space. E.g. there are two reads from the client:

one to get the query one to do the actual read.

I understand how I can do this, but I'd like to do the read in one call from the client. There is no need to sending the query back to the client, so I'd like to determine if it's possible to process the "Read the query object based on its ID" and generate the query on the space, and just return just the DTOs to the client (in my example these are Orders POJOs).

I realise this is a bit of a contrived example, but if the query objects were very large it would not be desirable to send them to the client, when the clients, does not care about them. I guess there could be some kind of service interface which sits on top of the space an provides this kind of functionality and this could sit on the same machine, but I'd like to have the clients talk directly to the space with northing in between.



greek87 gravatar imagegreek87 ( 2012-05-21 12:38:56 -0500 )edit


In such a case have a Task implemented to retrieve the query object and execute the query against the space. The Task execute should be injected with a clustered proxy to be able to query all partitions. Another option would be to have a service implemented. In both cases you should rout the Task/service call to the correct partition where the query object is located. Both would return the query result.


shay hassidim gravatar imageshay hassidim ( 2012-05-21 21:42:07 -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


Asked: 2012-05-17 07:53:53 -0500

Seen: 41 times

Last updated: May 17 '12