-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
Compatibility with GraalVM #403
Comments
I have not tested it with GraalVM. But any community contribution is more than welcome. |
Have you got any progress on this issue? |
Hey @anidotnet, |
@DarkAtra contribution is always welcome in latest Nitrite. |
After looking at the tests a bit, it's rather unlikely that i'm able to also introduce native tests for nitrite mvstore as it still uses junit 4. Apparently, native tests require at least junit version Update: i've created a separate module that uses junit 5 with a few test cases for basic nitrite operations - see the PR. Regarding the native hints: it seems like the following configuration is required for nitrite to properly read and write in a native image (when using mvstore with custom serialization-config.json
[ { "name": "java.lang.Integer" }, { "name": "java.lang.Long" }, { "name": "java.lang.Number" }, { "name": "java.lang.String" }, { "name": "java.util.ArrayList" }, { "name": "java.util.concurrent.atomic.AtomicBoolean" }, { "name": "java.util.concurrent.ConcurrentHashMap" }, { "name": "java.util.concurrent.ConcurrentHashMap$Segment" }, { "name": "java.util.concurrent.CopyOnWriteArrayList" }, { "name": "java.util.concurrent.locks.AbstractOwnableSynchronizer" }, { "name": "java.util.concurrent.locks.AbstractQueuedSynchronizer" }, { "name": "java.util.concurrent.locks.ReentrantLock" }, { "name": "java.util.concurrent.locks.ReentrantLock$NonfairSync" }, { "name": "java.util.concurrent.locks.ReentrantLock$Sync" }, { "name": "java.util.HashMap" }, { "name": "java.util.HashSet" }, { "name": "java.util.LinkedHashMap" }, { "name": "org.dizitart.no2.collection.NitriteDocument" }, { "name": "org.dizitart.no2.collection.NitriteId" }, { "name": "org.dizitart.no2.common.DBValue" }, { "name": "org.dizitart.no2.common.Fields" }, { "name": "org.dizitart.no2.common.meta.Attributes" }, { "name": "org.dizitart.no2.common.tuples.Pair" }, { "name": "org.dizitart.no2.index.IndexDescriptor" }, { "name": "org.dizitart.no2.index.IndexMeta" }, { "name": "org.dizitart.no2.store.UserCredential" } ] Also, users will have to provide additional reflection hints for classes that create indices. For example, if i was to store the following package de.darkatra
import org.dizitart.no2.index.IndexType
import org.dizitart.no2.repository.annotations.Id
import org.dizitart.no2.repository.annotations.Index
import org.dizitart.no2.repository.annotations.Indices
import java.time.Instant
@Indices(
value = [
Index(fields = ["message"], type = IndexType.NON_UNIQUE),
]
)
data class Error(
val message: String,
val timestamp: Instant
) using the following entity converter: class ErrorEntityConverter : EntityConverter<Error> {
override fun getEntityType(): Class<Error> = Error::class.java
override fun fromDocument(document: Document, nitriteMapper: NitriteMapper): Error {
return Error(
message = document.get(Error::message.name, String::class.java),
timestamp = Instant.parse(document.get(Error::timestamp.name, String::class.java))
)
}
override fun toDocument(error: Error, nitriteMapper: NitriteMapper): Document {
return Document.createDocument().apply {
put(Error::message.name, error.message)
put(Error::timestamp.name, error.timestamp.toString())
}
}
} via: val repository = database.getRepository(Error::class.java)
repository.insert(
Error(
message = "message",
timestamp = Instant.now()
)
) I'd have to add the following
or i'd get the following error message:
Users will also have to add additional serialization hints for all serializable types they write to the database. For example, the following code: val collection = database.getCollection("test")
collection.insert(
Document.createDocument("boolean", true)
) would require the following hint to be added to the users
Demo project: https://github.com/DarkAtra/nitrite-graalvm-demo |
Hi,
I'd love to use this awsome library with the native graalVM support.
Currently I'm fixing the similar issue as described here. Following are my error logs:
The text was updated successfully, but these errors were encountered: