Struct db_dump::Loader [−][src]
Perform a streaming load of only relevant database tables.
Example
This example loads just the version_downloads.csv table, in which each row is the download count for a single version of a single crate on a single day. We do not store the rows individually in memory but instead stream from the csv to accumulate just a total count per day across all crates, which requires far less memory.
use chrono::NaiveDate; use std::collections::BTreeMap as Map; fn main() -> db_dump::Result<()> { let mut downloads = Map::<NaiveDate, u64>::new(); db_dump::Loader::new() .version_downloads(|row| { *downloads.entry(row.date).or_default() += row.downloads; }) .load("./dbdump.tar.gz")?; for (date, count) in downloads { println!("{},{}", date, count); } Ok(()) }
Implementations
impl<'a> Loader<'a>
[src]
pub fn new() -> Self
[src]
pub fn badges(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
[src]
pub fn categories(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
[src]
pub fn crate_owners(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
[src]
pub fn crates(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
[src]
pub fn crates_categories(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
[src]
pub fn crates_keywords(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
[src]
pub fn dependencies(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
[src]
pub fn keywords(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
[src]
pub fn metadata(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
[src]
pub fn reserved_crate_names(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
[src]
pub fn teams(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
[src]
pub fn users(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
[src]
pub fn version_authors(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
[src]
pub fn version_downloads(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
[src]
pub fn versions(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
[src]
pub fn load(&mut self, path: impl AsRef<Path>) -> Result<()>
[src]
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Loader<'a>
impl<'a> !Send for Loader<'a>
impl<'a> !Sync for Loader<'a>
impl<'a> Unpin for Loader<'a>
impl<'a> !UnwindSafe for Loader<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
pub 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>,