Skip to content

Commit a9538e3

Browse files
committed
feat(modelql): efficient execution using bulk requests
1 parent 4119de1 commit a9538e3

File tree

176 files changed

+4871
-3005
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+4871
-3005
lines changed

gradle/libs.versions.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ dokka = "1.9.20"
4040
detekt = "1.23.7"
4141
xmlunit = "2.10.0"
4242
kotest = "5.9.1"
43+
reaktive = "2.2.0"
4344
testcontainers = "1.20.3"
4445
keycloak = "26.0.2"
4546

@@ -137,3 +138,9 @@ jimfs = { group = "com.google.jimfs", name = "jimfs", version = "1.3.0" }
137138

138139
testcontainers = { group = "org.testcontainers", name = "testcontainers", version.ref = "testcontainers" }
139140
testcontainers-postgresql = { group = "org.testcontainers", name = "postgresql", version.ref = "testcontainers" }
141+
142+
# The official publication with the group ID com.badoo.reaktive is built for JVM 17
143+
reaktive = { group = "org.modelix.reaktive", name = "reaktive", version.ref = "reaktive" }
144+
reaktive-testing = { group = "org.modelix.reaktive", name = "reaktive-testing", version.ref = "reaktive" }
145+
reaktive-annotations = { group = "org.modelix.reaktive", name = "reaktive-annotations", version.ref = "reaktive" }
146+
reaktive-coroutines-interop = { group = "org.modelix.reaktive", name = "coroutines-interop", version.ref = "reaktive" }
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package org.modelix.kotlin.utils
15+
16+
expect class AtomicLong(initial: Long) {
17+
fun incrementAndGet(): Long
18+
fun get(): Long
19+
fun set(newValue: Long)
20+
fun addAndGet(delta: Long): Long
21+
}
22+
23+
expect class AtomicBoolean(initial: Boolean) {
24+
fun get(): Boolean
25+
fun set(newValue: Boolean)
26+
fun compareAndSet(expectedValue: Boolean, newValue: Boolean): Boolean
27+
fun getAndSet(newValue: Boolean): Boolean
28+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) 2024.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.modelix.kotlin.utils
18+
19+
expect class ThreadLocal<E>(initialValueSupplier: () -> E) {
20+
fun get(): E
21+
fun set(value: E)
22+
fun remove()
23+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright (c) 2024.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.modelix.kotlin.utils
18+
19+
actual class AtomicLong actual constructor(initial: Long) {
20+
private var value: Long = initial
21+
actual fun incrementAndGet(): Long {
22+
return ++value
23+
}
24+
25+
actual fun get(): Long {
26+
return value
27+
}
28+
29+
actual fun set(newValue: Long) {
30+
value = newValue
31+
}
32+
33+
actual fun addAndGet(delta: Long): Long {
34+
value += delta
35+
return value
36+
}
37+
}
38+
39+
actual class AtomicBoolean actual constructor(initial: Boolean) {
40+
private var value: Boolean = initial
41+
actual fun get(): Boolean {
42+
return value
43+
}
44+
45+
actual fun set(newValue: Boolean) {
46+
value = newValue
47+
}
48+
49+
actual fun compareAndSet(expectedValue: Boolean, newValue: Boolean): Boolean {
50+
if (value == expectedValue) {
51+
value = newValue
52+
return true
53+
} else {
54+
return false
55+
}
56+
}
57+
58+
actual fun getAndSet(newValue: Boolean): Boolean {
59+
val oldValue = value
60+
value = newValue
61+
return oldValue
62+
}
63+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2024.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.modelix.kotlin.utils
18+
19+
actual class ThreadLocal<E> actual constructor(val initialValueSupplier: () -> E) {
20+
21+
private var value: E = initialValueSupplier()
22+
23+
actual fun get(): E {
24+
return value
25+
}
26+
27+
actual fun set(value: E) {
28+
this.value = value
29+
}
30+
31+
actual fun remove() {
32+
this.value = initialValueSupplier()
33+
}
34+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) 2024.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.modelix.kotlin.utils
18+
19+
public actual typealias AtomicLong = java.util.concurrent.atomic.AtomicLong
20+
public actual typealias AtomicBoolean = java.util.concurrent.atomic.AtomicBoolean

kotlin-utils/src/jvmMain/kotlin/org/modelix/kotlin/utils/ContextValue.jvm.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import kotlinx.coroutines.withContext
1818

1919
actual class ContextValue<E>(private val initialStack: List<E>) {
2020

21-
private val valueStack = ThreadLocal.withInitial { initialStack }
21+
private val valueStack = java.lang.ThreadLocal.withInitial { initialStack }
2222

2323
actual constructor() : this(emptyList())
2424

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2024.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.modelix.kotlin.utils
18+
19+
import java.lang.ThreadLocal as JvmThreadLocal
20+
21+
actual class ThreadLocal<E> actual constructor(initialValueSupplier: () -> E) {
22+
23+
private val threadLocal = JvmThreadLocal.withInitial(initialValueSupplier)
24+
25+
actual fun get(): E {
26+
return threadLocal.get()
27+
}
28+
29+
actual fun set(value: E) {
30+
return threadLocal.set(value)
31+
}
32+
33+
actual fun remove() {
34+
return threadLocal.remove()
35+
}
36+
}

model-api-gen-runtime/src/commonMain/kotlin/org/modelix/metamodel/GeneratedConcept.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ package org.modelix.metamodel
22

33
import org.modelix.model.api.ConceptReference
44
import org.modelix.model.api.IChildLink
5+
import org.modelix.model.api.IChildLinkReference
56
import org.modelix.model.api.IConcept
67
import org.modelix.model.api.IConceptReference
78
import org.modelix.model.api.INode
89
import org.modelix.model.api.IProperty
10+
import org.modelix.model.api.IPropertyReference
911
import org.modelix.model.api.IReferenceLink
12+
import org.modelix.model.api.IReferenceLinkReference
1013
import org.modelix.model.api.RoleAccessContext
1114
import org.modelix.model.api.getAllConcepts
1215
import kotlin.reflect.KClass
@@ -203,6 +206,8 @@ class GeneratedProperty<ValueT>(
203206
override fun deserializeValue(serialized: String?): ValueT = serializer.deserialize(serialized)
204207

205208
override fun getSimpleName(): String = simpleName
209+
210+
override fun toReference(): IPropertyReference = IPropertyReference.fromIdAndName(uid, simpleName)
206211
}
207212
fun IProperty.typed() = this as? ITypedProperty<*>
208213

@@ -233,6 +238,8 @@ abstract class GeneratedChildLink<ChildNodeT : ITypedNode, ChildConceptT : IConc
233238
}
234239

235240
override fun getSimpleName(): String = simpleName
241+
242+
override fun toReference(): IChildLinkReference = IChildLinkReference.fromIdAndName(uid, simpleName)
236243
}
237244
fun IChildLink.typed(): ITypedChildLink<ITypedNode> {
238245
return this as? ITypedChildLink<ITypedNode>
@@ -286,5 +293,7 @@ class GeneratedReferenceLink<TargetNodeT : ITypedNode, TargetConceptT : IConcept
286293
}
287294

288295
override fun getSimpleName(): String = simpleName
296+
297+
override fun toReference(): IReferenceLinkReference = IReferenceLinkReference.fromIdAndName(uid, simpleName)
289298
}
290299
fun IReferenceLink.typed() = this as? ITypedReferenceLink<ITypedNode> ?: UnknownTypedReferenceLink(this)

