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

Ask Your Question
0

Query for read all.

Hi, I need the query to read all the objects from the space. Please can any one provide me the query for the same.

Thanks Jitendra

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

asked 2009-08-19 15:14:44 -0500

jknayak 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

Try:
gigaspace.readMultiple(new Object() , Integer.MAX_VALUE);

You should be able to do the same with GSIterator.

Any special reason for reading everything within the space without any filtering?

Shay

answered 2009-08-19 15:42:20 -0500

shay hassidim gravatar image
edit flag offensive delete link more

Comments

This is just the requirement for the screen/front end. If I am not providing any filter it should get me all the values.

I am using C++ interface. And here is my sample code. Please suggest what changes I have to do here.

MyClass sampleObj; // Query to find all the objects where city is NY.. How to get all the objects and what will be the query ??? std::string queryString = "city like 'NY'"; SqlQuery cacheQuery(&sampleObj, queryString); std::vector<ientry*> responseBatch; try{ responseBatch = spaceProxy->readMultiple(cacheQuery, NULL_TX, 10000, DIRTY_READ); std::cout<<" The output size "<<responsebatch.size()<<std::endl; }="" catch(xapexception="" &e){="" std::cout="" <<="" "error="" -="" read="" failed="" "="" <<="" e.getname()="" <<="" std::endl;="" }<="" p="">

I have another question here. I guess the default output size of the readMultiple() method is 100000 objects. Can we go beyond that ? I mean to say that if my space having more than 100000 object and I want to fetch those how to do that.

Thanks Jitendra

jknayak gravatar imagejknayak ( 2009-08-19 15:56:41 -0500 )edit

There is no default for the readMultiple max objects to return. It would return everything within the space that matches the query criteria (in case you have Integer.MAX_VALUE as the max_objects parameter). This might cause problems with VERY large data set (load the network , load the client and consume large amount of memory).

Here are the different approaches you might want to try when there is a need to fetch/read large amount of data from the space: 1. Use the GSIterator – this will fetch objects in batches from the space. You can control the batch size. This will be a bit slower than the readMultiple but will not consume large memory at the space side. See: http://www.gigaspaces.com/wiki/displa... . Make sure you use the CURRENT IteratorScope when constructing your GSIterator. 2. Use Task Executors and perform your business logic at the space side (this is supported with Java and .Net for now). This will avoid the need to transfer the whole data over the network to the client side. Within the Task implementation you could send back only the data the client needs in optimal manner (and reduce it) rather than sending back the whole object. This will provide the best performance and flexibility. With C++ you can imitate this by using Request/Response model and run C++ PU. 3. Change the LRMI buffer chunk size. This system property should be placed on the GSC JVM using the EXT_JAVA_OPTIONS variable (and also the client side). You might need to twick it until you will get the desired behavior. The system property is com.gs.lrmi.maxBufferSize. It is in bytes. Its default value is 655360. You might want to start with 100000 as a value.

Shay

shay hassidim gravatar imageshay hassidim ( 2009-08-19 16:12:04 -0500 )edit

Hi Shay,

Thanks a lot for the response. Sorry to say, I could not get the proper answer of my first question. What will be the query string to get all the objects from the space ?

Thanks Jitendra

jknayak gravatar imagejknayak ( 2009-08-19 16:35:59 -0500 )edit

Just to be clear - Do you need to read all MyClass objects within the space or whatever objects you got within the space? Shay

shay hassidim gravatar imageshay hassidim ( 2009-08-19 16:51:15 -0500 )edit

For my current case I have to read all the MyClass objects.

Thanks
Jitendra

jknayak gravatar imagejknayak ( 2009-08-19 17:04:51 -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: 2009-08-19 15:14:44 -0500

Seen: 105 times

Last updated: Aug 19 '09