Use string cache and update README
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
|
||||
use rust_matrix_lib::state_map::StateMap;
|
||||
use string_cache::DefaultAtom as Atom;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
@@ -159,7 +160,7 @@ impl<'a> Compressor<'a> {
|
||||
/// group that can be used as a base for a delta.
|
||||
///
|
||||
/// Returns the state map and the actual base state group (if any) used.
|
||||
fn get_delta(&mut self, prev_sg: Option<i64>, sg: i64) -> (StateMap<String>, Option<i64>) {
|
||||
fn get_delta(&mut self, prev_sg: Option<i64>, sg: i64) -> (StateMap<Atom>, Option<i64>) {
|
||||
let state_map = collapse_state_maps(&self.original_state_map, sg);
|
||||
|
||||
let mut prev_sg = if let Some(prev_sg) = prev_sg {
|
||||
|
||||
@@ -84,7 +84,7 @@ fn get_initial_data_from_db(conn: &Connection, room_id: &str) -> BTreeMap<i64, S
|
||||
if let Some(etype) = etype {
|
||||
entry
|
||||
.state_map
|
||||
.insert(&etype, &row.get::<_, String>(3), row.get(4));
|
||||
.insert(&etype, &row.get::<_, String>(3), row.get::<_, String>(4).into());
|
||||
}
|
||||
|
||||
pb.inc(1);
|
||||
|
||||
@@ -9,6 +9,7 @@ extern crate indicatif;
|
||||
extern crate postgres;
|
||||
extern crate rayon;
|
||||
extern crate rust_matrix_lib;
|
||||
extern crate string_cache;
|
||||
|
||||
mod compressor;
|
||||
mod database;
|
||||
@@ -18,6 +19,7 @@ use compressor::Compressor;
|
||||
use clap::{App, Arg};
|
||||
use rayon::prelude::*;
|
||||
use rust_matrix_lib::state_map::StateMap;
|
||||
use string_cache::DefaultAtom as Atom;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::fs::File;
|
||||
@@ -29,14 +31,14 @@ use std::str::FromStr;
|
||||
#[derive(Default, Debug, Clone, PartialEq, Eq)]
|
||||
pub struct StateGroupEntry {
|
||||
prev_state_group: Option<i64>,
|
||||
state_map: StateMap<String>,
|
||||
state_map: StateMap<Atom>,
|
||||
}
|
||||
|
||||
/// Gets the full state for a given group from the map (of deltas)
|
||||
pub fn collapse_state_maps(
|
||||
map: &BTreeMap<i64, StateGroupEntry>,
|
||||
state_group: i64,
|
||||
) -> StateMap<String> {
|
||||
) -> StateMap<Atom> {
|
||||
let mut entry = &map[&state_group];
|
||||
let mut state_map = StateMap::new();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user