Skip to main content

StatsVisitor

Struct StatsVisitor 

Source
pub struct StatsVisitor {
    pub article_count: u64,
    pub category_count: u64,
    pub link_count: u64,
    pub infobox_count: u64,
    pub reference_count: u64,
}
Expand description

A visitor that collects counts only (low memory footprint).

Tracks aggregate statistics without storing individual articles. Useful for getting overview statistics of a snapshot.

§Example

use wme_stream::{ArticleVisitor, StatsVisitor};
use serde_json::Value;

let mut visitor = StatsVisitor::new();

// Simulate visiting articles
for i in 0..100 {
    visitor.visit_article_start(i as u64, "Article");
    visitor.visit_category("Category:Test", "https://en.wikipedia.org/wiki/Category:Test");
    visitor.visit_link("Link", "https://en.wikipedia.org/wiki/Link");
    visitor.visit_article_end();
}

assert_eq!(visitor.article_count, 100);
assert_eq!(visitor.category_count, 100);
assert_eq!(visitor.link_count, 100);

Fields§

§article_count: u64

Total articles processed

§category_count: u64

Total categories found

§link_count: u64

Total links found

§infobox_count: u64

Total infoboxes found

§reference_count: u64

Total references found

Implementations§

Source§

impl StatsVisitor

Source

pub fn new() -> Self

Create a new stats visitor with all counts at zero.

§Example
use wme_stream::StatsVisitor;

let visitor = StatsVisitor::new();
assert_eq!(visitor.article_count, 0);
assert_eq!(visitor.category_count, 0);

Trait Implementations§

Source§

impl ArticleVisitor for StatsVisitor

Source§

fn visit_article_start(&mut self, _id: u64, _name: &str)

Called when starting to process an article. Read more
Source§

fn visit_category(&mut self, _name: &str, _url: &str)

Called when encountering a category. Read more
Called when encountering a link. Read more
Source§

fn visit_infobox(&mut self, _name: &str, _value: &str)

Called when encountering an infobox field. Read more
Source§

fn visit_reference(&mut self, _id: &str, _ref_type: &str, _metadata: &Value)

Called when encountering a reference. Read more
Source§

fn visit_article_end(&mut self)

Called when finished processing an article. Read more
Source§

impl Default for StatsVisitor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.