pub struct ContentHashedIndex {
pub duplicates_found: usize,
pub unique_items: usize,
/* private fields */
}Expand description
Content-hashed index for deduplication of code units.
Used to avoid indexing identical code multiple times. The index normalizes whitespace before hashing, so code with different formatting but identical content will be detected as duplicates.
§Examples
use go_brrr::semantic::ContentHashedIndex;
let mut index = ContentHashedIndex::new();
// First occurrence is added
assert!(index.add("def foo(): pass", "src/a.py", "foo", 10));
// Identical content is detected as duplicate
assert!(!index.add("def foo(): pass", "src/b.py", "foo", 20));
// Check stats
let (unique, duplicates) = index.stats();
assert_eq!(unique, 1);
assert_eq!(duplicates, 1);Fields§
§duplicates_found: usizeNumber of duplicate items detected
unique_items: usizeNumber of unique items indexed
Implementations§
Source§impl ContentHashedIndex
impl ContentHashedIndex
Sourcepub fn check_duplicate(&self, content: &str) -> Option<&CodeLocation>
pub fn check_duplicate(&self, content: &str) -> Option<&CodeLocation>
Sourcepub fn dedup_ratio(&self) -> f64
pub fn dedup_ratio(&self) -> f64
Get the deduplication ratio (duplicates / total).
Returns 0.0 if no items have been processed.
Trait Implementations§
Source§impl Clone for ContentHashedIndex
impl Clone for ContentHashedIndex
Source§fn clone(&self) -> ContentHashedIndex
fn clone(&self) -> ContentHashedIndex
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContentHashedIndex
impl Debug for ContentHashedIndex
Source§impl Default for ContentHashedIndex
impl Default for ContentHashedIndex
Source§fn default() -> ContentHashedIndex
fn default() -> ContentHashedIndex
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ContentHashedIndex
impl RefUnwindSafe for ContentHashedIndex
impl Send for ContentHashedIndex
impl Sync for ContentHashedIndex
impl Unpin for ContentHashedIndex
impl UnwindSafe for ContentHashedIndex
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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 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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request