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

fs-storage: Implement storages in Rust #1

Open
1 of 3 tasks
kirillt opened this issue Jan 29, 2024 · 4 comments · Fixed by #10
Open
1 of 3 tasks

fs-storage: Implement storages in Rust #1

kirillt opened this issue Jan 29, 2024 · 4 comments · Fixed by #10
Assignees

Comments

@kirillt
Copy link
Member

kirillt commented Jan 29, 2024

Right now, we have storages implemented in Kotlin. It would be great to move them from arklib-android repo to arklib and implement them in Rust. Then, we'll replace Kotlin code with JNI bindings to Rust code.

The original storages implementation is here. Any storage is just a KV-table. Usually, from with ResourceId as type for keys.

The original implementation contains also "sync with disk" functionality. We should carefully plan this feature. Probably, it should be separated from storages into merge strategy for atomic files

  • Skip the Monoid abstraction for this moment.
  • Skip AggregatedStorage class for this moment.
  • FileStorage for keeping the table in a single file
  • FolderStorage for keeping the values in separate files
  • ChunkedStorage as hybrid between the two, multiple files where each file contains several entries from the table
  • What exactly should we version using atomic files? Each value, each chunk or the whole table only?
@kirillt kirillt transferred this issue from ARK-Builders/arklib Feb 13, 2024
@kirillt
Copy link
Member Author

kirillt commented Feb 13, 2024

@twitu as soon as the simplest FileStorage abstraction is ready, we can start using it in particular implementations like TagStorage and ScoreStorage and build Tauri components on top of them.

@twitu
Copy link
Collaborator

twitu commented Feb 18, 2024

Added FileStorage struct with same functionality as Kotlin implementation in #2

  • Read data from file into a mapping from ResourceId to value
  • Write data mapping from ResourceId to value to file
  • Verify file version
  • Delete file when dropped

@twitu
Copy link
Collaborator

twitu commented Feb 22, 2024

The next step is to implement specific implementations for TagStorage and ScoreStorage. After looking at the implementations for tags and score it's clear that they are aliases for Int and String or Sets of String. These can be written to a file by the generic FileStorage implementation.

However, the android implementation assumes that the keys are resource ids. The FileStorage can write any key that can be converted to a string. So for the specialized implementation where will the keys come from?

@twitu twitu linked a pull request Mar 25, 2024 that will close this issue
@twitu twitu closed this as completed in #10 Mar 31, 2024
twitu added a commit that referenced this issue Mar 31, 2024
* Add FileStorage logic, example and documentation

Co-Authored-by: Ishan Bhanuka <bhanuka.ishan@gmail.com>
Co-Authored-by: Pushkar Mishra <pushkarmishra029@gmail.com>
Co-Authored-by: Tarek <tareknaser360@gmail.com>
Co-Authored-by: Kirill Taran <kirill@taran.space>

* refactor done

Signed-off-by: Pushkar Mishra <pushkarmishra029@gmail.com>

* fix cargo.toml

Signed-off-by: Pushkar Mishra <pushkarmishra029@gmail.com>

* Update fs-storage/src/file_storage.rs

Co-authored-by: Tarek Elsayed <60650661+tareknaser@users.noreply.github.com>

* Update fs-storage/src/file_storage.rs

Co-authored-by: Tarek Elsayed <60650661+tareknaser@users.noreply.github.com>

* Update fs-storage/src/file_storage.rs

Co-authored-by: Tarek Elsayed <60650661+tareknaser@users.noreply.github.com>

* Add doc comment for erase

* feat(fs-storage): refactor CLI write cmd to accept key-value pairs

Signed-off-by: Tarek <tareknaser360@gmail.com>

---------

Signed-off-by: Pushkar Mishra <pushkarmishra029@gmail.com>
Signed-off-by: Tarek <tareknaser360@gmail.com>
Co-authored-by: Pushkar Mishra <pushkarmishra029@gmail.com>
Co-authored-by: Tarek <tareknaser360@gmail.com>
Co-authored-by: Kirill Taran <kirill@taran.space>
Co-authored-by: Tarek Elsayed <60650661+tareknaser@users.noreply.github.com>
@twitu twitu reopened this Mar 31, 2024
@kirillt kirillt changed the title Implement storages in Rust fs-storage: Implement storages in Rust Apr 3, 2024
@kirillt
Copy link
Member Author

kirillt commented Apr 3, 2024

We have the FolderStorage left to implement, ChunkedStorage will be done sometime in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

2 participants