Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroOneKnowFly committed Aug 25, 2024
1 parent bedd940 commit 23b5b4d
Show file tree
Hide file tree
Showing 8 changed files with 228 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
!/doc
!/dashboard
!/README.md
!/README_zh_CN.md
!/README_zh_CN.md

/Cargo.lock
129 changes: 128 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resolver = "2"

members = [
# "dashboard",
# "src/storage",
"src/storage",
# "src/query_engine",
# "src/tools",
# "src/util",
Expand Down
13 changes: 13 additions & 0 deletions doc/develop/ coding_standards_zh_CN.md
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中标识符的命名 规则应该使用统一的词序
81 changes: 81 additions & 0 deletions src/storage/src/btree.rs
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.)
}
1 change: 1 addition & 0 deletions src/storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ pub mod model;
pub mod record;
pub mod timestamp;
pub mod wal;
pub mod btree;
2 changes: 1 addition & 1 deletion src/storage/src/meta_db/bwtree.rs
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 added src/storage/src/page/mod.rs
Empty file.

0 comments on commit 23b5b4d

Please sign in to comment.