Skip to content

Commit

Permalink
Merge pull request #36 from BnjmnZmmrmn/bplusdb
Browse files Browse the repository at this point in the history
  • Loading branch information
BnjmnZmmrmn authored Sep 18, 2024
2 parents 7a4ba4d + fd645b4 commit 4a3f96a
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 10 deletions.
38 changes: 38 additions & 0 deletions src/database/bplus/index/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//! # Bplus Tree Errors [WIP]
//!
//! This file contains error codes that are
//! surfaced in the Bplus Tree API.

/* IMPORTS */

use std::fmt::{Formatter, Result};

/* CONSTANTS */

/* DEFINITIONS */

#[derive(Debug)]
pub enum Error {
UnexpectedError,
}

/* IMPLEMENTATIONS */

impl std::fmt::Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
todo!()
}
}

impl std::convert::From<std::io::Error> for Error {
fn from(_e: std::io::Error) -> Error {
Error::UnexpectedError
}
}

/* UNIT TESTING */

#[cfg(test)]
mod tests {
use super::*;
}
23 changes: 23 additions & 0 deletions src/database/bplus/index/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//! # Bplus Tree Module [WIP]
//!
//! This module provides a b+ tree data structure
//! that supports insert, delete, and lookup operations.

/* UTILITY MODULES */

mod error;

/* IMPLEMENTATION MODULES */

mod tree;

/* IMPORTS */

pub use tree::{BTree, BTreeBuilder};

/* UNIT TESTING */

#[cfg(test)]
mod tests {
use super::*;
}
68 changes: 68 additions & 0 deletions src/database/bplus/index/tree.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//! # Bplus Tree Implementation [WIP]
//!
//! This file contains a b+ tree implementation
//! and a b+ tree builder to help with construction.

/* IMPORTS */

use anyhow::Result;
use crate::{
database::{bplus::index::error::Error, Record},
model::State,
};

/* DEFINITIONS */

struct BTreeRecord {
}

pub struct BTree<> {
}

pub struct BTreeBuilder {
}

/* IMPLEMENTATIONS */

impl Record for BTreeRecord {
fn raw(&self) -> &bitvec::prelude::BitSlice<u8, bitvec::prelude::Msb0> {
todo!()
}
}

impl BTree<> {
fn insert(&mut self, record: BTreeRecord) -> Result<(), Error> {
todo!()
}

fn delete(&mut self, state: &State) -> Result<(), Error> {
todo!()
}

fn lookup(&mut self, state: &State) -> Result<BTreeRecord, Error> {
todo!()
}

#[cfg(debug_assertions)]
fn print(&mut self) -> Result<(), Error> {
todo!()
}
}


impl BTreeBuilder<> {
pub fn initialize() -> Result<Self> {
todo!()
}

pub fn build(&self) -> Result<BTree, Error> {
todo!()
}
}

/* UNIT TESTING */

#[cfg(test)]
mod tests {
use super::*;
}
21 changes: 11 additions & 10 deletions src/database/bplus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
//! This module provides a database implementation backed by a
//! persistent bplus tree.

/* UTILITY MODULES */

mod index;

/* IMPORTS */

use anyhow::Result;
Expand All @@ -15,27 +19,24 @@ use crate::{
model::State,
};

/* CONSTANTS */

/* DATABASE DEFINITION */
/* DEFINITIONS */

pub struct Database<'a> {
data: &'a str,
pub struct Database<> {
}

pub struct Parameters<'a> {
persistence: Persistence<'a>,
}

/* IMPLEMENTATION */
/* IMPLEMENTATIONS */

impl Database<'_> {
impl Database<> {
pub fn initialize(params: Parameters) -> Result<Self> {
todo!()
}
}

impl<R: Record> KVStore<R> for Database<'_> {
impl<R: Record> KVStore<R> for Database<> {
fn put(&mut self, key: State, value: &R) {
todo!()
}
Expand All @@ -49,7 +50,7 @@ impl<R: Record> KVStore<R> for Database<'_> {
}
}

impl Persistent for Database<'_> {
impl Persistent for Database<> {
fn bind_path(&self, path: &Path) -> Result<()> {
todo!()
}
Expand All @@ -59,7 +60,7 @@ impl Persistent for Database<'_> {
}
}

impl Tabular for Database<'_> {
impl Tabular for Database<> {
fn create_table(&self, id: &str, schema: Schema) -> Result<()> {
todo!()
}
Expand Down

0 comments on commit 4a3f96a

Please sign in to comment.