Summary: GigaSpaces.NET - SpaceIterator

Overview

The Space Iterator (ISpaceIterator) provides the ability to exhaustively read through all of the Entries of a Space that match one or more templates.

There are scenarios where the conventional read operation that returns a single entry object does not fit and there is a need to return a collection of entries from the space. Generally, an iterator should be used because returning all the Entries in one result sent back to the call would consume too many resources in the client or introduce too much latency before the first Entry could be processed. The iterator constructs a match set (a collection of Entry instances) that incrementally returns the necessary Entries. The Space Iterator constructs a proxy object that can be used to access a match set created by a space. The match set will initially contain some population of Entries specified by the operation that created it. These Entries can be retrieved by calling the next method. A successful call to next will remove the returned Entry from the match set.

Usage

Example 1 - Creating an iterator over existing and future persons

// Creating an iterator over existing and future persons
ISpaceIterator<Person> iterator = _proxy.GetSpaceIterator(new Person(), IteratorScope.ExistingAndFutureEntries);
// Iterating over persons
foreach (Person person in iterator)
{
    _logger.LogMessage("Person from iterator: " + person);
}

Example 2 - Creating an iterator over existing and future persons that match a template

Person person = new Person();
person.Age = 10;
SqlQuery<Person> template = new SqlQuery<Person>(person, "Age > ?");
ISpaceIterator<Person> iterator = testProxy.GetSpaceIterator<Person>(template, IteratorScope.ExistingAndFutureEntries);
foreach (Person person in iterator)
{   
    _logger.LogMessage("Person from iterator. Age: " + person.Age); 
}
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence