Class YqlLimit

java.lang.Object
tech.ydb.yoj.repository.ydb.yql.YqlLimit
All Implemented Interfaces:
YqlStatementPart<YqlLimit>

public class YqlLimit extends Object implements YqlStatementPart<YqlLimit>
Represents a LIMIT ... [OFFSET ...] clause in a YQL statement.
Note that YDB does not support OFFSET without LIMIT, so "row offset" cannot be set directly. To return the maximum possible amount of rows, you must know the YDB ResultSet row limit (e.g., defined by YDB_KQP_RESULT_ROWS_LIMIT environment variable for local YDB-in-Docker), and use YqlLimit.range(offset, max rows + offset). If you have a specific limit < max rows, it's much better to use YqlLimit.range(offset, limit + offset), of course.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final YqlLimit
    Gives a LIMIT clause that will always return an empty range (LIMIT 0).
  • Method Summary

    Modifier and Type
    Method
    Description
    static YqlLimit
     
    int
     
     
     
    boolean
     
    static YqlLimit
    range(long from, long to)
    Creates a limit clause to fetch rows in the half-open range [from, to).
    long
    Deprecated, for removal: This API element is subject to removal in a future version.
    Please calculate the maximum number of rows fetched by this LIMIT clause by using YqlLimit.getLimit() and YqlLimit.getOffset() instead.
    static YqlLimit
    top(long n)
    Creates a limit clause to fetch top n rows, as if by calling range(0, n).
     
    <T extends tech.ydb.yoj.repository.db.Entity<T>>
    String
    toYql(@NonNull tech.ydb.yoj.repository.db.EntitySchema<T> schema)
     

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface tech.ydb.yoj.repository.ydb.yql.YqlStatementPart

    combine, toFullYql
  • Field Details

    • EMPTY

      public static final YqlLimit EMPTY
      Gives a LIMIT clause that will always return an empty range (LIMIT 0).
  • Method Details

    • range

      public static YqlLimit range(long from, long to)
      Creates a limit clause to fetch rows in the half-open range [from, to).
      Parameters:
      from - first row index, counting from 0, inclusive
      to - last row index, counting from 0, exclusive. Must be >= from
      Returns:
      limit clause to fetch (to - from) rows in range [from, to)
    • top

      public static YqlLimit top(long n)
      Creates a limit clause to fetch top n rows, as if by calling range(0, n).
      Parameters:
      n - number of rows to fetch
      Returns:
      limit clause to fetch top n rows
    • empty

      public static YqlLimit empty()
      Returns:
      limit clause that fetches no rows
      See Also:
    • size

      @Deprecated(forRemoval=true) public long size()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Please calculate the maximum number of rows fetched by this LIMIT clause by using YqlLimit.getLimit() and YqlLimit.getOffset() instead.
    • isEmpty

      public boolean isEmpty()
      Returns:
      true if this YqlLimit represents an empty range (LIMIT 0); false otherwise
    • getPriority

      public int getPriority()
      Specified by:
      getPriority in interface YqlStatementPart<YqlLimit>
    • getType

      public String getType()
      Specified by:
      getType in interface YqlStatementPart<YqlLimit>
    • getYqlPrefix

      public String getYqlPrefix()
      Specified by:
      getYqlPrefix in interface YqlStatementPart<YqlLimit>
    • toYql

      public <T extends tech.ydb.yoj.repository.db.Entity<T>> String toYql(@NonNull @NonNull tech.ydb.yoj.repository.db.EntitySchema<T> schema)
      Specified by:
      toYql in interface YqlStatementPart<YqlLimit>
    • toString

      public String toString()
      Overrides:
      toString in class Object