Class BaseQuery<T>

java.lang.Object
org.infinispan.query.dsl.impl.BaseQuery<T>
All Implemented Interfaces:
Iterable<T>, PaginationContext<Query<T>>, ParameterContext<Query<T>>, Query<T>

public abstract class BaseQuery<T> extends Object implements Query<T>
Since:
7.2
Author:
anistor@redhat.com
  • Field Details

    • queryFactory

      protected final QueryFactory queryFactory
    • queryString

      protected final String queryString
    • namedParameters

      protected Map<String,Object> namedParameters
    • projection

      protected final String[] projection
    • startOffset

      protected int startOffset
    • maxResults

      protected int maxResults
    • hitCountAccuracy

      protected Integer hitCountAccuracy
    • local

      protected boolean local
    • timeout

      protected long timeout
      Optional timeout in nanoseconds.
  • Constructor Details

  • Method Details

    • getQueryString

      public String getQueryString()
      Returns the Ickle query string.
      Specified by:
      getQueryString in interface Query<T>
      Returns:
      the Ickle query string
    • getParameters

      public Map<String,Object> getParameters()
      Description copied from interface: Query
      Returns the named parameters Map.
      Specified by:
      getParameters in interface ParameterContext<T>
      Specified by:
      getParameters in interface Query<T>
      Returns:
      the named parameters (unmodifiable) or null if the query does not have parameters
    • setParameter

      public Query<T> setParameter(String paramName, Object paramValue)
      Description copied from interface: Query
      Sets the value of a named parameter.
      Specified by:
      setParameter in interface ParameterContext<T>
      Specified by:
      setParameter in interface Query<T>
      Parameters:
      paramName - the parameters name (non-empty and not null)
      paramValue - a non-null value
      Returns:
      itself
    • setParameters

      public Query<T> setParameters(Map<String,Object> paramValues)
      Description copied from interface: Query
      Sets multiple named parameters at once. Parameters names cannot be empty or null. Parameter values must not be null.
      Specified by:
      setParameters in interface ParameterContext<T>
      Specified by:
      setParameters in interface Query<T>
      Parameters:
      paramValues - a Map of parameters
      Returns:
      itself
    • resetQuery

      public abstract void resetQuery()
      Reset internal state after pagination or query parameters are modified. This is needed to ensure the next execution of the query uses the new values.
    • validateNamedParameters

      public void validateNamedParameters()
      Ensure all named parameters have non-null values.
    • getProjection

      public String[] getProjection()
      Specified by:
      getProjection in interface Query<T>
      Returns:
      the values for query projections or null if the query does not have projections.
    • hasProjections

      public boolean hasProjections()
      Description copied from interface: Query
      Indicates if the parsed query has projections (a SELECT clause) and consequently the returned results will actually be Object[] containing the projected values rather than the target entity.
      Specified by:
      hasProjections in interface Query<T>
      Returns:
      true if it has projections, false otherwise.
    • getStartOffset

      public long getStartOffset()
      Specified by:
      getStartOffset in interface Query<T>
    • getMaxResults

      public int getMaxResults()
      Specified by:
      getMaxResults in interface Query<T>
    • startOffset

      public Query<T> startOffset(long startOffset)
      Specified by:
      startOffset in interface PaginationContext<T>
      Specified by:
      startOffset in interface Query<T>
    • maxResults

      public Query<T> maxResults(int maxResults)
      Specified by:
      maxResults in interface PaginationContext<T>
      Specified by:
      maxResults in interface Query<T>
    • hitCountAccuracy

      public Integer hitCountAccuracy()
      Specified by:
      hitCountAccuracy in interface Query<T>
      Returns:
      current hitCountAccuracy if present
      See Also:
    • hitCountAccuracy

      public Query<T> hitCountAccuracy(int hitCountAccuracy)
      Description copied from interface: Query
      Limit 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.
      Specified by:
      hitCountAccuracy in interface Query<T>
      Parameters:
      hitCountAccuracy - The value to apply
      Returns:
      this, for method chaining
    • local

      public Query<T> local(boolean local)
      Description copied from interface: Query
      Set the query execution scope
      Specified by:
      local in interface Query<T>
      Parameters:
      local - if true, query will be restricted to the data present in the local node, ignoring the other members of the clusters
    • isLocal

      public boolean isLocal()
    • timeout

      public Query<T> timeout(long timeout, TimeUnit timeUnit)
      Description copied from interface: Query
      Set the timeout for this query. If the query hasn't finished processing before the timeout, a SearchTimeoutException 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.
      Specified by:
      timeout in interface Query<T>
    • entryIterator

      public <K> org.infinispan.commons.util.CloseableIterator<Map.Entry<K,T>> entryIterator()
      Description copied from interface: Query
      Returns a CloseableIterator over the results, including both key and value. Please close the iterator when you are done with processing the results. The query cannot use projections.
      Specified by:
      entryIterator in interface Query<T>
      Returns:
      the results of the query as an iterator.
    • executeStatement

      public int executeStatement()
      Description copied from interface: Query
      Executes a data modifying statement (typically a DELETE) that does not return results; instead it returns an affected entries count. This method cannot be used to execute a SELECT.

      NOTE: Paging params (firstResult/maxResults) are NOT allowed.

      Specified by:
      executeStatement in interface Query<T>
      Returns:
      the number of affected (deleted) entries