pub struct ChunkOffsetsBase<T>{ /* private fields */ }Expand description
A wrapper class for PQ chunk offsets.
Upon construction, this class guarantees that the underlying chunk offset plan is valid.
A valid PQ chunk offset plan records the starting offsets of each chunk such that chunk
i of a slice x can be accessed using x[offsets[i]..offsets[i+1]].
In particular, a valid PQ chunk offset plan has the following properties:
- It has a length of at least 2.
- Its first entry is 0.
- For
iin0..offsets.len(),offsets[i] < offsets[i+1].
Implementations§
Source§impl<T> ChunkOffsetsBase<T>
impl<T> ChunkOffsetsBase<T>
Sourcepub fn new(offsets: T) -> Result<Self, ChunkOffsetError>
pub fn new(offsets: T) -> Result<Self, ChunkOffsetError>
Construct a new ChunkOffset from a raw slice.
Returns an error if:
- The length of
offsetsis less than 2. - The entries in
offsetsare not strictly increasing.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Return the number of chunks associated with this mapping.
This will be one-less than the length of the provided slice.
Sourcepub fn dim(&self) -> usize
pub fn dim(&self) -> usize
Return the dimensionality of the vector data associated with this chunking schema.
Sourcepub fn dim_nonzero(&self) -> NonZeroUsize
pub fn dim_nonzero(&self) -> NonZeroUsize
Return the dimensionality of the vector data associated with this chunking schema.
By class invariant, the dimensionality must be nonzero, and this expressed in the retuen type.
This method cannot fail and will not panic.
Sourcepub fn at(&self, i: usize) -> Range<usize>
pub fn at(&self, i: usize) -> Range<usize>
Return a range containing the start and one-past-the-end indices for chunk i.
§Panics
Panics if i >= self.len().
Sourcepub fn as_view(&self) -> ChunkOffsetsView<'_>
pub fn as_view(&self) -> ChunkOffsetsView<'_>
Return self as a view.
Sourcepub fn to_owned(&self) -> ChunkOffsets
pub fn to_owned(&self) -> ChunkOffsets
Return a 'static copy of self.
Trait Implementations§
Source§impl<T> Clone for ChunkOffsetsBase<T>
impl<T> Clone for ChunkOffsetsBase<T>
Source§fn clone(&self) -> ChunkOffsetsBase<T>
fn clone(&self) -> ChunkOffsetsBase<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T> Debug for ChunkOffsetsBase<T>
impl<T> Debug for ChunkOffsetsBase<T>
Source§impl<'a> From<ChunkOffsetsBase<&'a [usize]>> for &'a [usize]
Allow chunk offsets view to be converted directly to slices.
impl<'a> From<ChunkOffsetsBase<&'a [usize]>> for &'a [usize]
Allow chunk offsets view to be converted directly to slices.
Source§fn from(view: ChunkOffsetsView<'a>) -> Self
fn from(view: ChunkOffsetsView<'a>) -> Self
Source§impl<T> PartialEq for ChunkOffsetsBase<T>
impl<T> PartialEq for ChunkOffsetsBase<T>
impl<T> Copy for ChunkOffsetsBase<T>
impl<T> StructuralPartialEq for ChunkOffsetsBase<T>
Auto Trait Implementations§
impl<T> Freeze for ChunkOffsetsBase<T>where
T: Freeze,
impl<T> RefUnwindSafe for ChunkOffsetsBase<T>where
T: RefUnwindSafe,
impl<T> Send for ChunkOffsetsBase<T>where
T: Send,
impl<T> Sync for ChunkOffsetsBase<T>where
T: Sync,
impl<T> Unpin for ChunkOffsetsBase<T>where
T: Unpin,
impl<T> UnsafeUnpin for ChunkOffsetsBase<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for ChunkOffsetsBase<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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