bmatsuo / lmdb-go

Bindings for the LMDB C library
BSD 3-Clause "New" or "Revised" License
158 stars 59 forks source link

PutMulti does not return the number of items written #103

Open bmatsuo opened 7 years ago

bmatsuo commented 7 years ago

When MDB_MULTIPLE is given to the mv_data field on the "length" parameter is set to the number of bytes written. Presumably items are written in page order (which is not necessarily sorted order from my experimentation). It's not clear exactly whether this is supposed to interplay with another flag like MDB_NOOVERWRITE or merely with errors like MDB_MAP_FULL.

From the official docs:

MDB_MULTIPLE - store multiple contiguous data elements in a single request. This flag may only be specified if the database was opened with MDB_DUPFIXED. The data argument must be an array of two MDB_vals. The mv_size of the first MDB_val must be the size of a single data element. The mv_data of the first MDB_val must point to the beginning of the array of contiguous data elements. The mv_size of the second MDB_val must be the count of the number of data elements to store. On return this field will be set to the count of the number of elements actually written. The mv_data of the second MDB_val is unused.

For backwards compatibility I can't change the signature of PutMulti. However for #99 I was probably going to add a new function for writing Multiple values. So it would make sense to address this issue with that new function.