Class ExecuteProperties

java.lang.Object
com.apple.foundationdb.record.ExecuteProperties

@API(UNSTABLE) public class ExecuteProperties extends Object
Limits on the execution of a query.
  • number of records to skip
  • limit on number of records returned
  • time limit for execution
  • limit on number of key-value pairs scanned
  • Field Details

    • UNLIMITED_TIME

      public static final long UNLIMITED_TIME
      A constant representing that no time limit is set.
      See Also:
    • SERIAL_EXECUTE

      public static final ExecuteProperties SERIAL_EXECUTE
      A basic set of properties for an unlimited query/scan execution with serializable isolation.
    • isolationLevel

      @Nonnull protected final IsolationLevel isolationLevel
    • skip

      protected final int skip
    • rowLimit

      protected final int rowLimit
  • Method Details

    • getIsolationLevel

      @Nonnull public IsolationLevel getIsolationLevel()
    • getSkip

      public int getSkip()
    • setSkip

      @Nonnull public ExecuteProperties setSkip(int skip)
    • isDryRun

      public boolean isDryRun()
    • setDryRun

      @Nonnull public ExecuteProperties setDryRun(boolean isDryRun)
    • getReturnedRowLimit

      public int getReturnedRowLimit()
      Get the limit on the number of rows that will be returned as it would be passed to FDB.
      Returns:
      the limit or ReadTransaction.ROW_LIMIT_UNLIMITED if there is no limit.
    • setReturnedRowLimit

      @Nonnull public ExecuteProperties setReturnedRowLimit(int rowLimit)
      Set the limit on the number of rows that will be returned.
      Parameters:
      rowLimit - the limit or ReadTransaction.ROW_LIMIT_UNLIMITED or Integer.MAX_VALUE for no limit
      Returns:
      a new ExecuteProperties with the given limit
    • getTimeLimit

      public long getTimeLimit()
      Get the time limit for query execution. This will return UNLIMITED_TIME if there is no time-limit imposed on a query.
      Returns:
      the maximum time for query execution
    • getScannedRecordsLimit

      public int getScannedRecordsLimit()
      Get the maximum number of records a query with this execute properties will scan. This will return Integer.MAX_VALUE if there is no limit to the number of records scanned by a query.
      Returns:
      the maximum number of records a query will scan
    • getScannedBytesLimit

      public long getScannedBytesLimit()
      Get the maximum number of bytes a query with this execute properties will scan. This will return Long.MAX_VALUE if there is no limit to the number of bytes scanned by a query.
      Returns:
      the maximum number of bytes a query will scan
    • getState

      @Nonnull public ExecuteState getState()
    • setState

      @Nonnull public ExecuteProperties setState(@Nonnull ExecuteState newState)
      Build a new ExecuteProperties with the given ExecuteState.
      Parameters:
      newState - the new state
      Returns:
      a new properties object with the new state
    • clearState

      @Nonnull public ExecuteProperties clearState()
      Build a new ExecuteProperties with an empty state.
      Returns:
      a new properties object with an empty state
    • isFailOnScanLimitReached

      public boolean isFailOnScanLimitReached()
      Get whether reaching the scan limit throws an exception.
      Returns:
      true if the scan limit throws an exception when reached, false if the scan returns early with RecordCursor.NoNextReason.SCAN_LIMIT_REACHED
    • setFailOnScanLimitReached

      public ExecuteProperties setFailOnScanLimitReached(boolean failOnScanLimitReached)
    • clearReturnedRowLimit

      @Nonnull public ExecuteProperties clearReturnedRowLimit()
    • clearRowAndTimeLimits

      @Nonnull public ExecuteProperties clearRowAndTimeLimits()
      Clear the returned row limit and time limit. Does not clear the skip.
      Returns:
      a new ExecuteProperties without the returned row and time limits
    • clearSkipAndLimit

      @Nonnull public ExecuteProperties clearSkipAndLimit()
      Clear the skip and returned row limit, but no other limits.
      Returns:
      a new ExecuteProperties without the skip and returned row limit
    • clearSkipAndAdjustLimit

      @Nonnull public ExecuteProperties clearSkipAndAdjustLimit()
      Remove any skip count and adjust the limit to include enough rows that we can skip those and then apply the current limit.
      Returns:
      a new properties without skip and with an adjusted limit
    • getReturnedRowLimitOrMax

      public int getReturnedRowLimitOrMax()
      Get the limit on the number of rows that will be returned as could be used for counting.
      Returns:
      the limit or Integer.MAX_VALUE if there is no limit.
    • setLimitsFrom

      @Nonnull public ExecuteProperties setLimitsFrom(@Nonnull ExecuteProperties other)
      Merge these limits with the ones specified in other, using the limit specified by other except where it is unlimited, in which case the limit from this ExecuteProperties is used instead.
      Parameters:
      other - the ExecuteProperties to the take the limits from
      Returns:
      an ExecuteProperties with limits merged as described above
    • getDefaultCursorStreamingMode

      public CursorStreamingMode getDefaultCursorStreamingMode()
      Get the default CursorStreamingMode for new ScanProperties.
      Returns:
      the default streaming mode
    • setDefaultCursorStreamingMode

      public ExecuteProperties setDefaultCursorStreamingMode(CursorStreamingMode defaultCursorStreamingMode)
      Set the default CursorStreamingMode for new ScanProperties.
      Parameters:
      defaultCursorStreamingMode - default streaming mode
      Returns:
      a new ExecuteProperties with the given default streaming mode
    • resetState

      @Nonnull public ExecuteProperties resetState()
      Reset the stateful parts of the properties to their "original" values, creating an independent mutable state.
      Returns:
      an ExecuteProperties with an independent mutable state
      See Also:
    • copy

      @Nonnull protected ExecuteProperties copy(int skip, int rowLimit, long timeLimit, @Nonnull IsolationLevel isolationLevel, @Nonnull ExecuteState state, boolean failOnScanLimitReached, CursorStreamingMode defaultCursorStreamingMode, boolean isDryRun)
      Create a new instance with these fields, copying any additional fields from subclasses.
      Parameters:
      skip - skip count
      rowLimit - returned row limit
      timeLimit - time limit
      isolationLevel - isolation level
      state - execute state
      failOnScanLimitReached - fail on scan limit reached
      defaultCursorStreamingMode - default streaming mode
      isDryRun - whether it is dry run
      Returns:
      a new properties with the given fields changed and other fields copied from this properties
    • asScanProperties

      @Nonnull public ScanProperties asScanProperties(boolean reverse)
    • newBuilder

      @Nonnull public static ExecuteProperties.Builder newBuilder()
    • toBuilder

      @Nonnull public ExecuteProperties.Builder toBuilder()
    • toString

      @Nonnull public String toString()
      Overrides:
      toString in class Object