Sha256: 6e7f1cdc809ba90773941ba19b1c2c370ea5285b6e01e794884dfbf4d885cb34

Contents?: true

Size: 1.72 KB

Versions: 1

Compression:

Stored size: 1.72 KB

Contents

.TH Page
.PP
Pagination
.SH Signature
.PP
.RS
.nf
page(operand: Relation, ordering: Ordering, nth: Integer) -> Relation
.fi
.RE
.SH Examples
.PP
.RS
.nf
page(suppliers, [:status, :sid], 1, page_size: 3)
.fi
.RE
.PP
.RS
.nf
page(suppliers, [:status, :sid], -1, page_size: 3)
.fi
.RE
.SH Description
.PP
Computes a relation by restricting the tuples of \fB\fCoperand\fR to those
belonging to the \fB\fCnth\fR page (starting at 1). When \fB\fCnth\fR is negative, returns
tuples that belong to the \fB\fCnth\fR page from the end (e.g., \-1 is last page).
.PP
Formally, the page is defined by those tuples whose ranking according to
\fB\fCorder\fR is such that \fB\fC(nth-1)*page_size <= rank < nth*page_size\fR\&. In other
words, this operator is almost equivalent to the following definition
(ignoring negative page indexes for simplicity):
.PP
.RS
.nf
def page(operand, order, nth, page_size)
  allbut(
    restrict(
      rank(operand, order, :rank),
      lte((nth-1)*page_size, :rank) & lt(:rank, nth*page_size)),
    [:rank])
end
.fi
.RE
.PP
As of current Alf version, for this operator to be semantically sound and
deterministic, \fB\fCorder\fR MUST be a total order, that is, it must at least
cover a candidate key. As of current Alf version, no error is raised if
this is not the case but that might change in future versions.
.SH Implementation notes
.PP
Contrary to the longer expression shown above, this operator compiles to
SQL (rank does not, so far) at the cost of having to provide a total
order.
.PP
As the result is a relation and relations are not ordered by definition,
the order in which tuples can be observed in the result (e.g. through
explicit tuple iteration, casting to an array, json encoding) is NOT
guaranteed to follow \fB\fCorder\fR\&.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-shell-0.15.0 doc/man/page.man