Skip to content

Commit

Permalink
fix(model-client): fix executing bulk queries in RestWebModelClient
Browse files Browse the repository at this point in the history
  • Loading branch information
odzhychko committed Jun 24, 2024
1 parent 5696d86 commit 919cdd8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.modelix.model.lazy

import org.modelix.model.IKeyValueStore
import org.modelix.model.persistent.IKVValue

abstract class IndirectObjectStore : IDeserializingKeyValueStore {

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

override fun <T : IKVValue> getAll(regular: List<IKVEntryReference<T>>, prefetch: List<IKVEntryReference<T>>): Map<String, T?> {
return getStore().getAll(regular, prefetch)
}

override fun put(hash: String, deserialized: Any, serialized: String) {
getStore().put(hash, deserialized, serialized)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
}

0 comments on commit 919cdd8

Please sign in to comment.