-
Notifications
You must be signed in to change notification settings - Fork 7
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
Make ordinary indexes store their keys unsliced #659
Conversation
= do | ||
#ifdef NO_IGNORE_ASSERTS | ||
maybeLastLastKey <- Growing.readMaybeLast lastKeys | ||
assert (all (< key) maybeLastLastKey) $ return () | ||
maybeLastUnslicedLastKey <- Growing.readMaybeLast unslicedLastKeys | ||
assert (all (< key) (fromUnslicedKey <$> maybeLastUnslicedLastKey)) | ||
(return ()) | ||
#endif | ||
Growing.append lastKeys pageCount key | ||
Growing.append unslicedLastKeys pageCount (makeUnslicedKey key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something along these lines would fix the compiler error with assertions disabled
= do
let !key' = makeUnslicedKey key
#ifdef NO_IGNORE_ASSERTS
maybeLastUnslicedLastKey <- Growing.readMaybeLast unslicedLastKeys
assert (all (< key') maybeLastUnslicedLastKey)
(return ())
#endif
Growing.append unslicedLastKeys pageCount key'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What compiler error do you get here? I can’t see an error in this code, and commenting out the #ifdef
–#endif
part doesn’t cause GHC to show me an error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see: When removing both assertion blocks, there is an unused import. I had a similar issue in the same module with readMaybeLast
, which I solved by a conditional import. I can just move the import of fromUnslicedKey
into the conditional block with the readMaybeLast
import.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can just move the import of
fromUnslicedKey
into the conditional block with thereadMaybeLast
import.
Done in dd6b71c.
= assert (firstKey <= lastKey) $ | ||
do | ||
#ifdef NO_IGNORE_ASSERTS | ||
maybeLastLastKey <- Growing.readMaybeLast lastKeys | ||
assert (all (< firstKey) maybeLastLastKey) $ return () | ||
maybeLastUnslicedLastKey <- Growing.readMaybeLast unslicedLastKeys | ||
assert | ||
(all (< firstKey) (fromUnslicedKey <$> maybeLastUnslicedLastKey)) | ||
(return ()) | ||
#endif | ||
Growing.append lastKeys 1 lastKey | ||
Growing.append unslicedLastKeys 1 (makeUnslicedKey lastKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my suggestion for appendMulti
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, I didn't mean to approve just yet
Let's squash before we merge |
dd6b71c
to
84f5ca5
Compare
Previously, the keys stored in ordinary indexes and ordinary-index accumulators were of type
SerialisedKey
, and the append operations for ordinary-index accumulators did not truncate keys that were represented as slices of larger byte sequences to their actual payloads. This pull request changesIndexOrdinary
andIndexOrdinaryAcc
to useUnsliced SerialisedKey
for storing keys, so that it is guaranteed that only actual key contents are stored.