Gemfire JavaDocs_test
Package org.apache.geode.cache.query
Interface SelectResults<E>
-
- All Superinterfaces:
java.util.Collection<E>
,java.lang.Iterable<E>
- All Known Subinterfaces:
CqResults<E>
public interface SelectResults<E> extends java.util.Collection<E>
Contains the results of a executing aSELECT
expression within a query. ASELECT
expression results inSelectResults
that contain instances ofStruct
if: (a) there is more than one projection in the projection attributes, or (b) if the projection is*
and there is more than one collection specified in theFROM
clause.Otherwise, a
SELECT
expression over a collection of domain objects results inSelectResults
that contain domain objects, i.e. instances of domain classes such asString
orAddress
.QueryService qs = cacheView.getQueryService(); String select = "SELECT DISTINCT * FROM /root/employees " + "WHERE salary > 50000"; Query query = qs.newQuery(select); SelectResults results = query.execute(); for (Iterator iter = results.iterator(); iter.hasNext();) { Employee emp = (Employee) iter.next(); System.out.println("Highly compensated: " + emp); } select = "SELECT DISTINCT age, address.zipCode FROM /root/employees " + "WHERE salary > 50000"; query = qs.newQuery(select); results = query.execute(); for (Iterator iter = results.iterator(); iter.hasNext();) { Struct struct = (Struct) iter.next(); int age = ((Integer) struct.get("age")).intValue(); String zipCode = (String) struct.get("zipCode"); System.out.println(age + " -> " + zipCode); }
- Since:
- GemFire 4.0
- See Also:
Query.execute()
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.List<E>
asList()
Returns thisSelectedResults
as ajava.util.List
.java.util.Set<E>
asSet()
Returns thisSelectResults
as ajava.util.Set
.CollectionType
getCollectionType()
Return the ObjectType for the type of collection this represents.boolean
isModifiable()
Return whether this collection is modifiable.int
occurrences(E element)
Return the number of times element occurs in this collection, that is the number of duplicateselement
has in this collection as defined by theequals
method.void
setElementType(ObjectType elementType)
Specify a new elementType, overriding any existing known elementType.
-
-
-
Method Detail
-
isModifiable
boolean isModifiable()
Return whether this collection is modifiable. The result of this method has no bearing on whether the elements in the collection themselves are modifiable.- Returns:
- true if this collection is modifiable, false if not.
-
occurrences
int occurrences(E element)
Return the number of times element occurs in this collection, that is the number of duplicateselement
has in this collection as defined by theequals
method. Ifelement
is not present in this collection, then 0 is returned.- Parameters:
element
- the element- Returns:
- the number of occurrences of element
- Since:
- GemFire 5.1
-
asSet
java.util.Set<E> asSet()
Returns thisSelectResults
as ajava.util.Set
. If this collection is distinct and unordered, then no copying is necessary. Otherwise, the contents of this collection will be copied into a new instance of java.util.HashSet.- Returns:
- Is this collection as a
java.util.Set
?
-
asList
java.util.List<E> asList()
Returns thisSelectedResults
as ajava.util.List
. If this collection is ordered, then no copying is necessary. Otherwise, the contents of this collection will be copied into a new instance of java.util.ArrayList.- Returns:
- this collection as a java.util.List
-
getCollectionType
CollectionType getCollectionType()
Return the ObjectType for the type of collection this represents.- Returns:
- the CollectionType for the type of collection this represents
-
setElementType
void setElementType(ObjectType elementType)
Specify a new elementType, overriding any existing known elementType. This modifies the CollectionType for this object to be the same collection type but with the newly specified element type.- Parameters:
elementType
- the new elementType
-
-