-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
bedd940
commit 23b5b4d
Showing
8 changed files
with
228 additions
and
4 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 |
---|---|---|
|
@@ -8,4 +8,6 @@ | |
!/doc | ||
!/dashboard | ||
!/README.md | ||
!/README_zh_CN.md | ||
!/README_zh_CN.md | ||
|
||
/Cargo.lock |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,13 @@ | ||
# MacrocosmDB 编发规范 V1.0 | ||
|
||
## 1. 概述 | ||
|
||
|
||
|
||
|
||
|
||
## 2. 代码风格 | ||
|
||
### 2.1 命名 | ||
|
||
#### 2.1.1 同一个crate中标识符的命名 规则应该使用统一的词序 |
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,81 @@ | ||
/* | ||
* MacrocosmDB | ||
* btree.rs | ||
* | ||
* Copyright (c) 2024 ULis | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
* Description: Brief description of what this file is for. | ||
*/ | ||
|
||
use std::cmp::Ordering; | ||
|
||
enum Node<K, V> { | ||
Internal(InternalNode<K, V>), | ||
Leaf(LeafNode<K, V>), | ||
} | ||
|
||
struct InternalNode<K, V> { | ||
keys : Vec<K>, | ||
children : Vec<Box<Node<K, V>>>, | ||
} | ||
|
||
struct LeafNode<K, V> { | ||
keys : Vec<K>, | ||
values : Vec<V>, | ||
next : Option<Box<LeafNode<K, V>>>, | ||
} | ||
|
||
// B+ tree structure | ||
pub struct BPTree<K, V> { | ||
root: Option<Box<Node<K, V>>>, | ||
order: usize, | ||
} | ||
|
||
impl<K: Ord + Clone, V> BPTree<K, V> { | ||
// Create a new B+ tree | ||
pub fn new(order: usize) -> Self { | ||
BPTree { | ||
root: None, | ||
order, | ||
} | ||
} | ||
|
||
// Insert a key-value pair | ||
pub fn insert(&mut self, key: K, value: V) { | ||
// TODO: Implement insertion logic | ||
} | ||
|
||
// Get the value associated with a key | ||
pub fn get(&self, key: &K) -> Option<&V> { | ||
// TODO: Implement search logic | ||
None | ||
} | ||
|
||
// Delete a key-value pair | ||
pub fn delete(&mut self, key: &K) { | ||
// TODO: Implement deletion logic | ||
} | ||
} | ||
|
||
// Helper functions for node operations | ||
impl<K: Ord + Clone, V> Node<K, V> { | ||
// ... (Implementation for node splitting, merging, etc.) | ||
} |
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 |
---|---|---|
|
@@ -6,3 +6,4 @@ pub mod model; | |
pub mod record; | ||
pub mod timestamp; | ||
pub mod wal; | ||
pub mod btree; |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/// cache line size. | ||
pub const cache_line_size: u32 = 64; | ||
pub const CACHE_LINE_SIZE: u32 = 64; | ||
|
||
pub struct BwTree {} |
Empty file.