Skip to content

Commit

Permalink
fix(model-server): IImmutableStore is supposed to return null values
Browse files Browse the repository at this point in the history
  • Loading branch information
slisson committed Dec 12, 2024
1 parent 110b426 commit d17a384
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.modelix.model.IGenericKeyListener
* Doesn't require transactions.
*/
interface IImmutableStore<KeyT> {
fun getAll(keys: Set<KeyT>): Map<KeyT, String>
fun getAll(keys: Set<KeyT>): Map<KeyT, String?>

Check warning

Code scanning / detekt

The function getAll is missing documentation. Warning

The function getAll is missing documentation.
fun addAll(entries: Map<KeyT, String>)

Check warning

Code scanning / detekt

The function addAll is missing documentation. Warning

The function addAll is missing documentation.
fun getIfCached(key: KeyT): String?

Check warning

Code scanning / detekt

The function getIfCached is missing documentation. Warning

The function getIfCached is missing documentation.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,9 @@ class IgniteStoreClient(jdbcProperties: Properties? = null, private val inmemory

override fun getImmutableStore(): IImmutableStore<ObjectInRepository> {
return object : IImmutableStore<ObjectInRepository> {
override fun getAll(keys: Set<ObjectInRepository>): Map<ObjectInRepository, String> {
override fun getAll(keys: Set<ObjectInRepository>): Map<ObjectInRepository, String?> {
keys.forEach { require(HashUtil.isSha256(it.key)) { "Not an immutable object: $it" } }
return cache.getAll(keys).mapValues {
val value = it.value
if (value == null) throw ObjectValueNotFoundException(it.key.key)
value
}
return cache.getAll(keys)
}

override fun addAll(entries: Map<ObjectInRepository, String>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,10 @@ class InMemoryStoreClient : IsolatingStore, ITransactionManager, IRepositoryAwar

override fun getImmutableStore(): IImmutableStore<ObjectInRepository> {
return object : IImmutableStore<ObjectInRepository> {
override fun getAll(keys: Set<ObjectInRepository>): Map<ObjectInRepository, String> {
override fun getAll(keys: Set<ObjectInRepository>): Map<ObjectInRepository, String?> {
keys.forEach { require(HashUtil.isSha256(it.key)) { "Not an immutable object: $it" } }
@OptIn(RequiresTransaction::class)
return runRead { this@InMemoryStoreClient.getAll(keys) }.mapValues {
val value = it.value
if (value == null) throw ObjectValueNotFoundException(it.key.key)
value
}
return runRead { this@InMemoryStoreClient.getAll(keys) }
}

override fun addAll(entries: Map<ObjectInRepository, String>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ abstract class StoreClientAdapter(val client: IsolatingStore) : IStoreClient {
override fun getImmutableStore(): IImmutableStore<String> {
val immutableStore = client.getImmutableStore()
return object : IImmutableStore<String> {
override fun getAll(keys: Set<String>): Map<String, String> {
override fun getAll(keys: Set<String>): Map<String, String?> {
val fromRepository = immutableStore.getAll(keys.map { it.withRepoScope() }.toSet()).mapKeys { it.key.key }
if (getRepositoryId() == null) return fromRepository

Expand Down

0 comments on commit d17a384

Please sign in to comment.