Skip to content

feat: subtree pairs iterator#12

Merged
QuantumExplorer merged 4 commits into
masterfrom
subtree-pairs-iterator
Dec 26, 2021
Merged

feat: subtree pairs iterator#12
QuantumExplorer merged 4 commits into
masterfrom
subtree-pairs-iterator

Conversation

@fominok
Copy link
Copy Markdown
Contributor

@fominok fominok commented Dec 22, 2021

This PR contains two changes:

Path compression

It alters how path compression works, previously collisions may occur for cases like [a, ab] vs [aa, b], also subtree keys shared the same prefix as parent trees which is harmful for iteration over subtree elements as there is no way to find out where to stop, now they're not.

New path compression algorithm (for subtree key):

  1. Concat all path segments as before
  2. Append number of segments
  3. Append lengths of each segment
  4. hash it

Subtree elements' keys use the same approach, but appending their key after hashing happened, this way their order is preserved and they're located sequentially in DB.

Subtree elements iterator

This allows for a given subtree to iterate over key-value pairs sorted by key, values are Element object

@fominok fominok changed the title [WIP] feat: Subtree pairs iterator feat: Subtree pairs iterator Dec 23, 2021
@fominok fominok marked this pull request as ready for review December 23, 2021 18:16
@fominok fominok force-pushed the subtree-pairs-iterator branch from 9bd3b16 to faae8ae Compare December 24, 2021 09:13
@shumkov shumkov changed the title feat: Subtree pairs iterator feat: subtree pairs iterator Dec 24, 2021
@QuantumExplorer QuantumExplorer merged commit 9f63168 into master Dec 26, 2021
@QuantumExplorer QuantumExplorer deleted the subtree-pairs-iterator branch December 26, 2021 04:18
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