node-lmdb icon indicating copy to clipboard operation
node-lmdb copied to clipboard

64bit key support with bigints

Open matthewaveryusa opened this issue 6 years ago • 2 comments

As discussed in #111. I didn't implement defaulting bigints to buffers since there's no easy v8 api to transform a bigint into an array of bytes. I'm guessing v8 doesn't expose such an API to avoid making an opinionated choice on how to store signed numbers in binary format (the logical options being either twos compliment or signbit+unsignedbytes.)

With that in mind I think the correct approach is to allow users to choose how they want to serialize bigints. The obvious easy answer it to use the toString() method at the cost of some extra memory and ordering, or to store the data as a binary key by doing Buffer.from(1n.toString(16),'hex') if they are unsigned bigints, and coming up with a sign-ness encoding/decoding if they are signed.

matthewaveryusa avatar Mar 29 '19 19:03 matthewaveryusa

Sorry for the late reply. Will review this as soon as I can.

Venemo avatar May 23 '19 12:05 Venemo

No worries. This patch will need some reworking as it touches the same areas in the codebase as the async pull request #150

matthewaveryusa avatar May 24 '19 14:05 matthewaveryusa