Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why this should be merged
Direct optimization:
startKey
and/orprefix
Indirect optimization
Fixes:
getChangesToGetToRoot(..)
no-ops being removed from outputHow this works
changeSummary
struct has a new field for having the changed keys in a sorted slicegetChangesToGetToRoot(..)
-> by having thesortedKeys
, we can search (binary search) for thestartKey
, and also easily stop iterating when we are afterendKey
.getValueChanges(..)
-> we can easily get change values betweenstartRoot
andendRoot
, with keys within[startKey, endKey]
in the following way:changes
,insertNumber
andindex
. Min => the root with the min key and min insertNumber (in this way, by popping out of the minheap, we traverse all the keys in ASC order by[key, insertNumber]
)[startKey, endKey]
, and push that initial state of each root into the heap (or not, if there are no keys inside that interval).IMPORTANT improvement for getValueChanges(..): we can stop whenever there are
maxLength
key changes found.How this was tested
Using the existing unit tests.
Adding new unit tests, or modifying existing ones to properly cover the new code.