This PR adds WriteBatch.PutVector methods as a developer-friendly wrapper of the existing Putv/PutvCf. fixes #22
There are also overloads that take a single key and a params array of values. Obviously, you can't have multiple params arrays in a method, it seemed to me that it was more likely to have a value vector than a key vector. Also, I provided overloads with and without ColumnFamilyHandle parameter since you can't have default value parameters after a params parameter.
As per comment on #22, the code only uses stackalloc for list/istSizes when the vector is less than 256 items. For vectors 256 items or longer, the code uses a rented array. The code is a little more complex than I would have wanted due to C# limitations on Span<T> and stackkalloc.
There aren't any tests in this project. I've tested similar code in my own library that uses rocksdb-sharp, but it doesn't have vectors larger than 256 so that code remains untested.
BTW, would it make more sense to add helper methods like this as extension methods? Given the nature of this library as a native code wrapper, there's little difference between extension and "normal" methods, so maybe it's not worth it.
This PR adds
WriteBatch.PutVector
methods as a developer-friendly wrapper of the existingPutv
/PutvCf
. fixes #22There are also overloads that take a single key and a
params
array of values. Obviously, you can't have multiple params arrays in a method, it seemed to me that it was more likely to have a value vector than a key vector. Also, I provided overloads with and without ColumnFamilyHandle parameter since you can't have default value parameters after aparams
parameter.As per comment on #22, the code only uses stackalloc for list/istSizes when the vector is less than 256 items. For vectors 256 items or longer, the code uses a rented array. The code is a little more complex than I would have wanted due to C# limitations on
Span<T>
andstackkalloc
.There aren't any tests in this project. I've tested similar code in my own library that uses rocksdb-sharp, but it doesn't have vectors larger than 256 so that code remains untested.
BTW, would it make more sense to add helper methods like this as extension methods? Given the nature of this library as a native code wrapper, there's little difference between extension and "normal" methods, so maybe it's not worth it.