• Stars
    star
    1,424
  • Rank 32,725 (Top 0.7 %)
  • Language
    C++
  • License
    GNU General Publi...
  • Created almost 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A tiny KV storage based on skiplist written in C++ language| 使用C++开发,基于跳表实现的轻量级键值数据库🔥🔥 🚀

👉 推荐 Gitee同步

版权申明: 本项目为我(程序员Carl)的原创。引用本项目文章请注明出处,例如:转自 https://github.com/youngyangyang04/Skiplist-CPP。 发现恶意抄袭或搬运,会动用法律武器维护自己的权益。让我们一起维护一个良好的技术创作环境!

English Version

KV存储引擎

众所周知,非关系型数据库redis,以及levedb,rockdb其核心存储引擎的数据结构就是跳表。

本项目就是基于跳表实现的轻量级键值型存储引擎,使用C++实现。插入数据、删除数据、查询数据、数据展示、数据落盘、文件加载数据,以及数据库大小显示。

在随机写读情况下,该项目每秒可处理啊请求数(QPS): 24.39w,每秒可处理读请求数(QPS): 18.41w

项目中文件

  • main.cpp 包含skiplist.h使用跳表进行数据操作
  • skiplist.h 跳表核心实现
  • README.md 中文介绍
  • README-en.md 英文介绍
  • bin 生成可执行文件目录
  • makefile 编译脚本
  • store 数据落盘的文件存放在这个文件夹
  • stress_test_start.sh 压力测试脚本
  • LICENSE 使用协议

提供接口

  • insertElement(插入数据)
  • deleteElement(删除数据)
  • searchElement(查询数据)
  • displayList(展示已存数据)
  • dumpFile(数据落盘)
  • loadFile(加载数据)
  • size(返回数据规模)

存储引擎数据表现

插入操作

跳表树高:18

采用随机插入数据测试:

插入数据规模(万条) 耗时(秒)
10 0.316763
50 1.86778
100 4.10648

每秒可处理写请求数(QPS): 24.39w

取数据操作

取数据规模(万条) 耗时(秒)
10 0.47148
50 2.56373
100 5.43204

每秒可处理读请求数(QPS): 18.41w

项目运行方式

make            // complie demo main.cpp
./bin/main      // run 

如果想自己写程序使用这个kv存储引擎,只需要在你的CPP文件中include skiplist.h 就可以了。

可以运行如下脚本测试kv存储引擎的性能(当然你可以根据自己的需求进行修改)

sh stress_test_start.sh 

待优化

  • delete的时候没有释放内存
  • 压力测试并不是全自动的
  • 跳表的key用int型,如果使用其他类型需要自定义比较函数,当然把这块抽象出来更好
  • 如果再加上一致性协议,例如raft就构成了分布式存储,再启动一个http server就可以对外提供分布式存储服务了

关于作者

大家好,我是程序员Carl,《代码随想录》作者,哈工大师兄,先后在腾讯和百度从事分布式技术研发。

More Repositories

1

leetcode-master

《代码随想录》LeetCode 刷题攻略:200道经典题目刷题顺序,共60w字的详细图解,视频难点剖析,50余张思维导图,支持C++,Java,Python,Go,JavaScript等多语言版本,从此算法学习不再迷茫!🔥🔥 来看看,你会发现相见恨晚!🚀
Shell
38,350
star
2

TechCPP

【C++面试&C++学习指南】 这里整理了C++后端研发工程师面试和工作必备的知识点 。
1,321
star
3

PowerVim

Make your vim more power and much easer.
Vim Script
1,116
star
4

Markdown-Resume-Template

BAT程序员自己的简历模板分享出来了 。技术简历追求简单明了,避免没有必要的花哨修饰,大家可以fork到自己仓库中,基于这个模板进行修改。
684
star
5

NoSQLAttack

NoSQLAttack is an open source Python tool to automate exploit MongoDB server IP on Internet and disclose the database data by MongoDB default configuration weaknesses and injection attacks.
Python
286
star
6

DesignPattern

This repository is built for design pattern in C++
C++
187
star
7

youngyangyang04

147
star
8

fileHttpServer

A simple file HTTP server, written in golang, that include get, put, post method to upload files
Go
130
star
9

Gomoku

五子棋对战游戏,支持多个client同时在线对战,由于游戏性质,使用典型的同步阻塞IO模型,多进程提供服务
C
82
star
10

NoSQLInjectionAttackDemo

NoSQLInjectionAttackDemo is website demo for test NoSQL Injection. There are two website demos in this project and all databases are mongoDB
CSS
40
star
11

NetworkDisk

【代码随想录知识星球】项目分享-基于Vue和Spring Boot等技术构建的前后端分离、分布式的网盘系统
Java
21
star
12

PowerSqlgen

Generate sqls to test mysql database
Shell
20
star
13

interview-master

面试大师
9
star
14

algorithm-interview-course

算法面试通关精讲
C++
8
star
15

Backend-Developer-Interview-Tutorial

史上最全的后端开发面试攻略
7
star
16

CS-Books

📚 计算机技术类书籍 PDF 最强总结
6
star
17

vssue

4
star
18

planeGame

my plane game
Java
3
star
19

codestyle

尽量不要写重复的代码
C++
3
star
20

RPC-Java

【代码随想录知识星球】项目分享-手撕RPC框架
2
star
21

KVstorageBaseRaft-cpp

【代码随想录知识星球】项目分享-基于Raft的k-v存储数据库
1
star
22

youngyangyang04.github.io

Carl Sun's BLOG
CSS
1
star
23

APPbackendFramework

A simple APP backend framework
PHP
1
star
24

Documents

This repository is for sharing my documents
1
star
25

test2

C
1
star
26

fileScan_1

Part of the OMS infrastructure. generates xml file by scan the local project, analyze the xml and download the bundle that the system need by scan properties file that include the many websites infomation.
Java
1
star