Skip to content

Commit fb87244

Browse files
committed
added clj-sophia
1 parent f07a165 commit fb87244

File tree

6 files changed

+98
-0
lines changed

6 files changed

+98
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Here the list of libraries tested:
1616
- [clojure/tools.logging+log4j](./tools-logging-log4j) - Logging library :white_check_mark:
1717
- [amazonica+s3](./amazonica-s3) - Cloud API wrapper library :x: (*Buildtime and Runtime error*)
1818
- [cheshire](./cheshire) - JSON parser/writer :white_check_mark:
19+
- [clj-sophia](./clj-sophia) - A fast RAM-Disk hybrid storage :x: (Runtime error/JNA)
1920
- [nippy](./nippy) - Clojure serialization/deserialization library :warning: (*Can't serialize exceptions*)
2021
- cognitect/aws-api+s3 - Cloud API library :question:
2122
- ring/jetty - Web server :question:

clj-sophia/.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/target
2+
/classes
3+
/checkouts
4+
profiles.clj
5+
pom.xml
6+
pom.xml.asc
7+
*.jar
8+
*.class
9+
/.lein-*
10+
/.nrepl-port
11+
.hgignore
12+
.hg/

clj-sophia/README.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# clj-sophia
2+
3+
Testing whether [clj-sophia](https://github.com/BrunoBonacci/clj-sophia) library can be used in a native binary image with GraalVM.
4+
5+
## Usage
6+
7+
Currently testing:
8+
9+
[com.brunobonacci/clj-sophia "0.5.2"]
10+
11+
Test with:
12+
13+
lein do clean, uberjar, native, run-native
14+
15+
16+
At runtime the following error is thrown:
17+
18+
Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'sp_env': com.sun.jna.Native.findSymbol(JLjava/lang/String;)J [symbol: Java_com_sun_jna_Native_findSymbol or Java_com_sun_jna_Native_findSymbol__JLjava_lang_String_2]
19+
at com.sun.jna.Function.<init>(Function.java:251)
20+
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:566)
21+
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:542)
22+
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:528)
23+
at com.sun.jna.Library$Handler.invoke(Library.java:228)
24+
at com.sun.proxy.$Proxy180.sp_env(Unknown Source)
25+
at com.brunobonacci.sophia.native$sp_env.invokeStatic(native.clj:121)
26+
at com.brunobonacci.sophia.native$sp_env.invoke(native.clj:102)
27+
at com.brunobonacci.sophia$fn__9197$sophia__9207.invoke(sophia.clj:146)
28+
at simple.main$_main.invokeStatic(main.clj:9)
29+
at simple.main$_main.invoke(main.clj:7)
30+
at clojure.lang.AFn.applyToHelper(AFn.java:152)
31+
at clojure.lang.AFn.applyTo(AFn.java:144)
32+
at simple.main.main(Unknown Source)

clj-sophia/project.clj

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
(defproject sophia "0.1.0-SNAPSHOT"
2+
3+
:dependencies [[org.clojure/clojure "1.10.0"]
4+
[com.brunobonacci/clj-sophia "0.5.2"]
5+
;; to use with Log4J
6+
[org.slf4j/slf4j-log4j12 "1.7.25"]
7+
;; see also resource/log4j.properties
8+
]
9+
10+
:main simple.main
11+
12+
:uberjar-name "simple-main.jar"
13+
:profiles {:uberjar {:aot :all}
14+
:dev {:plugins [[lein-shell "0.5.0"]]}}
15+
16+
:aliases
17+
{"native"
18+
["shell"
19+
"native-image" "--report-unsupported-elements-at-runtime" "--no-server"
20+
"--initialize-at-build-time"
21+
"-jar" "./target/${:uberjar-name:-${:name}-${:version}-standalone.jar}"
22+
"-H:Name=./target/${:name}"]
23+
24+
"run-native" ["shell" "./target/${:name}"]})

clj-sophia/resources/log4j.properties

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Root logger option
2+
log4j.rootLogger=INFO, stdout
3+
4+
# Direct log messages to stdout
5+
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
6+
log4j.appender.stdout.Target=System.out
7+
log4j.appender.stdout.encoding=UTF-8
8+
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
9+
log4j.appender.stdout.layout.ConversionPattern=%-5p %c{1}:%L - %m%n
10+
11+
# Print only messages of level DEBUG or above in the package
12+
# log4j.logger.com.mypackage=DEBUG, stdout
13+
# or
14+
# log4j.category.com.mypackage=DEBUG

clj-sophia/src/simple/main.clj

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
(ns simple.main
2+
(:require [com.brunobonacci.sophia :as sph])
3+
(:gen-class))
4+
5+
6+
7+
(defn -main []
8+
9+
(let [env (sph/sophia
10+
{;; where to store the files on disk
11+
:sophia.path "/tmp/sophia-test"
12+
;; which logical databases to create
13+
:dbs ["accounts", {:name "transactions"}]})]
14+
(prn "SET" (sph/set-value! env "accounts" "user1" "John"))
15+
(prn "GET" (sph/get-value env "accounts" "user1"))))

0 commit comments

Comments
 (0)