From 887ffd59776cf3c86a8b1cb72dc36d07c5b648fc Mon Sep 17 00:00:00 2001 From: Edd Robinson Date: Tue, 2 Jun 2020 16:59:24 +0100 Subject: [PATCH] refactor: remove lifetime to make index re-usable --- Cargo.lock | 1 + src/storage/tsm.rs | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b207d3a3c5..51db586fe6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -411,6 +411,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "predicates 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "prost 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "prost-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/src/storage/tsm.rs b/src/storage/tsm.rs index 7a02157747..5193f42bf6 100644 --- a/src/storage/tsm.rs +++ b/src/storage/tsm.rs @@ -409,11 +409,11 @@ fn parse_tsm_key( /// BlockData describes the various types of block data that can be held within /// a TSM file. -pub enum BlockData<'a> { +pub enum BlockData { Float { ts: Vec, values: Vec }, Integer { ts: Vec, values: Vec }, Bool { ts: Vec, values: Vec }, - Str { ts: Vec, values: Vec<&'a str> }, + Str { ts: Vec, values: Vec }, Unsigned { ts: Vec, values: Vec }, } @@ -574,12 +574,13 @@ mod tests { let f64_block = &index.decode_block(&f64_entry.block).unwrap(); blocks.push(f64_block); - // // Find the first integer block index entry in the file. + // Find the first integer block index entry in the file. let i64_entry = index .find(|e| e.as_ref().unwrap().block_type == 1_u8) .unwrap() .unwrap(); - blocks.push(&index.decode_block(&i64_entry.block).unwrap()); + let i64_block = &index.decode_block(&i64_entry.block).unwrap(); + blocks.push(i64_block); for block in blocks { // The first integer block in the value should have 509 values in it.