Summary: This page describes how you can obtain partial results when querying the space to improve application performance and reduce memory footprint.
Overview
Specifying a Projection with your QueryProjection supported using a SQLQuery or Id Queries. Below a simple example reading a Person object where only the 'firstName' and 'lastName' properties are returned with the query result array. All other Person properties will not be returned: public class Person { ... @SpaceId(autoGenerate = false) public Long getId() { ... } public String getFirstName() { ... } public String getLastName() { ... } public String getAddress() { ... } ... } GigaSpace gigaSpace = //... obtain a gigaspace reference. Long id = //... obtain the space object ID. Person result = gigaSpace.read<Person>(new IdQuery<Person>(Person.class, id).setProjections("firstName", "lastName")); With the above example a specific Person is being read but only its 'firstName' and 'lastName' will contains values and all the other properties will contain a null value. You may use the same approach with the SQLQuery or IdsQuery: SQLQuery<Person> query = new SQLQuery<Person>(Person.class,""). setProjections("firstName", "lastName"); Person result[] = gigaSpace.readMultiple(query); IdsQuery<Person> idsQuery = new IdsQuery<Person>(Person.class, new Long[]{id1,id2}). setProjections("firstName", "lastName"); Person result[] = space.readByIds(idsQuery).getResultsArray(); The SpaceDocument support projections as well: SQLQuery<SpaceDocument> docQuery = new SQLQuery<SpaceDocument>(Person.class.getName() ,"", QueryResultType.DOCUMENT).setProjections("firstName", "lastName"); SpaceDocument docresult[] = gigaSpace.readMultiple(docQuery); Supported OperationsThe projection is defined for any operation that return data from the space. Therefore ID Based or Query based operations supporting projections. You can use with read,take,readById,takeById,readMultiple and takeMultiple operations. When performing a take operation with projection the entire object will be removed from the space, but the result returned to the user will contain only the projected properties.
Considerations
|
![]() |
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence |