Fork me on GitHub
#graalvm
<
2020-04-25
>
littleli21:04:52

There is eventually also different way to use SQLite. By using Graalvm polyglot API and sulong.

littleli21:04:16

It's slightly difficult for me to explain, since I'm not C/C++ experienced. But in theory, you can compile SQLite using llvm-toolchain to llvm-bitcode and than using sulong and polyglot to interact and interop with such compiled sqlite shared object. There is a notation to map structures from native-c as described here: https://github.com/oracle/graal/blob/master/substratevm/src/com.oracle.svm.tutorial/src/com/oracle/svm/tutorial/CInterfaceTutorial.java Obviosly it's a great deal of work.

littleli21:04:29

To demonstrate something visible everyone can run SQLite on JVM by doing following on sqlite source:

export CC=$(lli --print-toolchain-path)/gcc
$CC -o sqlite -DSQLITE_THREADSAFE=0 shell.c sqlite3.c -ldl
lli --jvm sqlite
the last command actually runs sqlite compiled to llvm-bitcode with sulong interpreter directly on JVM. To interact with such a thing of course there has to be some envelope. It would be a great project for some Oracle Labs intern. I mean great example of the capabilities.

littleli21:04:38

It's probably wrong on some assumptions, but still...

peterschwarz21:04:49

That would be interesting, but would require writing a the interaction from top to bottom, versus being able to use existing JDBC code

peterschwarz21:04:51

the current JDBC drivers include the native binaries in the jar and move them around, which doesn't seem to play well with native image and clojure (at least as far as I've been able to manage).