rosedblabs / rosedb Goto Github PK
View Code? Open in Web Editor NEWLightweight, fast and reliable key/value storage engine based on Bitcask.
Home Page: https://rosedblabs.github.io
License: Apache License 2.0
Lightweight, fast and reliable key/value storage engine based on Bitcask.
Home Page: https://rosedblabs.github.io
License: Apache License 2.0
Hello,
Using: go version go1.16 windows/amd64
I just tried to build RoseDB, but have errors:
C:\goprojects\src\RoseDB\test>go build cmd\server\main.go
cmd\grpc_server.go:6:2: no required module provides package github.com/roseduan/rosedb/cmd/proto; to add it:
go get github.com/roseduan/rosedb/cmd/proto
C:\goprojects\src\RoseDB\test>go get github.com/roseduan/rosedb/cmd/proto
go get github.com/roseduan/rosedb/cmd/proto: no matching versions for query "upgrade"
使用mmap方式set一个kv,在0.data.str文件中会写入一个二进制entry;再次使用mmap set一个kv,该kv会写入1.data.str文件的开头,而不是继续在0.data.str中继续写入。
这导致16mb的0.data.str文件中,只有一个entry,剩余绝大部分空间都没有使用。并且每set一次不同的k,就会多一个文件。
文件offset数值错误。这发生在NewDBFile方法中的mmap逻辑中:
一开始我们让offset相当于文件的大小,但其实Truncate会将文件以'\0'填满,所以对于mmap来说,offset永远指的是文件固定大小,而不是实际entry要存储的位置。
由于存储逻辑中,会根据offset判断文件容量达到上限创建新文件存储entry,这就导致set新的k,会创建新的文件。
stat, err := file.Stat()
if err != nil {
return nil, err
}
df := &DBFile{Id: fileId, Path: path, Offset: stat.Size(), method: method}
if method == FileIO {
df.File = file
} else {
if err = file.Truncate(blockSize); err != nil {
return nil, err
}
m, err := mmap.Map(file, os.O_RDWR, 0)
if err != nil {
return nil, err
}
df.mmap = m
}
hint file 是 bitcask 中对于启动时,建立索引的一种优化手段。
如果 db 存在大量的数据文件,那么再次打开 db 时,必须重新扫描所有数据文件重建索引,这样的效率是十分低下的,因此 bitcask 提出了 hint file 保存索引文件来帮助 db 进行快速启动。
本人自告奋勇想为 rosedb 实现 hint file 这个 feature,故开此 issue 来听取大家意见,为 rosedb 略尽绵薄之力。
getset应该是原子操作吧,这么实现并发读写就有问题了
rosedb has reached 1k stars after first commit in 2020.12.06 👏
This is awesome, thanks for your support, I will continue to do it better.
There are no Test methods for some API in rosedb, you can add test cases according to the existed.
And you can also add some example code to show users how to use rosedb(under examples
dir).
https://github.com/flower-corp/rosedb/tree/main/examples
This kind PRs only aims to let you deep into rosedb and understand more about how it works.
The commands in rosedb are most similar to Redis, our goal is to support the most frequently used commands in Redis, and make sure the command does not exist in rosedb before you add it.
Redis commands docs: https://redis.io/commands
If an issue is marked with good first issue
, it is suitable for newcomers, you can pick one which you are interested in or good at.
Now rosedb has supported Redis protocol, but some commands are missed, so you can add the command:
supportedCommands
in cmd/cli.go, which lists all supported commands and its handler functionIf an issue is marked with bug
or enhancement
, which means bug fix or add/enhance features, you might have to understand completely rosedb to solve it.
every issue is marked with its difficulty(easy, medium, hard
), you can pick them according to your understanding of rosedb, and if you have any problems, contact me as soon.
环境
protoc-gen-go v1.27.1
protoc v3.19.1
go1.173
windows生成pb文件命令
protoc --go-grpc_out=. cmd/proto/rosedb.proto
protoc --go-grpc_out=. cmd/proto/pb_set.proto
protoc --go-grpc_out=. cmd/proto/pb_hash.proto
protoc --go-grpc_out=. cmd/proto/pb_zset.proto
protoc --go-grpc_out=. cmd/proto/pb_str.proto
protoc --go-grpc_out=. cmd/proto/pb_list.proto
高版本可能会遇到下面错误
参考文章
grpc with mustEmbedUnimplemented*** method
mustEmbedUnimplemented*** method appear in grpc-server
protoc-gen-go-grpc: program not found or is not executable
因此解决方案
protoc --go-grpc_opt=require_unimplemented_servers=false --go-grpc_out=. cmd/proto/rosedb.proto
protoc --go-grpc_out=. cmd/proto/rosedb.proto
protoc --go-grpc_out=. cmd/proto/pb_set.proto
protoc --go-grpc_out=. cmd/proto/pb_hash.proto
protoc --go-grpc_out=. cmd/proto/pb_zset.proto
protoc --go-grpc_out=. cmd/proto/pb_str.proto
protoc --go-grpc_out=. cmd/proto/pb_list.proto
for example,if I print the command : "set hello world",When the number of spaces between 'hello' and 'world' exceeds one, an error occurs。This is because spaces occupy the length of a parameter, and the number of parameters in the code is limited to two. In order to solve this problem, you should remove spaces from the input parameters before judging
rosedb 目前还非常的不完善,因此我希望有更多的人可以参与进来,不管你是 DB 的爱好者,或者是专家,甚至刚入门的小白,其实都能够对 rosedb 进行相关的贡献。
目前项目还比较缺人,如果有意愿的话,欢迎加我 vx:kiss_duan 进行交流!
我想尝试一下 grpc 方式操作 rosedb,但是 grpc.ClientConnInterface 这个应该怎么通过 grpc 获取到。
// 这个 conn 是 grpc.ClientConn()
conn ,err := grpc.Dial("127.0.0.1:5300", grpc.WithInsecure)
if err !=nil{
return
}
defer conn.Close()
// 这里 NewRosedbClient() 需要传入 grpc.ClientConnInterface
cli := proto.NewRosedbClient()
我在B站上刷到你的视频,对这个项目非常感兴趣,能不能在readme里面添加上你这个项目的参考论文,我挺想拜读一下源论文的,万分感谢。
如果希望list、set、hash、zset 接口支持interface, 那么是否需要在编码函数即EncodeValue函数中,支持多类型的编码,同时在list、set、hash、zset 的结构体内将支持String的结构 修改为 interface{} 结构 ?
你是一个非常优秀的人才,愿意来京东做相关的存储技术开发吗? 联系我微信18702995996
func TestRoseDB_GetSet(t *testing.T) {
t.Run("1", func(t *testing.T) {
err := roseDB.Set(123, 456)
assert.Empty(t, err)
var res int
err = roseDB.GetSet(123, 567, &res)
assert.Empty(t, err)
assert.Equal(t, res, 456)
var r2 int
err = roseDB.Get(123, &r2)
assert.Empty(t, err)
assert.Equal(t, r2, 567) // will raise a bug r2 = 456 not 567
})
t.Run("2", func(t *testing.T) {
var res interface{}
err := roseDB.GetSet(123, 222, &res)
assert.Equal(t, err, nil)
})
}
beacause for r2 get. it get data from cache. but 567 not write into cache
this bug i can fit it.
Now, can't set the expiration time for set / list / Zset / hash yet?
"github.com/roseduan/rosedb/cmd/proto"
找不到
proto.RegisterRosedbServer(s, g)
Do I understand correctly in that RoseDB is embeddable for key-value systems?
Do you have any simple examples?
If so, then I think that I might like to try it in m current P2P Cord code system to see how it performs across a number of nodes.
Thanks.
This is a todo list that we are doing or prepare to do, you can pick a few yuo are interested in, and create a new issue, tell what you think, and receive some advices from other people.
Then you can give us a PR!
Urgent and have to do:
Not urgent do it selectively:
When the client exits, even if the server cannot exit directly, it should prompt the server to be disconnected after performing other operations such as "press enter".
想请问一下是否有支持位图数据结构的计划?
目前 rosedb 当中的一些方法是没有对应的 Test 方法的,你可以按照已有的 Test,来为方法添加单元测测试。rosedb 下有一个 examples 目录,向用户展示 rosedb 的使用方法,你可以往其中添加一个方法。
这类 Pr 没有太多的技巧可言,只是为了让你熟悉整个 Pr 的流程,并且能够对 rosedb 中的一些方法有所认识,对 rosedb 的数据读写流程有更进一步的理解。
rosedb 支持的命令目前大致是按照 redis 来添加的,我们做到能够支持 redis 大多数常用的命令即可,做之前要确认一下这个命令在 rosedb 当中是不存在的。
尽量选择 redis 一些常用的命令,不常用的可以暂时不支持。
如果一个 issue 被标识为了 good first issue
,则说明这个 issue 也很适合新手参与,你可以按照自己的情况选择自己感兴趣或擅长的。
目前 rosedb 支持了 redis 协议,但是对应的方法并不完整,你可以为 rosedb 添加一个对应的 redis 协议的方法,具体做法是:
supportedCommands
变量,这里是所有支持的命令及其对应的处理方法supportedCommands
中增加这个方法的名称,并添加对应的处理方法说明:redis 协议的方法的输出尽量和原生 redis 保持一致
如果有一些 bug 或者新的功能,或是对已有功能进行完善,这类 issue 会被标识为 bug
或 enhancement
,这类问题可能稍微复杂点,需要你对 rosedb 整体的流程更加熟悉。
每个 issue 都标识了该问题的难易程度(easy、medium、hard
),你可以根据自己对 rosedb 的了解程度,选择适合自己的,对于任何问题或者 issue,在做之前,或者做的过程当中有问题的话,都可以提出来和我交流。
merge不加锁么,merge的时机是啥时候啊,merge的时候是要完全停止读写么
我的代码如下:
import (
"context"
"fmt"
"github.com/roseduan/rosedb/cmd/proto"
"google.golang.org/grpc"
)
func run() {
ctx := context.Background()
conn, err := grpc.DialContext(ctx, "127.0.0.1:5300", grpc.WithInsecure())
if err != nil {
return
}
defer conn.Close()
cli := proto.NewRosedbClient(conn)
var s proto.GetReq
s.Key = []byte("myk")
var opt grpc.CallOption
// 这里会报空指针错误。
test, err := cli.Get(ctx, &s, opt)
if err != nil {
return
}
fmt.Println(test.Dest)
}
项目中有关于parser一类的代码嘛?
bitdask模型应该只是时候用于大value,或者value存小文件的场景吧,而且就算用跳表做了索引,但是范围查询的时候,还是每个value的读取都是一次随机磁盘读,比mysql的“一次读一个页”到内存差很多啊,这样实现性能太差了,这样实现的话,感觉还不如退化成b+树的mysql呢
What do you think about adding GitHub Actions to the repository? At least, it can be basic like only builds and tests. GitHub provides the templates for the Go language.
Hello,
I have just come across RoseDB and think that it might be what I need for a project that I am working on.
One thing that I am needing is to develop for a P2P solution for the database with high number of nodes and am wondering about what it might take to have simple sharding added to RoseDB so that it can do high node clustering and spread out the data across all nodes as needed?
是否可以罗列一下现在已经实现的 redis-cli 命令,和未实现的命令。
我想尝试实现一些 redis-cli 命令,不知道这个项目是否有规划。
cmd/cmd_str.go:159:38: cannot use uint32(seconds) (value of type uint32) as int64 value in argument to db.Expire
建议使用golangci-lint去避免简单错误。
重启项目时事务id将会从最后一次成功的事务id开始递增,如果最后一次成功事务之后存在失败的事务,则会造成id重复
If I am not mistaken, the docs link on the README page points not to the latest docs. Eg this change is not in the package docs
4385873#diff-712e9efa3ee43d5b7429d9682aebe50c2011eeb91b7f8af793d9313df6cf9f02
Just so you know - great project, thanks a lot for this.
请问,有测试过在各平台上(Linux/Windows)突然断电或者程序突然结束的情况下的表现吗?
现在手上有个项目在用badgerdb,但是在Windows下突然断电或者退出程序会导致数据库损坏无法启动,正在找一个替换的方案。
KeyOnlyMemMode只支持Str模式,其他模式(List、Hash、Set、ZSet)只是通过磁盘写日志来保证数据不丢失,Value都是存储在内存中的,在Value值很大的时候,可能容易造成内存不足的问题。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.