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

Ask Your Question

using SQL's MAX when query the space

Hi, I see that the browser from the Management UI supports: "select MAX([Field_of_MyPOJO]) from MyPOJO" How can I do (something like) this in my code using the API? At last how to obtain a MyPOJO instance with the max/min value for a particular field? Thanks, Lucian h4. Attachments


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

asked 2009-09-17 02:52:16 -0500

lukeh 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

Few options:
- Use JDBC API - http://www.gigaspaces.com/wiki/display/XAP7/JDBCDriver
- Use Executors - read the objects, find the max/min within each partition and reduce the results. See:

- Use ExternalEntry. This is more an advanced option. See attached code. It is old an example so it might need some adaptation to work with XAP 7.

In all cases make sure you use extended indexing.
This will make sure that when you do the query (field > Integer.MINVALUE to find min object or field < Integer.MAXVALUE ) you will get the right object - When having the extended indexing used and you query the indexed field , the result set will be ordered in ascending manner. See:



  1. EEQuery.java

answered 2009-09-17 07:32:46 -0500

shay hassidim gravatar image
edit flag offensive delete link more


Thanks Shay, Any performance differences between those methods, considering I have all the data on one partition and data affinity? Before asking here I considered using "order by" in the query and readMultiple(query, 1). How fast is this compared with your suggestions? Lucian

lukeh gravatar imagelukeh ( 2009-09-21 08:26:48 -0500 )edit

For small data sets there would not be any difference. If you have large amount of data , the ExternalEntry approach should provide very good performance. "order by" in the query and readMultiple(query, 1) should also provide good performance. In both cases , I assume you have extended indexing used. Shay

shay hassidim gravatar imageshay hassidim ( 2009-09-21 09:00:49 -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: 2009-09-17 02:52:16 -0500

Seen: 126 times

Last updated: Sep 17 '09