-
Notifications
You must be signed in to change notification settings - Fork 55
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
Add filters and reverse ordering in Noter and Notifier #816
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -581,6 +581,37 @@ def getAllItemIter(self, db, key=b'', split=True, sep=b'.'): | |
splits = (bytes(key), val) | ||
yield tuple(splits) | ||
|
||
def getAllItemRvsdIter(self, db, key=b'', split=True, sep=b'.'): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already have a method that implements something similar to this and is called getIoValsAllPreBackIter. This name should match. |
||
""" | ||
Returns iterator of item duple (key, val), at each key over all | ||
keys in db in reverser order. If split is true then the key is split at sep and instead | ||
of returing duple it results tuple with one entry for each key split | ||
as well as the value. | ||
|
||
Works for both dupsort==False and dupsort==True | ||
|
||
Raises StopIteration Error when empty. | ||
|
||
Parameters: | ||
db is opened named sub db with dupsort=False | ||
key is key location in db to resume replay, | ||
If empty then last key in database | ||
split (bool): True means split key at sep before returning | ||
sep (bytes): separator char for key | ||
""" | ||
with self.env.begin(db=db, write=False, buffers=True) as txn: | ||
cursor = txn.cursor() | ||
if key == b'' or not cursor.set_key(key): # moves to val at key = key, first if empty | ||
cursor.last() | ||
|
||
for key, val in cursor.iterprev(): # return key, val at cursor | ||
if split: | ||
splits = bytes(key).split(sep) | ||
splits.append(val) | ||
else: | ||
splits = (bytes(key), val) | ||
yield tuple(splits) | ||
|
||
|
||
def getTopItemIter(self, db, key=b''): | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is an appropriate approach for filtering messages in LMDB. It requires deserializing the data and analyzing it and it hard codes the fields you can search for.
If you look at the Seeker class in KERIA you'll see an approach to creating LMDB indexes that are more flexible and more performant than this approach.