Summary: Querying the space using a Prepared Template
OverviewOne of the space querying methods is to use an IQuery object. This can be done using the IPreparedTemplate, which implements IQuery. This query can be passed as a template to the Read, Take, ReadMultiple, TakeMultiple, Count and Clear operations, as well as a template when registering for notification. An IPreparedTemplate is an object that is constructed by the ISpaceProxy.Snapshot method, and can be used to query the space as a template. This template increases the performance of the query, because it reduces serialization overhead and instance introspection. It should be used when doing a repetetive query that uses the same template, otherwise doing a Snapshot for each template, decreases performance. UsageTo use a prepared template, it must be constructed by the ISpaceProxy.Snapshot method. Example 1 – Creating a prepared template from an objectPerson personTemplate = new Person();
personTemplate.Age = 21;
IPreparedTemplate<Person> preparedTemplate = proxy.Snapshot(personTemplate);
Example 2 – Creating a prepared template from SqlQueryA prepared template can also be created from any IQuery object, such as SqlQuery. Person personTemplate = new Person(); personTemplate.Age = 21; SqlQuery<Person> query = new SqlQuery<Person>(personTemplate, "Age >= ?"); IPreparedTemplate<Person> preparedTemplate = proxy.Snapshot(query);
After creating the prepared template, it can be passed as a template to the Read, Take, ReadMultiple, TakeMultiple, Count and Clear operations, as well as a template when registering for notification. Taking an object from the space using the prepared templatePerson person = proxy.Take(preparedTemplate); Limitations
|
![]() |
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence |