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

Feature Proposal: Key Prefix Scan #154

Open
robbitt07 opened this issue May 29, 2022 · 0 comments
Open

Feature Proposal: Key Prefix Scan #154

robbitt07 opened this issue May 29, 2022 · 0 comments

Comments

@robbitt07
Copy link

Looking for similar prefix scan functionality like what is available in LevelDB or BadgerDB. Basically looking for the option to scan a set of prefixes.

    def prefix_iteritems(self, prefix: str):
        GET_ITEMS = 'SELECT key, value FROM "%s" WHERE key LIKE ? ORDER BY rowid' % self.tablename
        for key, value in self.conn.select(GET_ITEMS, (f"{prefix}%",)):
            yield key, self.decode(value)

Keys

"p:60606"
"p:64112"
"p:90210"

Query

db.prefix_iteritems("p:6")
>>> ("p:60606", "p:64112", )
db.prefix_iteritems("p:64")
>>> ("p:64112", )
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

No branches or pull requests

1 participant