Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix readDataAndKeys #27

Merged
merged 2 commits into from
Oct 20, 2023
Merged

Conversation

dannynorth
Copy link
Contributor

A bug exists in readDataAndKeys (#24) where requesting non-existent keys will cause subsequent keys to be associated with the wrong data.

This fixes that.

The SQLiteStorageEngineTest succeeds, because its implementation of `readDataAndKeys` does not rely on the fault logic inherited from the default implementation on `StorageEngine`

The DiskStorageEngineTest fails. Only five keys exist in the database (`0`, `1`, `2`, `3`, and `4`). However, 10 get requested in reverse order. The faulty logic means that key `9` gets the data associated with key `4`, key `8` with key `3`, and so on down to key `5` getting the data meant for key `0`. This means that comparing the returned _keys_ fails, but the comparing the returned _data_ succeeds.

The ObjectStorageTest fails, for similar reasons. It is also using `zip()` to construct the returned array, blindly assuming that the object retrieved for each key exists.
Fixes mergesort#24

Using `zip()` loses the association between keys and values, because the array returned from `read(keys:)` does not provide information about _skipped_ keys (See mergesort#26).
@mergesort
Copy link
Owner

This is a great catch, thank you so much @dannynorth!

@mergesort mergesort merged commit a415bc2 into mergesort:main Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants