From 1d3f559b591a16b58f276cfef68412112d459ab7 Mon Sep 17 00:00:00 2001 From: Sascha Lisson Date: Fri, 20 Dec 2024 15:10:35 +0100 Subject: [PATCH 1/2] fix(model-client): don't use roleIds in the deprecated ReplicatedRepository It's only used by the legacy-sync-plugin, which still relies on name based roles. --- .../kotlin/org/modelix/model/client/ReplicatedRepository.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model-client/src/jvmMain/kotlin/org/modelix/model/client/ReplicatedRepository.kt b/model-client/src/jvmMain/kotlin/org/modelix/model/client/ReplicatedRepository.kt index 7b77c43e4c..fe96026668 100644 --- a/model-client/src/jvmMain/kotlin/org/modelix/model/client/ReplicatedRepository.kt +++ b/model-client/src/jvmMain/kotlin/org/modelix/model/client/ReplicatedRepository.kt @@ -235,7 +235,7 @@ actual open class ReplicatedRepository actual constructor( var initialVersion = if (versionHash.isNullOrEmpty()) null else loadFromHash(versionHash, store) val initialTree = MutableObject() if (initialVersion == null) { - initialTree.setValue(CLTree.builder(store).repositoryId(branchReference.repositoryId).build()) + initialTree.setValue(CLTree.builder(store).useRoleIds(false).repositoryId(branchReference.repositoryId).build()) initialVersion = createVersion(initialTree.value, arrayOf(), null) client.asyncStore.put(branchReference.getKey(), initialVersion.getContentHash()) } else { From 3052d4b3a91c5c774f48f005b2325d62c0b29a37 Mon Sep 17 00:00:00 2001 From: Sascha Lisson Date: Fri, 20 Dec 2024 15:16:21 +0100 Subject: [PATCH 2/2] fix(model-datastructure): repeated wrapping with AsyncStoreAsLegacyDeserializingStore `AsyncStoreAsLegacyDeserializingStore` and are adapters `LegacyDeserializingStoreAsAsyncStore` that convert between `IDeserializingKeyValueStore` and `IAsyncObjectStore`. While converting between these two interfaces, another adapter was added instead of unwrapping an existing one, causing the call stack to keep growing util it was to large (StackOverflowError). --- .../src/commonMain/kotlin/org/modelix/model/lazy/CLTree.kt | 3 +-- .../src/commonMain/kotlin/org/modelix/model/lazy/CLVersion.kt | 3 +-- .../kotlin/org/modelix/model/lazy/IKVEntryReference.kt | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/model-datastructure/src/commonMain/kotlin/org/modelix/model/lazy/CLTree.kt b/model-datastructure/src/commonMain/kotlin/org/modelix/model/lazy/CLTree.kt index ef88b5d93d..d2b20c86b4 100644 --- a/model-datastructure/src/commonMain/kotlin/org/modelix/model/lazy/CLTree.kt +++ b/model-datastructure/src/commonMain/kotlin/org/modelix/model/lazy/CLTree.kt @@ -12,7 +12,6 @@ import org.modelix.model.api.ITree import org.modelix.model.api.async.getAncestors import org.modelix.model.api.async.getDescendants import org.modelix.model.async.AsyncAsSynchronousTree -import org.modelix.model.async.AsyncStoreAsLegacyDeserializingStore import org.modelix.model.async.AsyncTree import org.modelix.model.async.IAsyncObjectStore import org.modelix.model.persistent.CPHamtInternal @@ -58,7 +57,7 @@ class CLTree(val data: CPTree, val asyncStore: IAsyncObjectStore) : ITree by Asy store, ) - val store: IDeserializingKeyValueStore = AsyncStoreAsLegacyDeserializingStore(asyncStore) + val store: IDeserializingKeyValueStore = asyncStore.getLegacyObjectStore() override fun getId(): String = data.id diff --git a/model-datastructure/src/commonMain/kotlin/org/modelix/model/lazy/CLVersion.kt b/model-datastructure/src/commonMain/kotlin/org/modelix/model/lazy/CLVersion.kt index 6d20d4b63f..2e246fa91b 100644 --- a/model-datastructure/src/commonMain/kotlin/org/modelix/model/lazy/CLVersion.kt +++ b/model-datastructure/src/commonMain/kotlin/org/modelix/model/lazy/CLVersion.kt @@ -22,7 +22,6 @@ import org.modelix.model.api.PNodeReference import org.modelix.model.api.TreePointer import org.modelix.model.api.async.getDescendants import org.modelix.model.async.AsyncAsSynchronousTree -import org.modelix.model.async.AsyncStoreAsLegacyDeserializingStore import org.modelix.model.async.AsyncTree import org.modelix.model.async.BulkQueryAsAsyncStore import org.modelix.model.async.IAsyncObjectStore @@ -277,7 +276,7 @@ class CLVersion : IVersion { } fun tryLoadFromHash(hash: String, store: IAsyncObjectStore): Maybe { - return KVEntryReference(hash, CPVersion.DESERIALIZER).getValue(store).notNull().map { CLVersion(it, AsyncStoreAsLegacyDeserializingStore(store)) } + return KVEntryReference(hash, CPVersion.DESERIALIZER).getValue(store).notNull().map { CLVersion(it, store) } } } diff --git a/model-datastructure/src/commonMain/kotlin/org/modelix/model/lazy/IKVEntryReference.kt b/model-datastructure/src/commonMain/kotlin/org/modelix/model/lazy/IKVEntryReference.kt index cb46c5cab7..9fe9f9e95b 100644 --- a/model-datastructure/src/commonMain/kotlin/org/modelix/model/lazy/IKVEntryReference.kt +++ b/model-datastructure/src/commonMain/kotlin/org/modelix/model/lazy/IKVEntryReference.kt @@ -1,7 +1,6 @@ package org.modelix.model.lazy import com.badoo.reaktive.single.Single -import org.modelix.model.async.AsyncStoreAsLegacyDeserializingStore import org.modelix.model.async.IAsyncObjectStore import org.modelix.model.persistent.IKVValue @@ -13,5 +12,5 @@ interface IKVEntryReference { fun getUnwrittenValue(): E fun getDeserializer(): (String) -> E fun write(store: IDeserializingKeyValueStore) - fun write(store: IAsyncObjectStore) = write(AsyncStoreAsLegacyDeserializingStore(store)) + fun write(store: IAsyncObjectStore) = write(store.getLegacyObjectStore()) }