All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.geode.cache.query.SelectResults Maven / Gradle / Ivy

Go to download

Apache Geode provides a database-like consistency model, reliable transaction processing and a shared-nothing architecture to maintain very low latency performance with high concurrency processing

There is a newer version: 1.15.1
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
 * agreements. See the NOTICE file distributed with this work for additional information regarding
 * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the License. You may obtain a
 * copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package org.apache.geode.cache.query;

import java.util.*;
import org.apache.geode.cache.query.types.*;

/**
 * Contains the results of a {@linkplain org.apache.geode.cache.query.Query#execute() executing} a
 * SELECT expression within a query. A SELECT expression results in
 * SelectResults that contain instances of {@link Struct} 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 the FROM clause.
 * 

* * Otherwise, a SELECT expression over a collection of domain objects results in * SelectResults that contain domain objects, i.e. instances of domain classes such as * {@link String} or Address. *

* *

 * 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);
 * }
 *
 * 
* * @see org.apache.geode.cache.query.Query#execute() * * @since GemFire 4.0 */ public interface SelectResults extends Collection { /** * Return whether this collection is modifiable. The result of this method has no bearing on * whether the elements in the collection themselves are modifiable. * * @return true if this collection is modifiable, false if not. */ public boolean isModifiable(); /** * Return the number of times element occurs in this collection, that is the number of duplicates * element has in this collection as defined by the equals> method. If * element is not present in this collection, then 0 is returned. * * @param element the element * @return the number of occurrances of element * @since GemFire 5.1 */ public int occurrences(E element); /** * Returns this SelectResults as a java.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. * * @return Is this collection as a java.util.Set? */ public Set asSet(); /** * Returns this SelectedResults as a java.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. * * @return this collection as a java.util.List */ public List asList(); /** * Return the ObjectType for the type of collection this represents. * * @return the CollectionType for the type of collection this represents */ public CollectionType getCollectionType(); /** * 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. * * @param elementType the new elementType */ public void setElementType(ObjectType elementType); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy