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

Support 'prefix_extractor' option? #160

Open
webbery opened this issue May 8, 2020 · 5 comments
Open

Support 'prefix_extractor' option? #160

webbery opened this issue May 8, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@webbery
Copy link

webbery commented May 8, 2020

I look at the source code and find none about 'prefix_extractor'.
Will rocksdb support 'prefix_extractor' option?

@vweevers
Copy link
Member

vweevers commented May 10, 2020

A PR is welcome. I don't know what prefix_extractor is and what kind of API it would require, so it'd be best to discuss that before opening a PR, so that we can assess the complexity.

@vweevers vweevers added the enhancement New feature or request label May 10, 2020
@MeirionHughes
Copy link
Member

MeirionHughes commented Apr 22, 2021

From the looks of things there are three options, via classes:

  • FixedPrefixTransform takes integer opt
  • CappedPrefixTransform takes integer opt
  • SamePrefixTransform takes string opt

Not sure whether SamePrefixTransform is enabled - its hidden behind a GFLAGS macro check, which is not defined according to my vscode. Its also in a test file - prefix_test.cc

presumably this could be exposed to the js side as

options: {
  ...
  prefix_extractor? : {
    fixed?: number,
    capped?: number,
    same?: string
  } 
}

where ? is optional notation and only 1 of them should be be defined.

on the binding side (db_open), it would require checking which is defined (if any), and mapping to the corresponding class;

i.e.

options.prefix_extractor.reset(NewFixedPrefixTransform(2));

before being sent to the open the db.

@vweevers
Copy link
Member

What does it do?

@MeirionHughes
Copy link
Member

Not 100% sure - but it seems it can optimize seeking/iterating when you're doing composite keys. https://github.com/facebook/rocksdb/wiki/Prefix-Seek#defining-a-prefix

@MeirionHughes
Copy link
Member

I don't need this tbh - but I fancied having a gander at the code-base and tried to add it. #168

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants