mirror of https://github.com/dswd/zvault
Enforcing bundle ordering in index rebuild (re #13)
This commit is contained in:
parent
ca7153117b
commit
cc4a9f40ee
|
@ -7,6 +7,7 @@ This project follows [semantic versioning](http://semver.org).
|
||||||
* [added] Ability to read/write tar file from/to stdin/stdout
|
* [added] Ability to read/write tar file from/to stdin/stdout
|
||||||
* [added] Added date to bundles
|
* [added] Added date to bundles
|
||||||
* [modified] Logging to stderr
|
* [modified] Logging to stderr
|
||||||
|
* [modified] Enforce deterministic bundle ordering
|
||||||
* [fixed] Only print "repairing bundles" if actually repairing bundles
|
* [fixed] Only print "repairing bundles" if actually repairing bundles
|
||||||
* [fixed] Only put mode bits of st_mode into metadata
|
* [fixed] Only put mode bits of st_mode into metadata
|
||||||
|
|
||||||
|
|
|
@ -255,6 +255,7 @@ fn print_config(config: &Config) {
|
||||||
|
|
||||||
fn print_analysis(analysis: &HashMap<u32, BundleAnalysis>) {
|
fn print_analysis(analysis: &HashMap<u32, BundleAnalysis>) {
|
||||||
let mut reclaim_space = [0; 11];
|
let mut reclaim_space = [0; 11];
|
||||||
|
let mut rewrite_size = [0; 11];
|
||||||
let mut data_total = 0;
|
let mut data_total = 0;
|
||||||
for bundle in analysis.values() {
|
for bundle in analysis.values() {
|
||||||
data_total += bundle.info.encoded_size;
|
data_total += bundle.info.encoded_size;
|
||||||
|
@ -262,6 +263,7 @@ fn print_analysis(analysis: &HashMap<u32, BundleAnalysis>) {
|
||||||
for i in 0..11 {
|
for i in 0..11 {
|
||||||
if bundle.get_usage_ratio() <= i as f32 * 0.1 {
|
if bundle.get_usage_ratio() <= i as f32 * 0.1 {
|
||||||
reclaim_space[i] += bundle.get_unused_size();
|
reclaim_space[i] += bundle.get_unused_size();
|
||||||
|
rewrite_size[i] += bundle.get_used_size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -271,7 +273,7 @@ fn print_analysis(analysis: &HashMap<u32, BundleAnalysis>) {
|
||||||
println!("Reclaimable space (depending on vacuum ratio)");
|
println!("Reclaimable space (depending on vacuum ratio)");
|
||||||
#[allow(unknown_lints,needless_range_loop)]
|
#[allow(unknown_lints,needless_range_loop)]
|
||||||
for i in 0..11 {
|
for i in 0..11 {
|
||||||
println!(" - ratio={:3}: {:>10}, {:4.1} %", i*10, to_file_size(reclaim_space[i] as u64), reclaim_space[i] as f32 / data_total as f32 * 100.0);
|
println!(" - ratio={:3}: {:>10}, {:4.1} %, rewriting {:>10}", i*10, to_file_size(reclaim_space[i] as u64), reclaim_space[i] as f32 / data_total as f32 * 100.0, to_file_size(rewrite_size[i] as u64));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -348,7 +348,9 @@ impl Repository {
|
||||||
pub fn rebuild_index(&mut self) -> Result<(), RepositoryError> {
|
pub fn rebuild_index(&mut self) -> Result<(), RepositoryError> {
|
||||||
info!("Rebuilding index from bundles");
|
info!("Rebuilding index from bundles");
|
||||||
self.index.clear();
|
self.index.clear();
|
||||||
for (num, id) in self.bundle_map.bundles() {
|
let mut bundles = self.bundle_map.bundles();
|
||||||
|
bundles.sort_by_key(|&(_, ref v)| v.clone());
|
||||||
|
for (num, id) in bundles {
|
||||||
let chunks = try!(self.bundles.get_chunk_list(&id));
|
let chunks = try!(self.bundles.get_chunk_list(&id));
|
||||||
for (i, (hash, _len)) in chunks.into_inner().into_iter().enumerate() {
|
for (i, (hash, _len)) in chunks.into_inner().into_iter().enumerate() {
|
||||||
try!(self.index.set(&hash, &Location{bundle: num as u32, chunk: i as u32}));
|
try!(self.index.set(&hash, &Location{bundle: num as u32, chunk: i as u32}));
|
||||||
|
|
Loading…
Reference in New Issue