pub struct DictionaryIndexTask {
database: Database,
}Expand description
Indexes .index dictionary files into SQLite for fast word lookups.
On each startup the task resumes from where it left off, so large dictionaries are indexed incrementally across restarts.
Fields§
§database: DatabaseImplementations§
Source§impl DictionaryIndexTask
impl DictionaryIndexTask
Sourcepub fn new(database: Database) -> Self
pub fn new(database: Database) -> Self
Creates a new DictionaryIndexTask.
Sourcefn detect_metadata(path_str: &str) -> (bool, bool)
fn detect_metadata(path_str: &str) -> (bool, bool)
Detects dictionary metadata by scanning the first lines of the .index
file for 00-database-allchars and 00-database-case-sensitive entries.
Returns (case_sensitive, all_chars).
Sourcefn resolve_index_state(
&self,
index_path: &Path,
path_str: &str,
fp_str: &str,
) -> Option<(i64, u64, u64, bool)>
fn resolve_index_state( &self, index_path: &Path, path_str: &str, fp_str: &str, ) -> Option<(i64, u64, u64, bool)>
Queries or initialises the metadata row for fp_str, returning
(dict_id, skip_lines, total_lines).
Returns None when the file is already fully indexed or a DB error
occurs, signalling that index_file should skip this file.
Sourcefn mark_completed(
&self,
dict_id: i64,
path_str: &str,
current_line: u64,
total_lines: u64,
)
fn mark_completed( &self, dict_id: i64, path_str: &str, current_line: u64, total_lines: u64, )
Marks the dictionary as fully indexed in the metadata table.
Sourcefn parse_index_line<'a>(
path_str: &str,
line: &'a str,
) -> Option<(&'a str, i64, i64)>
fn parse_index_line<'a>( path_str: &str, line: &'a str, ) -> Option<(&'a str, i64, i64)>
Parses one tab-separated line from a .index file.
Returns None for lines that cannot be decoded. On decode failure a
tracing error is emitted so the caller can skip the line without losing
diagnostic info. Metadata lines such as 00-database-* are parsed
normally so they are indexed and available for dictionary metadata
queries.
Sourcefn scan_and_batch(
&self,
job: &IndexFileJob<'_>,
skip_lines: u64,
hub: &Sender<Event>,
shutdown: &ShutdownSignal,
) -> Option<u64>
fn scan_and_batch( &self, job: &IndexFileJob<'_>, skip_lines: u64, hub: &Sender<Event>, shutdown: &ShutdownSignal, ) -> Option<u64>
Drives the line-by-line scan of an open index file, collecting entries into batches and flushing them to the database.
Returns Some(current_line) when scanning completed normally, None
when a flush error or shutdown cut it short.
fn index_file( &self, index_path: &Path, hub: &Sender<Event>, shutdown: &ShutdownSignal, )
fn flush_batch( &self, job: &IndexFileJob<'_>, batch: &[(i64, String, i64, i64, Option<String>)], current_line: u64, hub: &Sender<Event>, ) -> Result<(), Error>
Sourcefn delete_stale_entries(
&self,
on_disk_fingerprints: &[String],
hub: &Sender<Event>,
shutdown: &ShutdownSignal,
)
fn delete_stale_entries( &self, on_disk_fingerprints: &[String], hub: &Sender<Event>, shutdown: &ShutdownSignal, )
Removes index data for dictionaries that are no longer present on disk.
For each fingerprint in dictionary_index_meta that has no corresponding
.index file in on_disk_fingerprints, this method marks the meta row as
incomplete before deletion begins. This ensures that if the process is
interrupted mid-deletion, the next startup does not treat a partially
deleted dictionary as fully indexed. Entries are then removed in batches
via delete_entries_for_dict, after which the meta row itself is deleted.
Trait Implementations§
Source§impl BackgroundTask for DictionaryIndexTask
impl BackgroundTask for DictionaryIndexTask
Auto Trait Implementations§
impl Freeze for DictionaryIndexTask
impl !RefUnwindSafe for DictionaryIndexTask
impl Send for DictionaryIndexTask
impl Sync for DictionaryIndexTask
impl Unpin for DictionaryIndexTask
impl UnsafeUnpin for DictionaryIndexTask
impl !UnwindSafe for DictionaryIndexTask
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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