Skip to content

Commit

Permalink
Pass error
Browse files Browse the repository at this point in the history
  • Loading branch information
namse committed Nov 14, 2024
1 parent a55b447 commit 0419b9f
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 232 deletions.
20 changes: 10 additions & 10 deletions luda-editor/new-server/bptree/src/bp_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ mod test {

#[tokio::test]
async fn test_insert() {
let path = std::env::temp_dir().join("bp_map_test_insert");
let path = std::env::temp_dir().join("bp_map::bp_map_test_insert");
if let Err(err) = std::fs::remove_file(&path) {
if err.kind() != std::io::ErrorKind::NotFound {
panic!("{:?}", err);
Expand Down Expand Up @@ -116,7 +116,7 @@ mod test {

#[tokio::test]
async fn test_insert_and_delete() {
let path = std::env::temp_dir().join("bp_map_test_insert_and_delete");
let path = std::env::temp_dir().join("bp_map::bp_map_test_insert_and_delete");
if let Err(err) = std::fs::remove_file(&path) {
if err.kind() != std::io::ErrorKind::NotFound {
panic!("{:?}", err);
Expand Down Expand Up @@ -154,7 +154,7 @@ mod test {

#[tokio::test]
async fn test_insert_contains() {
let path = std::env::temp_dir().join("bp_map_test_insert_contains");
let path = std::env::temp_dir().join("bp_map::bp_map_test_insert_contains");
if let Err(err) = std::fs::remove_file(&path) {
if err.kind() != std::io::ErrorKind::NotFound {
panic!("{:?}", err);
Expand Down Expand Up @@ -198,7 +198,7 @@ mod test {

#[tokio::test]
async fn test_insert_delete_contains() {
let path = std::env::temp_dir().join("bp_map_test_insert_delete_contains");
let path = std::env::temp_dir().join("bp_map::bp_map_test_insert_delete_contains");
if let Err(err) = std::fs::remove_file(&path) {
if err.kind() != std::io::ErrorKind::NotFound {
panic!("{:?}", err);
Expand Down Expand Up @@ -251,7 +251,7 @@ mod test {

#[tokio::test]
async fn test_insert_delete_get() {
let path = std::env::temp_dir().join("bp_map_test_insert_delete_get");
let path = std::env::temp_dir().join("bp_map::bp_map_test_insert_delete_get");
if let Err(err) = std::fs::remove_file(&path) {
if err.kind() != std::io::ErrorKind::NotFound {
panic!("{:?}", err);
Expand Down Expand Up @@ -306,7 +306,7 @@ mod test {

#[tokio::test]
async fn test_insert_delete_contains_without_cache() {
let path = std::env::temp_dir().join("test_insert_delete_contains_without_cache");
let path = std::env::temp_dir().join("bp_map::test_insert_delete_contains_without_cache");
if let Err(err) = std::fs::remove_file(&path) {
if err.kind() != std::io::ErrorKind::NotFound {
panic!("{:?}", err);
Expand Down Expand Up @@ -359,7 +359,7 @@ mod test {

#[tokio::test]
async fn test_insert_delete_contains_small_cache() {
let path = std::env::temp_dir().join("test_insert_delete_contains_small_cache");
let path = std::env::temp_dir().join("bp_map::test_insert_delete_contains_small_cache");
if let Err(err) = std::fs::remove_file(&path) {
if err.kind() != std::io::ErrorKind::NotFound {
panic!("{:?}", err);
Expand Down Expand Up @@ -412,7 +412,7 @@ mod test {

#[tokio::test]
async fn test_insert_turn_off_contains() {
let path = std::env::temp_dir().join("test_insert_turn_off_contains");
let path = std::env::temp_dir().join("bp_map::test_insert_turn_off_contains");
if let Err(err) = std::fs::remove_file(&path) {
if err.kind() != std::io::ErrorKind::NotFound {
panic!("{:?}", err);
Expand Down Expand Up @@ -461,7 +461,7 @@ mod test {

#[tokio::test]
async fn test_next_insert_next_delete_next() {
let path = std::env::temp_dir().join("test_next_insert_next_delete_next");
let path = std::env::temp_dir().join("bp_map::test_next_insert_next_delete_next");
if let Err(err) = std::fs::remove_file(&path) {
if err.kind() != std::io::ErrorKind::NotFound {
panic!("{:?}", err);
Expand Down Expand Up @@ -514,7 +514,7 @@ mod test {

// #[tokio::test]
// async fn test_stream() {
// let path = std::env::temp_dir().join("test_stream");
// let path = std::env::temp_dir().join("bp_map::test_stream");
// if let Err(err) = std::fs::remove_file(&path) {
// if err.kind() != std::io::ErrorKind::NotFound {
// panic!("{:?}", err);
Expand Down
6 changes: 5 additions & 1 deletion luda-editor/new-server/bptree/src/bp_map/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Operator {
}

let (right_half, center_key) =
leaf_node.split_and_insert(key, record_page_range, leaf_node_offset, right_node_offset);
leaf_node.split_and_insert(key, record_page_range, right_node_offset);
self.blocks_updated.insert(
PageRange::page(right_node_offset),
PageBlock::Page(Page::LeafNode(right_half)),
Expand Down Expand Up @@ -110,6 +110,7 @@ impl Operator {
.await?
.as_leaf_node_mut();
leaf_node.delete(key);
assert!(!leaf_node.contains(key));
}

Ok(())
Expand All @@ -124,14 +125,17 @@ impl Operator {
Ok(contains)
}
pub async fn get(&mut self, key: Key) -> Result<Option<Bytes>> {
println!("key: {:?}", key);
let leaf_node_offset = self.find_leaf_node_for(key).await?;
let leaf_node = self
.page(leaf_node_offset, PageBlockTypeHint::Node)
.await?
.as_leaf_node();
let Some(record_page_range) = leaf_node.get_record_page_range(key) else {
println!("not exists: {:?}", key);
return Ok(None);
};
println!("record_page_range: {:?}", record_page_range);
let bytes = self.record(record_page_range).await?;
Ok(Some(bytes))
}
Expand Down
Loading

0 comments on commit 0419b9f

Please sign in to comment.