libchewing icon indicating copy to clipboard operation
libchewing copied to clipboard

Experiment with pure rust build with redb backend

Open kanru opened this issue 2 years ago • 5 comments

Redb (https://github.com/cberner/redb) is a rust BTree database implementation.

If we implement a user dictionary backend in redb then we can optional remove sqlite as dependency.

kanru avatar Jul 16 '23 00:07 kanru

Using SQLite format allows users to easily modify the database directly (https://github.com/chewing/libchewing/issues/385). Will this change block such an usage?

https://github.com/launchbadge/sqlx may be useful. It is written in pure Rust and supports SQLite (among several others)

yan12125 avatar Jul 16 '23 06:07 yan12125

We should provide tools to help users to modify the user dictionary, and this is planned after the rewrite.

Using SQLite is mostly fine. The problem is linking with C library complicates the build process, but it's mostly solved. This issue is to see if we can build libchewing completely without any C dependency to make development a bit easier.

We are already using rusqlite as a simple wrapper around SQLite so we don't need to look into sqlx.

kanru avatar Jul 16 '23 06:07 kanru

Currently I know two tools for modifying user dictionaries, namely chewing-editor and the one from PIME. Both of them rely on libchewing, so there are limitations on how user dictionaries can be modified. Will the new tool allow changing arbitrary data in the database?

We are already using rusqlite as a simple wrapper around SQLite so we don't need to look into sqlx.

Here I mention sqlx as it can also make development easier and keeps SQLite format.

yan12125 avatar Jul 16 '23 07:07 yan12125

Yes, we can expose more powerful API for editors to use. We can also provide user dict <--> CSV or Excel conversion.

Here I mention sqlx as it can also make development easier and keeps SQLite format.

Appreciated. The user experience with rusqlite is already very good so the improvements from sqlx is limited. Besides, sqlx is more heavy weight and more suitable for web service usage.

kanru avatar Jul 16 '23 07:07 kanru

Thank you very much for clarifications. I'd love those directions. Hopefully I can also contribute some codes - at least the C part.

Regarding sqlx: sorry I didn't check their codes carefully. Actually there is still C dependency due to usage of libsqlite3-sys.

yan12125 avatar Jul 16 '23 08:07 yan12125

We implemented with a simpler format CDB using https://github.com/kanru/cdb2-rs

kanru avatar Mar 25 '24 12:03 kanru