Closed AlgorithmsAreCool closed 4 years ago
As far i can tell without compiling code it's all matter of this class https://github.com/CoreyKaylor/Lightning.NET/blob/master/src/LightningDB/Native/ValueStructure.cs
We can add method ReadOnlySpan<byte> GetSpan()
with body like this (not tested and even compiled):
public ReadOnlySpan<byte> GetSpan()
{
return new Span<byte>(data.ToPointer(), size.ToInt32());
}
I think it should work. I'll try to compile this in a free moment and push PR
I'm not sure if we should expand api with call like "GetSpan" or just override default get? I think main contributors should make that decision
Seems like this repo is quite dead. If you are looking for really performant LMDB adapter use this https://github.com/Spreads/Spreads.LMDB . I'm using it on production. On .NET Core 2.1 (full Span/Memory support) allocations are really rare, it's super awsome. Using it is quite cumbersome (you need to pin everything that talks with database) but it's really worth it
Long overdue, but first pass is on master now b048931dc3a. More API changes coming but using Span definitely makes things nicer. No perf comparisons yet.
@CoreyKaylor I've got some more free time these days, can i help with anything?
@AlgorithmsAreCool I've added a few up for grabs issues. Let me know if you're interested in any of them. Not exhaustive, but those are the immediate ones that come to mind.
Now that System.Memory is available, .NET has a way to get closer to the 0-copy read/write semantics of LMDB.
Do you think providing Span overloads for operations if a good fit for this library? If so I'd be willing to get some PRs going to support it.