You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today the key comparison function used by the database is bytes.Compare. In cases where we're dealing with fixed-size integer or ascii keys this makes a lot of sense, but I have a use case for using variable size integers as keys (similar to big.Int), and the order of the keys as defined by bytes.Compare is not the natural order of the integer values.
I'd like to explore modifying the package to make the comparison function configurable on a per-bucket basis, but I wanted to get feedback from someone more familiar with the implementation in case there were any major concerns.
The text was updated successfully, but these errors were encountered:
Gonna spitball some stuff here and maybe try to test it, but it seems like it would be as simple as having the bucket struct have a new member (func(a, b []byte)int) that will default to bytes.Compare, but setable with a new CreateBucket func, then passing that func into the cursor struct when you make a cursor. cursor will then reference its stored comparison func instead of always using bytes.compare. Does anyone think there's something missing with all that?
EDIT: Persisting the comparison function will be an issue. the responsibility COULD be placed on the user, and they would have to keep track of which buckets use which comparison function and pass it in each time they open the bucket. I think a better way, though unsure how to do it, would be to copy the comparison function to the disk with the bucket and load it from there when the bucket is opened. Currently unaware of any way to do that though
Hello,
Today the key comparison function used by the database is
bytes.Compare
. In cases where we're dealing with fixed-size integer or ascii keys this makes a lot of sense, but I have a use case for using variable size integers as keys (similar to big.Int), and the order of the keys as defined bybytes.Compare
is not the natural order of the integer values.I'd like to explore modifying the package to make the comparison function configurable on a per-bucket basis, but I wanted to get feedback from someone more familiar with the implementation in case there were any major concerns.
The text was updated successfully, but these errors were encountered: