Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

将存储引擎中直接写 Rocksdb 的部分换成调用封装的 Batch 接口 #280

Open
27 of 70 tasks
longfar-ncy opened this issue Apr 15, 2024 · 1 comment
Open
27 of 70 tasks
Labels
✏️ Feature New feature or request

Comments

@longfar-ncy
Copy link
Collaborator

longfar-ncy commented Apr 15, 2024

为方便在 raft 模式和单机模式之间切换,所有的写命令底层在写 rocksdb 时应当采用我们封装的 Batch 接口。

参考PR:#285

修改方法:

参考上述PR,总结起来有四件事:

  1. 构造我们封装的 Batch ,不使用 rocksdb::Batch ;
  2. 把 put 和 delete 换成 Batch 接口的 put 和 delete;
  3. 调用 Batch 的 Commit 方法,并返回 Commit 方法的返回值
  4. 在 consistency_test.go 中增加简单的一致性测试

小技巧

对于第 2 点,也是最麻烦的地方,但可以用 vim 的替换来做,非常方便。
这里我把替换的命令放出来,只需要在命令模式下,在下边这行命令前边加上行号范围即可

  • vscode vim 插件:s/batch\.(\w+)\(handles_\[(\w+)\], (.+)\);/batch->\1(\2, \3);/gc
  • 原生vim:s/batch\.\(\w\+\)(handles_\[\(\w\+\)\], \(.\+\));/batch->\1(\2, \3);/gc

示例:如图,找到想要替换的函数的范围(行号),然后添加在上述命令前即可。比如我想要替换 LPushx 这个函数的写操作,找到开始行号和结束行号,然后在VIM中输入下边内容即可:

:356,387s/batch\.\(\w\+\)(handles_\[\(\w\+\)\], \(.\+\));/batch->\1(\2, \3);/gc

image

待做事项

// Strings Commands

  • Set

smj:

  • Append
  • Decrby
  • GetSet
  • Incrby
  • Incrbyfloat
    lh
  • MSet
  • MSetnx
  • Setxx
  • SetBit
  • Setex
    lft:
  • Setnx
  • Setvx
  • Delvx
  • Setrange
  • BitOp

// Hash

  • HDel
  • HSet

ncy:

  • HIncrby
  • HIncrbyfloat
  • HMSet
  • HSetnx

// Sets Commands

  • SAdd
  • SRem
    lh:
  • SDiffstore
  • SInterstore
  • SMove
  • SPop
  • SUnionstore

// Lists Commands

  • LPop
  • LPush

zzl:

  • LInsert
  • LPushx
  • LRem
  • LSet
  • LTrim

xd: (下周不来就分出去)

  • RPop
  • RPoplpush
  • RPush
  • RPushx

// Zsets Commands

  • ZAdd
  • ZRem
    csx: (下周不来就分出去)
  • ZIncrby
  • ZRemrangebylex
  • ZRemrangebyrank
  • ZRemrangebyscore

todo:
lh:

  • ZUnionstore
  • ZInterstore
  • ZPopMax
  • ZPopMin

// Keys Commands

  • StringsDel
  • HashesDel
  • ListsDel
  • ZsetsDel
  • SetsDel
  • StringsPKPatternMatchDel
  • ListsPKPatternMatchDel
  • HashesPKPatternMatchDel
  • ZsetsPKPatternMatchDel
  • SetsPKPatternMatchDel
  • StringsExpire
  • HashesExpire
  • ListsExpire
  • ZsetsExpire
  • SetsExpire
  • StringsExpireat
  • HashesExpireat
  • ListsExpireat
  • SetsExpireat
  • ZsetsExpireat
@longfar-ncy longfar-ncy added the ✏️ Feature New feature or request label Apr 15, 2024
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: Replace the part of the storage engine that directly writes Rocksdb with calling the encapsulated Batch interface to facilitate switching between stand-alone mode and Raft cluster mode.

@longfar-ncy longfar-ncy changed the title 将存储引擎中直接写 Rocksdb 的部分换成调用封装的 Batch 接口,方便在单机模式和 Raft 集群模式之间切换 将存储引擎中直接写 Rocksdb 的部分换成调用封装的 Batch 接口 Apr 16, 2024
happy-v587 added a commit to happy-v587/pikiwidb that referenced this issue May 17, 2024
AlexStocks pushed a commit that referenced this issue May 20, 2024
…nionstore command use new batch (#320)

issue: #280

Signed-off-by: HappyUncle <[email protected]>
happy-v587 added a commit to happy-v587/pikiwidb that referenced this issue May 26, 2024
happy-v587 added a commit to happy-v587/pikiwidb that referenced this issue May 26, 2024
happy-v587 added a commit to happy-v587/pikiwidb that referenced this issue May 26, 2024
happy-v587 added a commit to happy-v587/pikiwidb that referenced this issue May 26, 2024
happy-v587 added a commit to happy-v587/pikiwidb that referenced this issue May 26, 2024
AlexStocks pushed a commit that referenced this issue May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✏️ Feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants