IntegerDataRange

Struct IntegerDataRange 

Source
pub struct IntegerDataRange {
    pub low: i64,
    pub high: i64,
    pub bits_required: usize,
}
Expand description

Holds the observed range of values seen in a set of points whose coordinates are 32-bit integers (signed or unsigned).

From this information we can determine how to translate the coordinates so that their normalized range has a low of zero. This permits us to use the fewest number of bits to represent them when constructing a Hilbert index.

  • Use the normalize method to adjust a coordinate value into range such that the full precision of the number is preserved.
  • Use the compress method to both normalize and shrink the coordinate value, to reduce the number of bits used per coordinate, at the expense of less precision.

Motivation.

  1. The Hilbert Curve transformation requires non-negative numbers, so all values must be translated until the lowest is zero. That means that if the lowest value is negative, we shift to the positive direction, or contrariwise to the negative direction.
  2. The execution time of the Hilbert transformation is directly proportional to the number of bits used to represent each value. Thus if we can sacrifice some precision, each value can be right-shifted by the same number of bits if we wish to compress the range.

Fields§

§low: i64

Lowest value of any coordinate of any point in a collection of points.

§high: i64

Highest value of any coordinate of any point in a collection of points.

§bits_required: usize

Minimum number of bits required to represent a normalized value without loss of information.

Examples:

  • If low is -10 and high is 24 then the range is 34 so 6 bits are required to represent all values in that range.
  • If low is 50 and high is 67 then the range is 17 so 5 bits are required to represent all values in that range.

Implementations§

Source§

impl IntegerDataRange

Source

pub fn new<I>(low_i: I, high_i: I) -> Self
where I: Into<i64>,

Create an IntegerDataRange without reference to particular data.

Source

pub fn from_i32<I>(points: &[I]) -> Self
where for<'a> &'a I: IntoIterator<Item = &'a i32>,

Study all i32 coordinates in all points to find the minimum and maximum values.

Source

pub fn from_u32<I>(points: &[I]) -> Self
where for<'a> &'a I: IntoIterator<Item = &'a u32>,

Study all u32 coordinates in all points to find the minimum and maximum values.

Source

pub fn range(&self) -> u32

Range from low to high value.

Source

pub fn normalize<I>(&self, coordinate: I) -> u32
where I: Into<i64>,

Normalize an integer convertible to an i64, shifting it enough so that the minimum value found in any point is shifted to zero and the maximum value is shifted to range, and using the full number of bits required for the range.

Source

pub fn compress<I>(&self, coordinate: I, bits_allocated: usize) -> u32
where I: Into<i64>,

Normalize a coordinate value, shifting it enough so that the minimum value found in any point is shifted to zero and the maximum value is shifted to range, then optionally compressing the range by bit shifting such that no more than the given number of bits are required for the largest value.

Trait Implementations§

Source§

impl Clone for IntegerDataRange

Source§

fn clone(&self) -> IntegerDataRange

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for IntegerDataRange

Source§

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

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

impl PartialEq for IntegerDataRange

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for IntegerDataRange

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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V