Iterator Item Copy

I have a fork of Badger that implements a Item.Copy() mechanic, where the Item comes from iterator.Next().

At the moment, each item is only valid within a Next() call, as the object is re-used between iterations.

However, I wanted to copy the item struct, so that I can call item.ValueCopy() at some future point, but still within the same transaction. This was driven by the fact that calling item.ValueCopy() is faster then db.Get(key) since the item contains the valueptr which points to where we can get the value in the value log. Without having to traverse the various trees/levels like what happens when you call db.Get(key).

My question is: Would something like this item.Copy be an interesting feature to have on badger enough for me to open up a PR?
I’d prefer to not use a fork forever, and have this functionality in the main repo.

Please let me know :slight_smile:

PS: Here are the changes in question, relatively simple/straight forward.

What version of Go are you using (go version)?

$ go version
1.18

What operating system are you using?

Ubuntu via WS1 on Windows 10

What version of Badger are you using?

v3

Does this issue reproduce with the latest master?

Feature request, N/A