Class AqlQueryOptions

All Implemented Interfaces:
Cloneable

public final class AqlQueryOptions extends TransactionalOptions<AqlQueryOptions> implements Cloneable
Author:
Mark Vollmary, Michele Rastelli
  • Constructor Details

    • AqlQueryOptions

      public AqlQueryOptions()
  • Method Details

    • getCount

      public Boolean getCount()
    • count

      public AqlQueryOptions count(Boolean count)
      Parameters:
      count - indicates whether the number of documents in the result set should be returned in the "count" attribute of the result. Calculating the "count" attribute might have a performance impact for some queries in the future so this option is turned off by default, and "count" is only returned when requested.
      Returns:
      options
    • getTtl

      public Integer getTtl()
    • ttl

      public AqlQueryOptions ttl(Integer ttl)
      Parameters:
      ttl - The time-to-live for the cursor (in seconds). The cursor will be removed on the server automatically after the specified amount of time. This is useful to ensure garbage collection of cursors that are not fully fetched by clients. If not set, a server-defined value will be used.
      Returns:
      options
    • getBatchSize

      public Integer getBatchSize()
    • batchSize

      public AqlQueryOptions batchSize(Integer batchSize)
      Parameters:
      batchSize - maximum number of result documents to be transferred from the server to the client in one roundtrip. If this attribute is not set, a server-controlled default value will be used. A batchSize value of 0 is disallowed.
      Returns:
      options
    • getMemoryLimit

      public Long getMemoryLimit()
    • memoryLimit

      public AqlQueryOptions memoryLimit(Long memoryLimit)
      Parameters:
      memoryLimit - the maximum number of memory (measured in bytes) that the query is allowed to use. If set, then the query will fail with error "resource limit exceeded" in case it allocates too much memory. A value of 0 indicates that there is no memory limit.
      Returns:
      options
      Since:
      ArangoDB 3.1.0
    • getCache

      public Boolean getCache()
    • cache

      public AqlQueryOptions cache(Boolean cache)
      Parameters:
      cache - flag to determine whether the AQL query cache shall be used. If set to false, then any query cache lookup will be skipped for the query. If set to true, it will lead to the query cache being checked for the query if the query cache mode is either on or demand.
      Returns:
      options
    • getFillBlockCache

      public Boolean getFillBlockCache()
    • fillBlockCache

      public AqlQueryOptions fillBlockCache(Boolean fillBlockCache)
      Parameters:
      fillBlockCache - if set to true or not specified, this will make the query store the data it reads via the RocksDB storage engine in the RocksDB block cache. This is usually the desired behavior. The option can be set to false for queries that are known to either read a lot of data that would thrash the block cache, or for queries that read data known to be outside of the hot set. By setting the option to false, data read by the query will not make it into the RocksDB block cache if it is not already in there, thus leaving more room for the actual hot set.
      Returns:
      options
      Since:
      ArangoDB 3.8.1
    • getBindVars

      public Map<String,Object> getBindVars()
    • getQuery

      public String getQuery()
    • query

      public AqlQueryOptions query(String query)
      Parameters:
      query - the query which you want parse
      Returns:
      options
    • getFailOnWarning

      public Boolean getFailOnWarning()
    • failOnWarning

      public AqlQueryOptions failOnWarning(Boolean failOnWarning)
      Parameters:
      failOnWarning - When set to true, the query will throw an exception and abort instead of producing a warning. This option should be used during development to catch potential issues early. When the attribute is set to false, warnings will not be propagated to exceptions and will be returned with the query result. There is also a server configuration option --query.fail-on-warning for setting the default value for failOnWarning so it does not need to be set on a per-query level.
      Returns:
      options
    • maxRuntime

      public AqlQueryOptions maxRuntime(Double timeout)
      Parameters:
      timeout - The query has to be executed within the given runtime or it will be killed. The value is specified in seconds. The default value is 0.0 (no timeout).
      Returns:
      options
    • getProfile

      public Boolean getProfile()
      Returns:
      If set to true, then the additional query profiling information will be returned in the sub-attribute profile of the extra return attribute if the query result is not served from the query cache.
    • profile

      public AqlQueryOptions profile(Boolean profile)
      Parameters:
      profile - If set to true, then the additional query profiling information will be returned in the sub-attribute profile of the extra return attribute if the query result is not served from the query cache.
      Returns:
      options
    • getMaxTransactionSize

      public Long getMaxTransactionSize()
    • maxTransactionSize

      public AqlQueryOptions maxTransactionSize(Long maxTransactionSize)
      Parameters:
      maxTransactionSize - Transaction size limit in bytes. Honored by the RocksDB storage engine only.
      Returns:
      options
      Since:
      ArangoDB 3.2.0
    • getMaxWarningCount

      public Long getMaxWarningCount()
    • maxWarningCount

      public AqlQueryOptions maxWarningCount(Long maxWarningCount)
      Parameters:
      maxWarningCount - Limits the maximum number of warnings a query will return. The number of warnings a query will return is limited to 10 by default, but that number can be increased or decreased by setting this attribute.
      Returns:
      options
      Since:
      ArangoDB 3.2.0
    • getIntermediateCommitCount

      public Long getIntermediateCommitCount()
    • intermediateCommitCount

      public AqlQueryOptions intermediateCommitCount(Long intermediateCommitCount)
      Parameters:
      intermediateCommitCount - Maximum number of operations after which an intermediate commit is performed automatically. Honored by the RocksDB storage engine only.
      Returns:
      options
      Since:
      ArangoDB 3.2.0
    • getIntermediateCommitSize

      public Long getIntermediateCommitSize()
    • intermediateCommitSize

      public AqlQueryOptions intermediateCommitSize(Long intermediateCommitSize)
      Parameters:
      intermediateCommitSize - Maximum total size of operations after which an intermediate commit is performed automatically. Honored by the RocksDB storage engine only.
      Returns:
      options
      Since:
      ArangoDB 3.2.0
    • getSatelliteSyncWait

      public Double getSatelliteSyncWait()
    • satelliteSyncWait

      public AqlQueryOptions satelliteSyncWait(Double satelliteSyncWait)
      Parameters:
      satelliteSyncWait - This enterprise parameter allows to configure how long a DBServer will have time to bring the satellite collections involved in the query into sync. The default value is 60.0 (seconds). When the max time has been reached the query will be stopped.
      Returns:
      options
      Since:
      ArangoDB 3.2.0
    • getSkipInaccessibleCollections

      public Boolean getSkipInaccessibleCollections()
    • skipInaccessibleCollections

      public AqlQueryOptions skipInaccessibleCollections(Boolean skipInaccessibleCollections)
      Parameters:
      skipInaccessibleCollections - AQL queries (especially graph traversals) will treat collection to which a user has no access rights as if these collections were empty. Instead of returning a forbidden access error, your queries will execute normally. This is intended to help with certain use-cases: A graph contains several collections and different users execute AQL queries on that graph. You can now naturally limit the accessible results by changing the access rights of users on collections. This feature is only available in the Enterprise Edition.
      Returns:
      options
      Since:
      ArangoDB 3.2.0
    • getFullCount

      public Boolean getFullCount()
    • fullCount

      public AqlQueryOptions fullCount(Boolean fullCount)
      Parameters:
      fullCount - if set to true and the query contains a LIMIT clause, then the result will have an extra attribute with the sub-attributes stats and fullCount, { ... , "extra": { "stats": { "fullCount": 123 } } }. The fullCount attribute will contain the number of documents in the result before the last LIMIT in the query was applied. It can be used to count the number of documents that match certain filter criteria, but only return a subset of them, in one go. It is thus similar to MySQL's SQL_CALC_FOUND_ROWS hint. Note that setting the option will disable a few LIMIT optimizations and may lead to more documents being processed, and thus make queries run longer. Note that the fullCount attribute will only be present in the result if the query has a LIMIT clause and the LIMIT clause is actually used in the query.
      Returns:
      options
    • getMaxPlans

      public Integer getMaxPlans()
    • maxPlans

      public AqlQueryOptions maxPlans(Integer maxPlans)
      Parameters:
      maxPlans - Limits the maximum number of plans that are created by the AQL query optimizer.
      Returns:
      options
    • getRules

      public Collection<String> getRules()
    • rules

      public AqlQueryOptions rules(Collection<String> rules)
      Parameters:
      rules - A list of to-be-included or to-be-excluded optimizer rules can be put into this attribute, telling the optimizer to include or exclude specific rules. To disable a rule, prefix its name with a -, to enable a rule, prefix it with a +. There is also a pseudo-rule all, which will match all optimizer rules
      Returns:
      options
    • getStream

      public Boolean getStream()
    • stream

      public AqlQueryOptions stream(Boolean stream)
      Parameters:
      stream - Specify true and the query will be executed in a streaming fashion. The query result is not stored on the server, but calculated on the fly. Beware: long-running queries will need to hold the collection locks for as long as the query cursor exists. When set to false a query will be executed right away in its entirety. In that case query results are either returned right away (if the resultset is small enough), or stored on the arangod instance and accessible via the cursor API (with respect to the ttl). It is advisable to only use this option on short-running queries or without exclusive locks (write-locks on MMFiles). Please note that the query options cache, count and fullCount will not work on streaming queries. Additionally query statistics, warnings and profiling data will only be available after the query is finished. The default value is false
      Returns:
      options
      Since:
      ArangoDB 3.4.0
    • getShardIds

      public Collection<String> getShardIds()
    • shardIds

      public AqlQueryOptions shardIds(String... shardIds)
      Restrict query to shards by given ids. This is an internal option. Use at your own risk.
      Parameters:
      shardIds -
      Returns:
      options
    • getForceOneShardAttributeValue

      public String getForceOneShardAttributeValue()
    • forceOneShardAttributeValue

      public AqlQueryOptions forceOneShardAttributeValue(String forceOneShardAttributeValue)
      Parameters:
      forceOneShardAttributeValue - This query option can be used in complex queries in case the query optimizer cannot automatically detect that the query can be limited to only a single server (e.g. in a disjoint smart graph case).

      If the option is set incorrectly, i.e. to a wrong shard key value, then the query may be shipped to a wrong DB server and may not return results (i.e. empty result set).

      Use at your own risk.

      Returns:
      options
    • getOptions

      public AqlQueryOptions.Options getOptions()
    • allowDirtyRead

      public AqlQueryOptions allowDirtyRead(Boolean allowDirtyRead)
      Parameters:
      allowDirtyRead - Set to true allows reading from followers in an active-failover setup.
      Returns:
      options
      Since:
      ArangoDB 3.4.0
      See Also:
    • getAllowDirtyRead

      public Boolean getAllowDirtyRead()
    • getAllowRetry

      public Boolean getAllowRetry()
    • allowRetry

      public AqlQueryOptions allowRetry(Boolean allowRetry)
      Parameters:
      allowRetry - Set this option to true to make it possible to retry fetching the latest batch from a cursor.

      This makes possible to safely retry invoking ArangoCursor.next() in case of I/O exceptions (which are actually thrown as ArangoDBException with cause IOException)

      If set to false (default), then it is not safe to retry invoking ArangoCursor.next() in case of I/O exceptions, since the request to fetch the next batch is not idempotent (i.e. the cursor may advance multiple times on the server).

      Note: once you successfully received the last batch, you should call Closeable.close() so that the server does not unnecessary keep the batch until the cursor times out (ttl(Integer)).

      Returns:
      options
      Since:
      ArangoDB 3.11
    • clone

      public AqlQueryOptions clone()
      Overrides:
      clone in class Object