Skip to main content

PageQuery

Struct PageQuery 

Source
pub struct PageQuery { /* private fields */ }
Expand description

What a PageSource is asked for: its rows, in an order (an ORDER BY).

Implementations§

Source§

impl PageQuery

Source

pub fn new() -> Self

The source’s rows in its own order.

Source

pub fn sorted_by(self, key: SortKey) -> Self

The query with its rows sorted by key too, after the keys it has.

Source

pub fn sort(&self) -> &[SortKey]

The keys rows are sorted by, the first first; none for the source’s own order.

Source

pub fn order_by_sql<S: AsRef<str>>(&self, keys: &[S]) -> String

The order as an SQL ORDER BY clause, for a source that pages a query with LIMIT and OFFSET: the sort keys, then the keys not among them, ascending. Give as keys the columns that tell rows apart (an id): rows that tie in every sort key then keep one order from page to page, so none shows twice or goes missing. Names are quoted as standard SQL quotes them ("time", and "a ""b""" for a column named a "b"), each once. Empty with no sort keys and no keys, which leaves the order to the engine: one that reads in parallel may change it from one page to the next.

use densa_arrow::{PageQuery, SortKey};
use densa_grid::SortOrder;

let query = PageQuery::new().sorted_by(SortKey::new("time", SortOrder::Descending));
let order = query.order_by_sql(&["id"]);
assert_eq!(order, r#"ORDER BY "time" DESC, "id""#);
let sql = format!("SELECT * FROM trips {order} LIMIT 256 OFFSET 512");

Trait Implementations§

Source§

impl Clone for PageQuery

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PageQuery

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PageQuery

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for PageQuery

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PageQuery

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.