From 839d0b436d9ec0bb6c179cba5b8d4e3bc626f0c1 Mon Sep 17 00:00:00 2001 From: Artem Ananev Date: Thu, 19 Dec 2024 14:24:50 -0800 Subject: [PATCH] Restored dynamic OnDiskKeySerializer/OnDiskValueSerializer class registration Signed-off-by: Artem Ananev --- .../com/swirlds/state/merkle/StateUtils.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/platform-sdk/swirlds-state-impl/src/main/java/com/swirlds/state/merkle/StateUtils.java b/platform-sdk/swirlds-state-impl/src/main/java/com/swirlds/state/merkle/StateUtils.java index e892c31668c3..75079e26fdf5 100644 --- a/platform-sdk/swirlds-state-impl/src/main/java/com/swirlds/state/merkle/StateUtils.java +++ b/platform-sdk/swirlds-state-impl/src/main/java/com/swirlds/state/merkle/StateUtils.java @@ -29,7 +29,9 @@ import com.swirlds.common.utility.NonCryptographicHashing; import com.swirlds.logging.legacy.LogMarker; import com.swirlds.state.merkle.disk.OnDiskKey; +import com.swirlds.state.merkle.disk.OnDiskKeySerializer; import com.swirlds.state.merkle.disk.OnDiskValue; +import com.swirlds.state.merkle.disk.OnDiskValueSerializer; import com.swirlds.state.merkle.memory.InMemoryValue; import com.swirlds.state.merkle.memory.InMemoryWritableKVState; import com.swirlds.state.merkle.queue.QueueNode; @@ -286,14 +288,34 @@ public static void registerWithSystem( md.inMemoryValueClassId(), md.stateDefinition().keyCodec(), md.stateDefinition().valueCodec()))); + // FUTURE WORK: remove OnDiskKey registration, once there are no objects of this clas + // in existing state snapshots constructableRegistry.registerConstructable(new ClassConstructorPair( OnDiskKey.class, () -> new OnDiskKey<>( md.onDiskKeyClassId(), md.stateDefinition().keyCodec()))); + // FUTURE WORK: remove OnDiskKeySerilalizer registration, once there are no objects of this clas + // in existing state snapshots + constructableRegistry.registerConstructable(new ClassConstructorPair( + OnDiskKeySerializer.class, + () -> new OnDiskKeySerializer<>( + md.onDiskKeySerializerClassId(), + md.onDiskKeyClassId(), + md.stateDefinition().keyCodec()))); + // FUTURE WORK: remove OnDiskValue registration, once there are no objects of this clas + // in existing state snapshots constructableRegistry.registerConstructable(new ClassConstructorPair( OnDiskValue.class, () -> new OnDiskValue<>( md.onDiskValueClassId(), md.stateDefinition().valueCodec()))); + // FUTURE WORK: remove OnDiskValueSerializer registration, once there are no objects of this clas + // in existing state snapshots + constructableRegistry.registerConstructable(new ClassConstructorPair( + OnDiskValueSerializer.class, + () -> new OnDiskValueSerializer<>( + md.onDiskValueSerializerClassId(), + md.onDiskValueClassId(), + md.stateDefinition().valueCodec()))); constructableRegistry.registerConstructable(new ClassConstructorPair( SingletonNode.class, () -> new SingletonNode<>(