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

WIP: Lexicographic iteration #104

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

andrewosh
Copy link
Collaborator

@andrewosh andrewosh commented Apr 19, 2018

This PR includes a couple of changes to make lexicographic iteration possible (relevant discussion here #78). Once supported, we should be able to create useful things like a leveldown implementation based on hyperdb.

Summary of changes:

  1. The approach to path construction in lib/hash.js has been modified to support variable-length paths. Each path component is separated by a separator value instead of being fixed-length.
  2. lib/iterator.js and lib/put.js have been lightly modified to a) remove hard-coded values and b) make non-recursive iteration respect the path separator.

Some things to consider before this can be merged:

  1. The hashing scheme for path components should probably be configurable, but the variable-length path approach works regardless of hashing scheme (i.e. for lexint, you don't want to hash the path, but if you don't need lex iteration then you'll likely want to get the benefits that come with the hash-based approach).
  2. The hashing scheme will need to be included in a metadata record (TBD), since if affects lookups -- replication between two dbs with different schemes would be problematic, for example.

Note: This is still WIP, and the above issues need to be addressed before merging.

@andrewosh
Copy link
Collaborator Author

This PR has been updated with support for a top-level lexint flag. When enabled, paths will be constructed without any hashing, and iteration will thus be lexicographically ordered. When disabled, path components will be hashed (as in current master).

Storing a db's path configuration (is there a better term for this?) in a header is still in the works.

@andrewosh
Copy link
Collaborator Author

Some wires got crossed and I was referring to "lexicographic iteration" as lexint, which is lexicographic integer! This PR will be updated to rename lexint -> lex

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.

1 participant