Refactor data representation and storage

Mostly moving around code
This commit is contained in:
Joscha 2024-08-25 21:40:11 +02:00
parent 0eb745e928
commit 7a2372fedd
10 changed files with 416 additions and 379 deletions

View file

@ -2,15 +2,17 @@ use std::fs::File;
use std::io::{self, BufReader};
use std::path::Path;
use crate::data::AdjacencyList;
use crate::data::adjacency_list::PageIdx;
use crate::data::store;
pub fn run(datafile: &Path) -> io::Result<()> {
let mut databuf = BufReader::new(File::open(datafile)?);
let data = AdjacencyList::read(&mut databuf)?;
let data = store::read_adjacency_list(&mut databuf)?;
for (page_idx, page) in data.pages.iter().enumerate() {
let page_idx = PageIdx(page_idx as u32);
if page.data.redirect {
for link_idx in data.link_range(page_idx as u32) {
for link_idx in data.link_range(page_idx) {
let target_page = data.page(data.link(link_idx).to);
println!("{:?} -> {:?}", page.data.title, target_page.data.title);
}