Spreads / Spreads.LMDB

Low-level zero-overhead and the fastest LMDB .NET wrapper with some additional native methods useful for Spreads
http://docs.dataspreads.io/spreads/libs/lmdb/api/README.html
Mozilla Public License 2.0
80 stars 9 forks source link

Issue with multiple data write #8

Closed jakoss closed 6 years ago

jakoss commented 6 years ago

Hi,

Could you help me out with and issue i'm having.. For the purpose of SoundFingerprinting algorithm i'm trying to use multiple data as Dictionary<int, Set<ulong>>() and (i far as i understandard LMDB) that it should work this way. But i found an use case when written values are just.. wrong. And i can't find out why is that happening. If you could take a look at this code (it's full issue reproduction in xunit test) SpreadsLMDBBugRepro.zip

buybackoff commented 6 years ago

Line 126: if (cursor.TryGet(ref key, ref value, CursorGetOption.***Set***).

CursorGetOption.First:

Position at first key/data item

CursorGetOption.Set:

Position at specified key

CursorGetOption.FirstDuplicate:

Position at first data item of current key. Only for MDB_DUPSORT

Looks like First is absolute, you need to Set to your key.

jakoss commented 6 years ago

Thanks! Frankly i wouldn't find out that myself. Cursors in LMDB are really confusing

buybackoff commented 6 years ago

You need to read the docs as a legal document and make no assumptions. It actually behaves exactly like documented. But some explanation redundancy in cursors behavior would be nice, have to learn by trial & error often.