Giter Club home page Giter Club logo

btree-and-bplustree-realize's Introduction

文件说明:

1.Tree.h:B树和B+树的通用接口,虚基类。BTree和BPlusTree都继承它,只有BPlusTree才有linear函数 2.BTree.h,BTree.cpp:B树的声明、实现代码 3.BPlusTree.h,BPlusTree.cpp:B+树的声明、实现代码,注:大多数的函数,B和B+都是一样的,但是我还是分开写了,比如输出函数 4.Context.h:策略方法的实现 5.mian.cpp:使用用例,因为我测试的时候windows和linux都有,为使中文不乱码,我在main写的简单的英语说明

不足之处的改进

对于数据库来说,目前的BTree操作有两个大问题,一个是吃内存(我是把整体数据在内存中操作),另一个是没能立即持久化。而数据库的其他功能,如事务处理、并发暂不考虑。 针对以上提到的2个问题(吃内存,没持久化),实现方案思路如下: 1.只是把B+树的部份放在内存中,一有变化,即时把变化存起来,以防断电;(留有接口,还没写) 2.可以写一个虚函数接口,fopen、fwrite、fread这样的,然后去调基类的这些接口,并分别在派生类中去封装Linux的文件读法、C语言的读法、C++的读法,然后通过改变生成的派生类的不同,比较它们读写的效率。

时间测试说明:

100W的随机数据存入硬盘,包括插入数据的时间: B存数据,1.70s左右; B+存数据,inorder函数存,2.2s左右;linear函数存,2s左右; 如果不算插入的时间,只是存储的时间,0.2s-0.4s左右。 注:inorder函数:从根结点开始遍历,linear函数:从叶子结点链表开始遍历。写入文件用的fwrite来写的整体结构体来存储测试的。另外的fprintf存文件,100W数据,起码要30秒。

btree-and-bplustree-realize's People

Contributors

orange1438 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.