-
Notifications
You must be signed in to change notification settings - Fork 636
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
Merge() seems to have a bug #258
Comments
In version 2.2.3, the Iterator method has been removed. Why? |
@Jeremy-Run After updating to version 2.2.3, the execution result remains unchanged, and the issue doesn't seem to be resolved. |
Sorry, I pulled the wrong branch, my bad. |
@taroim pr hasn't been merged into the main branch yet, wait for @roseduan review. |
The iterator replies on the IRadix data structure, but after our tests, the IRadix will occupy lots of memory when the database grows larger. So we decide to use BTree as the memory data structure instead of IRadix. So next release the iterator will be removed, if you have any troubles, please feel free to give us feedback. |
This problem has been resolved, please update to the latest commit, thanks. @taroim |
It's usable, thank you. |
package main
import (
"fmt"
"github.com/rosedblabs/rosedb/v2"
"github.com/rosedblabs/rosedb/v2/utils"
)
func main() {
options := rosedb.DefaultOptions
options.DirPath = "./tmp/rosedb_merge"
// merge after insert
db, err := rosedb.Open(options)
if err != nil {
panic(err)
}
for i := 0; i < 10; i++ {
_ = db.Put([]byte(utils.GetTestKey(i)), utils.RandomValue(100*1024))
}
_ = db.Merge(true)
_ = db.Close()
// merge after deletion
db, err = rosedb.Open(options)
if err != nil {
panic(err)
}
fmt.Printf("KeysNum=%v, DiskSize=%.2fMiB\n", db.Stat().KeysNum, float64(db.Stat().DiskSize)/1024/1024)
for i := 0; i < 10; i++ {
_ = db.Delete([]byte(utils.GetTestKey(i)))
}
_ = db.Merge(true)
_ = db.Close()
// open statistics again
db, err = rosedb.Open(options)
if err != nil {
panic(err)
}
fmt.Printf("KeysNum=%v, DiskSize=%.2fMiB\n", db.Stat().KeysNum, float64(db.Stat().DiskSize)/1024/1024)
_ = db.Close()
} First Execution Result: Second Execution Result: |
I will fix it later. |
I have fixed this in the latest commit, enjoy! Feel free to give us any feedback, thanks. |
OK, thanks. |
执行结果:
KeysNum=0, DiskSize=0.00MiB
KeysNum=10, DiskSize=0.98MiB
KeysNum=10, DiskSize=0.00MiB # 请注意:此处 KeysNum 应该为 0
问题描述:
Put 数据后执行 Merge(),然后 Delete 数据后再执行 Merge(),这时候就会出现所有的 Key 都还在!?
The text was updated successfully, but these errors were encountered: