-
Notifications
You must be signed in to change notification settings - Fork 2
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 SQL functions in Rust for checkpointing in SQLite bagfile databases #9
Comments
So if I understand the calculations above correctly each step needs the result of the previous one, right? I should be possible to do that as custom aggregate function in sql, but diesel does currently not provide a interface for custom aggregate functions with the sqlite backend. (It is possible to implement that and it shouldn't be to hard to implement that, If you are interested in using that approach I can provide a few pointers what needs to be done exactly) That said: The easiest solution here is to just load data batch wise, do the calculation and after that load and process the next batch. |
Correct, digest bytes from the previous message (of the same topic) is used in the current row's hmac.
Ah, this is termed as a "custom aggregate function" in SQL... TDIL!
Certainly, I'm still a new rustacean, but I could look into it. Perhaps you'd like to write those pointers and todo items under a new ticket back over at diesel-rs/diesel to proceed further.
Thats seem like a reasonable workaround for now. Would you suggest to add a partial struct with only the bbr_ros2/bbr_cli/src/models/message.rs Lines 3 to 10 in a9f0780
|
I refer to this functionality.
I've opened a issue for this: diesel-rs/diesel#2191 If you try to implement this and hit a problem just ping me there or in our gitter channel.
In general, you don't need a struct to load values. You could just use tuples there. With big amounts of data it is also preferable to select only those fields that are really required. |
Diesel, the Rust crate being migrated to for interfacing with recording in SQLite .db3, enables the use of custom sql_functions which can also be implemented in rust:
http://docs.diesel.rs/diesel/macro.sql_function.html#use-with-sqlite
I'm still unsure how to formulate a SQL query that could loop over all rows given a
topic_id
(A vs B) in themessages
(1,2,...,N) table such that it could replicate a hash chain as follows in (9) and (10):An example of specifying a
.filter()
query using thetopic_id
as a criteria is as follows:bbr_ros2/bbr_cli/src/api/mod.rs
Lines 119 to 123 in a9f0780
Would it be possible to replicate something like a LAG function (guessing here?) over filter query and feed that into a custom function in SQL sequentially? Is this even possible in SQLite?
https://www.sqlitetutorial.net/sqlite-window-functions/sqlite-lag/
bbr_ros2/bbr_cli/migrations/create_tabels/up.sql
Lines 8 to 13 in a9f0780
Relates to: diesel-rs/diesel#1775 , cc @weiznich
The text was updated successfully, but these errors were encountered: