Skip to main content

IndexBlock

Struct IndexBlock 

Source
pub struct IndexBlock<T> { /* private fields */ }
Expand description

IndexVec allows to store h3index in compressed form.

The main purpose of this is to allow having seldom used data in memory without it occupying too much space. This sacrifices a bit of speed when accessing the data.

The order if the h3indexes in the block is not changed, so - for example - continuous paths of h3 edges can be stored without them becoming shuffled.

The compression is done using run-length-encoding (RLE). To improve the compression ratio the bytes of all contained h3indexes are grouped by their position in the u64 of the h3index. For spatially close h3index this results in a quite good compression ratio as many bytes are common over many h3indexes. As an example: a k-ring with k=50 and 7651 cells compresses from 61kb to around 7.6kb.

Implementations§

Source§

impl<T> IndexBlock<T>
where T: Index,

Source

pub const fn len(&self) -> usize

Source

pub const fn is_empty(&self) -> bool

Source

pub fn contains(&self, index: &T) -> Result<bool, Error>

check if index is contained in this IndexBlock.

This method avoids decompressing the whole block at once and instead only decompresses single bytes while traversing the contained indexes.

Source

pub const fn size_of_uncompressed(&self) -> usize

The size of the inner data when it would be stored in a simple Vec

Source

pub const fn size_of_compressed(&self) -> usize

Source

pub fn iter_uncompressed(&self) -> Result<OwningDecompressedIter<'_, T>, Error>

returns an iterator over the decompressed decompressed contents of the IndexBlock.

Useful for situations where only one or few decompressions are done. When many blocks are decompressed using the Decompressor is more efficient as the decompression buffer needs to be allocated only once.

Trait Implementations§

Source§

impl<T: Clone> Clone for IndexBlock<T>

Source§

fn clone(&self) -> IndexBlock<T>

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<T: Debug> Debug for IndexBlock<T>

Source§

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

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

impl<'de, T> Deserialize<'de> for IndexBlock<T>
where T: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: Eq> Eq for IndexBlock<T>

Source§

impl<T> From<&[T]> for IndexBlock<T>
where T: Index,

Source§

fn from(index_slice: &[T]) -> Self

Converts to this type from the input type.
Source§

impl<T> From<IndexVec<T>> for IndexBlock<T>
where T: Index + Copy,

Source§

fn from(ivc: IndexVec<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Vec<T>> for IndexBlock<T>
where T: Index,

Source§

fn from(vc: Vec<T>) -> Self

Converts to this type from the input type.
Source§

impl<T, B> FromIterator<B> for IndexBlock<T>
where B: Borrow<T>, T: Index + Copy,

Source§

fn from_iter<I: IntoIterator<Item = B>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T: PartialEq> PartialEq for IndexBlock<T>

Source§

fn eq(&self, other: &IndexBlock<T>) -> bool

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

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

Inequality operator !=. Read more
Source§

impl<T> Serialize for IndexBlock<T>
where T: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: PartialEq> StructuralPartialEq for IndexBlock<T>

Auto Trait Implementations§

§

impl<T> Freeze for IndexBlock<T>
where PhantomData<T>: Freeze,

§

impl<T> RefUnwindSafe for IndexBlock<T>

§

impl<T> Send for IndexBlock<T>
where PhantomData<T>: Send,

§

impl<T> Sync for IndexBlock<T>
where PhantomData<T>: Sync,

§

impl<T> Unpin for IndexBlock<T>
where PhantomData<T>: Unpin,

§

impl<T> UnsafeUnpin for IndexBlock<T>

§

impl<T> UnwindSafe for IndexBlock<T>

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<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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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, <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<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool