Skip to content

Commit b4fd113

Browse files
author
Oleksandr Dzhychko
authored
Merge pull request #851 from modelix/fix-bulkQuery-in-RestWebModelClient
fix(model-client): fix executing bulk queries in RestWebModelClient
2 parents 1a592c2 + 919cdd8 commit b4fd113

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

model-datastructure/src/commonMain/kotlin/org/modelix/model/lazy/IndirectObjectStore.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
package org.modelix.model.lazy
1515

1616
import org.modelix.model.IKeyValueStore
17+
import org.modelix.model.persistent.IKVValue
1718

1819
abstract class IndirectObjectStore : IDeserializingKeyValueStore {
1920

@@ -34,6 +35,10 @@ abstract class IndirectObjectStore : IDeserializingKeyValueStore {
3435
return getStore().getAll(hash, deserializer)
3536
}
3637

38+
override fun <T : IKVValue> getAll(regular: List<IKVEntryReference<T>>, prefetch: List<IKVEntryReference<T>>): Map<String, T?> {
39+
return getStore().getAll(regular, prefetch)
40+
}
41+
3742
override fun put(hash: String, deserialized: Any, serialized: String) {
3843
getStore().put(hash, deserialized, serialized)
3944
}

model-server/src/test/kotlin/org/modelix/model/server/handlers/KeyValueLikeModelServerTest.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import org.modelix.model.server.store.forContextRepository
3939
import org.modelix.model.server.store.forGlobalRepository
4040
import kotlin.test.Test
4141
import kotlin.test.assertEquals
42+
import kotlin.test.assertNotNull
4243
import kotlin.test.assertTrue
4344

4445
class KeyValueLikeModelServerTest {
@@ -116,4 +117,19 @@ class KeyValueLikeModelServerTest {
116117
val branchAVersion = clientV2.pull(branchA, null) as CLVersion
117118
assertTrue(branchAVersion.isMerge())
118119
}
120+
121+
@Test
122+
fun `model client V1 can run a bulk query`() = runTest {
123+
val clientV1 = RestWebModelClient(baseUrl = "http://localhost/", providedClient = client)
124+
val clientV2 = createModelClient()
125+
val repositoryId = RepositoryId("repo1")
126+
val version = clientV2.initRepositoryWithLegacyStorage(repositoryId) as CLVersion
127+
val treeHash = checkNotNull(version.treeHash) { "Tree has should be loaded." }
128+
129+
val bulkQuery = clientV1.storeCache.newBulkQuery()
130+
val bulkQueryValue = bulkQuery.query(treeHash)
131+
val bulkQueryResult = bulkQueryValue.executeQuery()
132+
133+
assertNotNull(bulkQueryResult)
134+
}
119135
}

0 commit comments

Comments
 (0)