From 919cdd8c15a3f66a3ec291ca4d208d31769a909f Mon Sep 17 00:00:00 2001 From: Oleksandr Dzhychko Date: Mon, 24 Jun 2024 15:39:26 +0200 Subject: [PATCH] fix(model-client): fix executing bulk queries in RestWebModelClient --- .../modelix/model/lazy/IndirectObjectStore.kt | 5 +++++ .../handlers/KeyValueLikeModelServerTest.kt | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/model-datastructure/src/commonMain/kotlin/org/modelix/model/lazy/IndirectObjectStore.kt b/model-datastructure/src/commonMain/kotlin/org/modelix/model/lazy/IndirectObjectStore.kt index 65b44484df..2c63abc79b 100644 --- a/model-datastructure/src/commonMain/kotlin/org/modelix/model/lazy/IndirectObjectStore.kt +++ b/model-datastructure/src/commonMain/kotlin/org/modelix/model/lazy/IndirectObjectStore.kt @@ -14,6 +14,7 @@ package org.modelix.model.lazy import org.modelix.model.IKeyValueStore +import org.modelix.model.persistent.IKVValue abstract class IndirectObjectStore : IDeserializingKeyValueStore { @@ -34,6 +35,10 @@ abstract class IndirectObjectStore : IDeserializingKeyValueStore { return getStore().getAll(hash, deserializer) } + override fun getAll(regular: List>, prefetch: List>): Map { + return getStore().getAll(regular, prefetch) + } + override fun put(hash: String, deserialized: Any, serialized: String) { getStore().put(hash, deserialized, serialized) } diff --git a/model-server/src/test/kotlin/org/modelix/model/server/handlers/KeyValueLikeModelServerTest.kt b/model-server/src/test/kotlin/org/modelix/model/server/handlers/KeyValueLikeModelServerTest.kt index def6b11fff..0623c839f0 100644 --- a/model-server/src/test/kotlin/org/modelix/model/server/handlers/KeyValueLikeModelServerTest.kt +++ b/model-server/src/test/kotlin/org/modelix/model/server/handlers/KeyValueLikeModelServerTest.kt @@ -39,6 +39,7 @@ import org.modelix.model.server.store.forContextRepository import org.modelix.model.server.store.forGlobalRepository import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertNotNull import kotlin.test.assertTrue class KeyValueLikeModelServerTest { @@ -116,4 +117,19 @@ class KeyValueLikeModelServerTest { val branchAVersion = clientV2.pull(branchA, null) as CLVersion assertTrue(branchAVersion.isMerge()) } + + @Test + fun `model client V1 can run a bulk query`() = runTest { + val clientV1 = RestWebModelClient(baseUrl = "http://localhost/", providedClient = client) + val clientV2 = createModelClient() + val repositoryId = RepositoryId("repo1") + val version = clientV2.initRepositoryWithLegacyStorage(repositoryId) as CLVersion + val treeHash = checkNotNull(version.treeHash) { "Tree has should be loaded." } + + val bulkQuery = clientV1.storeCache.newBulkQuery() + val bulkQueryValue = bulkQuery.query(treeHash) + val bulkQueryResult = bulkQueryValue.executeQuery() + + assertNotNull(bulkQueryResult) + } }