diff --git a/crates/loro-core/examples/encoding.rs b/crates/loro-core/examples/encoding.rs index feec667d..75193610 100644 --- a/crates/loro-core/examples/encoding.rs +++ b/crates/loro-core/examples/encoding.rs @@ -1,6 +1,9 @@ -use std::{io::Read, time::Instant}; +use std::{ + io::{Read, Write}, + time::Instant, +}; -use flate2::read::GzDecoder; +use flate2::{read::GzDecoder, write::GzEncoder}; use loro_core::{configure::Configure, container::registry::ContainerWrapper, LoroCore}; use serde_json::Value; const RAW_DATA: &[u8; 901823] = include_bytes!("../benches/automerge-paper.json.gz"); @@ -47,20 +50,10 @@ fn main() { assert_eq!(buf, buf2); let json2 = loro.to_json(); assert_eq!(json1, json2); - let mut last = 100; - let mut count = 0; - let mut max_count = 0; - for &byte in buf.iter() { - if byte == last { - count += 1; - if count > max_count { - max_count = count; - } - } else { - count = 0; - } - last = byte; - } - - println!("Longest continuous bytes length {}", max_count); + let update_buf = loro.export_updates(&Default::default()).unwrap(); + println!("Updates have {} bytes", update_buf.len()); + let mut encoder = GzEncoder::new(Vec::new(), flate2::Compression::default()); + encoder.write_all(&update_buf).unwrap(); + let data = encoder.finish().unwrap(); + println!("After compress updates have {} bytes", data.len()); } diff --git a/crates/loro-core/src/log_store.rs b/crates/loro-core/src/log_store.rs index 1ab88fab..d5818b15 100644 --- a/crates/loro-core/src/log_store.rs +++ b/crates/loro-core/src/log_store.rs @@ -45,7 +45,7 @@ pub struct GcConfig { impl Default for GcConfig { fn default() -> Self { GcConfig { - gc: true, + gc: false, snapshot_interval: 6 * MONTH, } }