model-api-gen-runtime/src/commonMain/kotlin/org/modelix/metamodel/UnknownConcept.kt

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -5,63 +5,13 @@ import org.modelix.model.api.IConcept
55
import org.modelix.model.api.IConceptReference
66
import org.modelix.model.api.ILanguage
77
import org.modelix.model.api.INode
8-
import org.modelix.model.api.IProperty
98
import org.modelix.model.api.IReferenceLink
10-
import org.modelix.model.area.IArea
9+
import org.modelix.model.api.meta.EmptyConcept
10+
import org.modelix.model.api.meta.NullConcept
1111
import kotlin.reflect.KClass
1212

13-
abstract class EmptyConcept : IConcept {
14-
override fun isAbstract(): Boolean = true
15-
16-
override fun isSubConceptOf(superConcept: IConcept?): Boolean = superConcept == this
17-
18-
override fun getDirectSuperConcepts(): List<IConcept> = emptyList()
19-
20-
override fun isExactly(concept: IConcept?): Boolean = concept == this
21-
22-
override fun getOwnProperties(): List<IProperty> = emptyList()
23-
24-
override fun getOwnChildLinks(): List<IChildLink> = emptyList()
25-
26-
override fun getOwnReferenceLinks(): List<IReferenceLink> = emptyList()
27-
28-
override fun getAllProperties(): List<IProperty> = emptyList()
29-
30-
override fun getAllChildLinks(): List<IChildLink> = emptyList()
31-
32-
override fun getAllReferenceLinks(): List<IReferenceLink> = emptyList()
33-
34-
override fun getProperty(name: String): IProperty {
35-
throw IllegalArgumentException("Cannot get property '$name'. No concept information available for '${getUID()}'.")
36-
}
37-
38-
override fun getChildLink(name: String): IChildLink {
39-
throw IllegalArgumentException("Cannot get link '$name'. No concept information available for '${getUID()}'.")
40-
}
41-
42-
override fun getReferenceLink(name: String): IReferenceLink {
43-
throw IllegalArgumentException("Cannot get link '$name'. No concept information available for '${getUID()}'.")
44-
}
45-
}
46-
47-
object NullConcept : EmptyConcept(), IConceptReference {
48-
override fun getReference(): IConceptReference = this
49-
50-
override val language: ILanguage?
51-
get() = null
52-
53-
override fun getUID(): String = "null"
54-
55-
override fun getShortName(): String = "null"
56-
57-
override fun getLongName(): String = getShortName()
58-
59-
override fun resolve(area: IArea?): IConcept? {
60-
return this
61-
}
62-
63-
override fun serialize(): String = "null"
64-
}
13+
@Deprecated("use org.modelix.model.api.meta.NullConcept", ReplaceWith("org.modelix.model.api.meta.NullConcept"))
14+
val NullConcept = org.modelix.model.api.meta.NullConcept
6515

6616
data class UnknownConcept(private val ref: IConceptReference) : EmptyConcept() {
6717
override fun getReference(): IConceptReference {

0 commit comments

Comments
 (0)