-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
208 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
"./Cargo.toml", | ||
"./Cargo.toml", | ||
"./Cargo.toml", | ||
"./Cargo.toml", | ||
"./Cargo.toml" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use std::{cmp::Ordering, collections::HashMap, path::PathBuf}; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct TableBiggestKeys { | ||
pub sstables: HashMap<PathBuf, Vec<u8>>, | ||
} | ||
impl TableBiggestKeys { | ||
pub fn new() -> Self { | ||
Self { | ||
sstables: HashMap::new(), | ||
} | ||
} | ||
|
||
pub fn set(&mut self, sst_path: PathBuf, biggest_key: Vec<u8>) -> bool { | ||
self.sstables.insert(sst_path, biggest_key).is_some() | ||
} | ||
|
||
pub fn remove(&mut self, sst_path: PathBuf) -> bool { | ||
self.sstables.remove(&sst_path).is_some() | ||
} | ||
|
||
// Returns SSTables whose last key is greater than the supplied key parameter | ||
pub fn filter_sstables_by_biggest_key(&self, key: &Vec<u8>) -> Vec<&PathBuf> { | ||
self.sstables | ||
.iter() | ||
.filter(|(_, key_prefix)| { | ||
key_prefix.as_slice().cmp(key) == Ordering::Greater | ||
|| key_prefix.as_slice().cmp(key) == Ordering::Equal | ||
}) | ||
.map(|(path, _)| return path) | ||
.collect() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mod key_offseter; | ||
pub use key_offseter::TableBiggestKeys; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.