Sha256: f16d237ef9192abfb7844dbfb084cde4c9fb66139e3dc8e85d92284e78d395a8

Contents?: true

Size: 1.76 KB

Versions: 2

Compression:

Stored size: 1.76 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
page(suppliers, [:status, :sid], 1, 3)
.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

2 entries across 2 versions & 1 rubygems

Version Path
alf-shell-0.16.4 doc/man/page.man
alf-shell-0.16.0 doc/man/page.man