Why use slice as immutable memtable type?


(Yijun Zhao) #1

Hello everyone, my question is here(https://github.com/dgraph-io/badger/blob/master/db.go#L67) why imm is a slice of skiplist instead of one skiplist?

I see here(https://github.com/dgraph-io/badger/blob/master/db.go#L850) make sure imm just pick one element every time (edited)

So why not use db.imm = db.mt instead of db.imm = append(db.imm, db.mt) ? (edited)

I see Leveldb use db.imm = db.mt style. (edited)

Sorry for my pool English, I hope you know what I mean…


(Manish R Jain) #2

There is not just one, but many immutable tables, which are waiting to be flushed to disk. That’s why it’s a slice. You can control how many they can be here:


(Yijun Zhao) #3

Got it, thanks for reply.