Closed danielcrenna closed 4 years ago
Yes, we are looking at updating the cursor API, we should have something "soon™".
Just curious, what kind of keys do you generally use? Integers? Strings? blobs?
Almost always it's a composite string key prepared with Encoding.UTF8.GetBytes
because it's easier to build keys for lexicographical streaming that way, but I'd like to reduce these allocations, even an LRU cache on this still means I'm holding a large bag of byte buffers.
Yep, we should be able to quash those allocations easily.
Also, I'm assuming you mean keeping keys implicitly sorted in lexicographic order. Maybe we can optimize for this use case. A little stackalloc goes along way
I have a bunch of the changes made locally. I'll push up a PR in the next day or two. Had a little bit of a tangent when I thought I found a bug in the underlying native library, but select isn't broken so I should be able to move forward again.
@AlgorithmsAreCool yeah, so what I was intending to do was to store prefixes and key segments in contiguous ranges, so that I could produce a prefixed key without having to allocate memory. I've done this just with a fake "RangeSpan
Any suggestions for the PutMultiple overload?
@CoreyKaylor thanks for this, API looks really solid. cursors took more time to refactor but it's better off.
@danielcrenna thanks for the comment. Always nice to hear some positive feedback.
Methods like
cursor.MoveTo(byte[] key)
and similar all call private methods that cast thebyte[]
parameter to aReadOnlySpan<byte>
.Can we get overloads (or replacements) that take the
ReadOnlySpan<byte>
directly?This would save unnecessary allocations.