Skip to main content

RowRange

Struct RowRange 

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

One entry of a path’s ranges attribute: which rows to read.

Built three ways, one per selector the rich YPath reference defines:

  • RowRange::rows — by row index; plain Rust ranges convert via Into, so path.range(0..100) reads as it would on a slice;
  • RowRange::keys — by key, on a sorted table;
  • RowRange::exact_key — exactly the rows whose key starts with a tuple.

A range never mixes exact with a lower or upper limit, because no constructor can express that — the reference defines them as alternatives.

Implementations§

Source§

impl RowRange

Source

pub fn rows(rows: impl RangeBounds<i64>) -> Self

Rows by index: rows(0..100), rows(100..), rows(..).

Rust range semantics and the cluster’s are the same — lower_limit is inclusive and upper_limit exclusive for a row_index (the reference: “All limit types except for key_bound are inclusive in the lower_limit attribute and exclusive in the upper_limit attribute”) — so 0..2 means rows 0 and 1 on both sides of the wire, and ..=2 rows 0 through 2.

Source

pub fn keys(keys: impl RangeBounds<Key>) -> Self

Rows by key, on a sorted table.

Takes a Rust range of Keys, and the inclusivity travels with it:

  • keys(a..b) — from a inclusive to b exclusive. These are the spellings the key selector has natively (inclusive in lower_limit, exclusive in upper_limit), so they are sent as {key=[…]}, exactly what the Go SDK’s ypath.Key sends.
  • keys(a..=b) — inclusive upper bound. The key selector cannot say that, so it is sent as the cluster’s key_bound form, {key_bound=["<="; […]]}; an exclusive lower bound ((Bound::Excluded(a), …)) likewise becomes {key_bound=[">"; […]]}. The reference defines key_bound as [relation; prefix] with > >= allowed only in lower_limit and < <= only in upper_limit, and this constructor is what makes the wrong pairing unwritable.

A key shorter than the table’s key columns is a prefix bound — and the two selectors compare a prefix by opposite rules.

key compares the row’s whole key against the bound component-wise, the shorter tuple being smaller when equal so far. key_bound does not: the reference says the row’s key is first truncated to the bound’s length — “we need to extract a prefix of length K from that key and perform a lexicographic comparison” — after which every row sharing the prefix compares equal to the bound. So <= takes that whole group and > drops that whole group, and the practical consequence is that a..b and a..=b differ by a group of rows rather than by one row.

Measured on a local cluster, on a table keyed (host, path) holding (a,/x) (a,/y) (b,/x) (b,/y) (c,/x):

asked forsentrows back
keys(a..b){key=[a]}{key=[b]}(a,/x) (a,/y)
keys(a..=b){key=[a]}{key_bound=["<=";[b]]}(a,/x) (a,/y) (b,/x) (b,/y)
keys((Excluded(a), Unbounded)){key_bound=[">";[a]]}(b,/x) (b,/y) (c,/x)
keys(a..=a){key=[a]}{key_bound=["<=";[a]]}(a,/x) (a,/y)

The third row is the one to remember: an exclusive lower bound on a prefix excludes every row of that prefix, not the one row equal to it — there is no “the row just after a” for the cluster to start from. Give a full key if you want a single row skipped.

The second row settles the other question a mixed range raises: an entry carrying key on one side and key_bound on the other is accepted — the same local cluster answered it 200 with the rows above — so the most natural inclusive spelling needs no workaround.

Source

pub fn exact_key(key: impl Into<Key>) -> Self

Exactly the rows whose full key starts with key.

The exact selector of the reference: “only returns those rows where the full key contains the key tuple as its prefix”. On a table keyed by (host, path), exact_key(Key::from("example.com")) is every row of that host — the same rows keys(k..=k) selects, measured on a local cluster against the table in RowRange::keys, said in the cluster’s own word for it.

Trait Implementations§

Source§

impl Clone for RowRange

Source§

fn clone(&self) -> RowRange

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 RowRange

Source§

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

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

impl From<Range<i64>> for RowRange

Source§

fn from(rows: Range<i64>) -> Self

Converts to this type from the input type.
Source§

impl From<RangeFrom<i64>> for RowRange

Source§

fn from(rows: RangeFrom<i64>) -> Self

Converts to this type from the input type.
Source§

impl From<RangeFull> for RowRange

Source§

fn from(rows: RangeFull) -> Self

Converts to this type from the input type.
Source§

impl From<RangeInclusive<i64>> for RowRange

Source§

fn from(rows: RangeInclusive<i64>) -> Self

Converts to this type from the input type.
Source§

impl From<RangeTo<i64>> for RowRange

Source§

fn from(rows: RangeTo<i64>) -> Self

Converts to this type from the input type.
Source§

impl From<RangeToInclusive<i64>> for RowRange

Source§

fn from(rows: RangeToInclusive<i64>) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for RowRange

Source§

fn eq(&self, other: &RowRange) -> 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 RowRange

Auto Trait Implementations§

Blanket Implementations§

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<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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more