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

fix: 'gte'&'lte' need follow ASCII character set order when load leaves #3424

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: 'gte'&'lte' need follow ASCII character set order when load leaves
coldstar1993 authored Nov 25, 2023

Verified

This commit was signed with the committer’s verified signature. The key has expired.
HighCrit HighCrit
commit 265eefdf97e3eb9ba3f6b8d7fcb1c34627425454
Original file line number Diff line number Diff line change
@@ -242,7 +242,7 @@ export class StandardIndexedTree extends TreeBase implements IndexedTree {
this.db
.createReadStream({
gte: indexToKeyLeaf(this.getName(), startingIndex),
lte: indexToKeyLeaf(this.getName(), 2n ** BigInt(this.getDepth())),
lte: indexToKeyLeaf(this.getName(), BigInt((2n ** BigInt(this.getDepth())).toString().replace(/\d/g, '9'))),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hye, I think there's a more efficient O(1) way of determining the number of digits (in base 10) 2^n has than converting bigints to strings.

We've also got serialisation primitives in foundation that convert bigints to buffers. In a separate PR we've encoded the leaf indices as big endian hex strings (which would sort naturally)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could u pls share me with your pr? thx

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

})
.on('data', function (data) {
const index = Number(data.key);