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

org.infinispan.commons.api.query.Query Maven / Gradle / Ivy

There is a newer version: 15.1.0.Dev03
Show newest version
package org.infinispan.commons.api.query;

import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import org.infinispan.commons.util.CloseableIterator;

/**
 * @since 15.0
 */
public interface Query extends Iterable {

   /**
    * Returns the Ickle query string.
    */
   String getQueryString();

   /**
    * Returns the results of a search as a list.
    *
    * @return a list of objects that were found in the search.
    */
   List list();

   /**
    *  Executes the query (a SELECT statement). Subsequent invocations cause the query to be re-executed.
    *  

* Executing a DELETE is also allowed. In this case, no results will be returned, but the number of affected entries * will be returned as the hit count in the {@link QueryResult}. * * @return {@link QueryResult} with the results. */ QueryResult execute(); /** * Executes a data modifying statement (typically a DELETE) that does not return results; instead it returns the * count of affected entries. This method cannot be used to execute a SELECT. *

* NOTE: Paging parameters (firstResult/maxResults) are NOT allowed. * * @return the number of affected (deleted) entries */ int executeStatement(); /** * Indicates if the parsed query has projections (a SELECT clause) and consequently, the returned results will * actually be {@code Object[]} containing the projected values rather than the target entity. * * @return {@code true} if it has projections, {@code false} otherwise. */ boolean hasProjections(); long getStartOffset(); Query startOffset(long startOffset); int getMaxResults(); Query maxResults(int maxResults); /** * @return the current hitCountAccuracy if present * @see #hitCountAccuracy(int) */ Integer hitCountAccuracy(); /** * Limits the required accuracy of the hit count for the indexed queries to an upper-bound. * Setting the hit-count-accuracy could improve the performance of queries targeting large data sets. * * @param hitCountAccuracy The value to apply * @return this, for method chaining */ Query hitCountAccuracy(int hitCountAccuracy); /** * Returns the named parameters Map. * * @return the named parameters (unmodifiable) or {@code null} if the query does not have parameters */ Map getParameters(); /** * Sets the value of a named parameter. * * @param paramName the parameters name (non-empty and not null) * @param paramValue a non-null value * @return itself */ Query setParameter(String paramName, Object paramValue); /** * Sets multiple named parameters at once. Parameter names cannot be empty or {@code null}. Parameter values must * not be {@code null}. * * @param paramValues a Map of parameters * @return itself */ Query setParameters(Map paramValues); /** * Returns a {@link CloseableIterator} over the results. Close the iterator when you are done with processing * the results. * * @return the results of the query as an iterator. */ @Override CloseableIterator iterator(); /** * Returns a {@link CloseableIterator} over the results, including both key and value. Close the iterator when * you are done with processing the results. The query cannot use projections. * * @return the results of the query as an iterator. */ CloseableIterator> entryIterator(); /** * Set the timeout for this query. If the query hasn't finished processing before the timeout, * a timeout will be thrown. For queries that use the index, the timeout * is handled on a best effort basis, and the supplied time is rounded to the nearest millisecond. */ Query timeout(long timeout, TimeUnit timeUnit); /** * Set the query execution scope * * @param local if true, query will be restricted to the data present in the local node, ignoring the other * members of the clusters */ Query local(boolean local); Query scoreRequired(boolean scoreRequired); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy