Package org.postgresql.core.v3.adaptivefetch

# Class AdaptiveFetchCache

java.lang.Object
org.postgresql.core.v3.adaptivefetch.AdaptiveFetchCache

public class AdaptiveFetchCache extends Object
The main purpose of this class is to handle adaptive fetching process. Adaptive fetching is used to compute fetch size to fully use size defined by maxResultBuffer. Computing is made by dividing maxResultBuffer size by max row result size noticed so far. Each query have separate adaptive fetch size computed, but same queries have it shared. If adaptive fetch is turned on, first fetch is going to be made with defaultRowFetchSize, next fetching of resultSet will be made with computed adaptive fetch size. If adaptive fetch is turned on during fetching, then first fetching made by ResultSet will be made with defaultRowFetchSize, next will use computed adaptive fetch size. Property adaptiveFetch need properties defaultRowFetchSize and maxResultBuffer to work.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AdaptiveFetchCache(long maximumResultBufferSize, Properties info)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addNewQuery(boolean adaptiveFetch, Query query)`
  Add query to being cached and computing adaptive fetch size.
  `boolean`
  `getAdaptiveFetch()`
  Get state of adaptive fetch.
  `int`
  `getFetchSizeForQuery(boolean adaptiveFetch, Query query)`
  Get adaptive fetch size for given query.
  `void`
  `removeQuery(boolean adaptiveFetch, Query query)`
  Remove query information from caching.
  `void`
  `setAdaptiveFetch(boolean adaptiveFetch)`
  Set state of adaptive fetch.
  `void`
  `updateQueryFetchSize(boolean adaptiveFetch, Query query, int maximumRowSizeBytes)`
  Update adaptive fetch size for given query.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### AdaptiveFetchCache

    public AdaptiveFetchCache(long maximumResultBufferSize, Properties info) throws SQLException
    Throws:
      `SQLException`

- ## Method Details

  - ### addNewQuery

    public void addNewQuery(boolean adaptiveFetch, Query query)
    Add query to being cached and computing adaptive fetch size.
    Parameters:
      `adaptiveFetch` - state of adaptive fetch, which should be used during adding query
      `query` - query to be cached

  - ### updateQueryFetchSize

    public void updateQueryFetchSize(boolean adaptiveFetch, Query query, int maximumRowSizeBytes)
    Update adaptive fetch size for given query.
    Parameters:
      `adaptiveFetch` - state of adaptive fetch, which should be used during updating fetch size for query
      `query` - query to be updated
      `maximumRowSizeBytes` - max row size used during updating information about adaptive fetch size for given query

  - ### getFetchSizeForQuery

    public int getFetchSizeForQuery(boolean adaptiveFetch, Query query)
    Get adaptive fetch size for given query.
    Parameters:
      `adaptiveFetch` - state of adaptive fetch, which should be used during getting fetch size for query
      `query` - query to which we want get adaptive fetch size
    Returns:
      adaptive fetch size for query or -1 if size doesn't exist/adaptive fetch state is false

  - ### removeQuery

    public void removeQuery(boolean adaptiveFetch, Query query)
    Remove query information from caching.
    Parameters:
      `adaptiveFetch` - state of adaptive fetch, which should be used during removing fetch size for query
      `query` - query to be removed from caching

  - ### getAdaptiveFetch

    public boolean getAdaptiveFetch()
    Get state of adaptive fetch.
    Returns:
      state of adaptive fetch

  - ### setAdaptiveFetch

    public void setAdaptiveFetch(boolean adaptiveFetch)
    Set state of adaptive fetch.
    Parameters:
      `adaptiveFetch` - desired state of adaptive fetch