[−][src]Struct sacapart::PartitionedSuffixArray
A partitioned suffix array, that is faster to construct but finds slightly worse matches in a slightly longer amount of time.
Suffix sorting is an expensive operation that is hard to parallelize well. The idea behind a partitioned suffix array is to suffix sort multiple parts of a text (in parallel) rather than the full text.
Using two partitions will result in roughly 2x faster construction (assuming there are two cores available), but search will now take O(2 * log n), and matches across the boundaries may be much worse.
For example, the text "totor" may be partitioned into "tot" and "or". Looking for matches for "tor" may well only return a substring of "to", at offset 0, because the first partition only has the suffixes "t", "to", and "tot". The second partition only has the suffixes "or" and "r". So, it finds the substring "(to)tor", tries to extend it to the right, and fails. It doesn't try to extend "to(t)or", because in the suffix array of that partition, that substring is a weaker match than "(to)tor".
For some applications (like bsdiff-like algorithms), this is an acceptable tradeoff (the resulting patch will be slightly larger). For others, it isn't.
Methods
impl<'a, Index> PartitionedSuffixArray<'a, Index> where
Index: ToPrimitive + Send,
[src]
Index: ToPrimitive + Send,
pub fn new<F>(text: &'a [u8], num_partitions: usize, f: F) -> Self where
F: Fn(&'a [u8]) -> SuffixArray<'a, Index> + Sync,
[src]
F: Fn(&'a [u8]) -> SuffixArray<'a, Index> + Sync,
pub fn num_partitions(&self) -> usize
[src]
Trait Implementations
impl<'a, Index> StringIndex<'a> for PartitionedSuffixArray<'a, Index> where
Index: ToPrimitive + Send,
[src]
Index: ToPrimitive + Send,
fn longest_substring_match(&self, needle: &[u8]) -> LongestCommonSubstring<'a>
[src]
Auto Trait Implementations
impl<'a, Index> Send for PartitionedSuffixArray<'a, Index>
impl<'a, Index> Sync for PartitionedSuffixArray<'a, Index> where
Index: Sync,
Index: Sync,
impl<'a, Index> Unpin for PartitionedSuffixArray<'a, Index> where
Index: Unpin,
Index: Unpin,
impl<'a, Index> UnwindSafe for PartitionedSuffixArray<'a, Index> where
Index: UnwindSafe,
Index: UnwindSafe,
impl<'a, Index> RefUnwindSafe for PartitionedSuffixArray<'a, Index> where
Index: RefUnwindSafe,
Index: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,