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

Use queries with custom xor function #1113

Merged
merged 3 commits into from
Jun 3, 2022
Merged

Conversation

KonradStaniec
Copy link
Contributor

Removes custom logic to sort elements, by using custom xor function on sqlite level and sql query to sort results by xor distance.

Next step is to add nice queries to get content in range of node radius like:
"SELECT key WHERE xorDistance(?, key) <= radius LIMIT limit"

@KonradStaniec KonradStaniec requested a review from kdeme June 2, 2022 12:22
Comment on lines 215 to 216
fraction > 0 and fraction < 1,
"Deleted fraction shohould be > 0 and < 1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fraction > 0 and fraction < 1,
"Deleted fraction shohould be > 0 and < 1"
fraction > 0 and fraction < 1,
"Deleted fraction should be > 0 and < 1"

var bytesDeleted: int64 = 0
let targetBytes = target.toByteArrayBE()
for e in db.getAllOrderedByDistanceStmt.exec(targetBytes, ri):
if bytesDeleted + ri.payloadLength < bytesToDelete:
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't matter that much in our current setting, as an arbitrary fraction is chosen anyhow, but it would be more correct if you still allow the last deletion to reach the amount of bytesToDelete (or slightly more).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is matter of preference i.e current approach interprets fraction as at most data to delete, where with allowing this last deletion it would be at least data to delete. I slightly prefer at most interpretation as it allows to discard case when the whole database could be deleted when someone would provide fraction of 0.99 (or something similar)

@KonradStaniec KonradStaniec merged commit 0776f35 into master Jun 3, 2022
@KonradStaniec KonradStaniec deleted the use-custom-xor-in-queries branch June 3, 2022 11:44
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.

None yet

2 participants