From 5104519aac8e58fbf46be76c7c12054f0a605cfd Mon Sep 17 00:00:00 2001 From: Hazem Zaghloul Date: Wed, 15 Oct 2025 15:44:55 +0100 Subject: [PATCH] Add equals and hashCode overrides to Type.Uuid --- .../query/plan/cascades/typing/Type.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/typing/Type.java b/fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/typing/Type.java index 127efbc757..20bdcda287 100644 --- a/fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/typing/Type.java +++ b/fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/typing/Type.java @@ -3004,10 +3004,20 @@ class Uuid implements Type { private final boolean isNullable; + /** + * Memoized hash function. + */ + @Nonnull + private final Supplier hashFunctionSupplier = Suppliers.memoize(this::computeHashCode); + private Uuid(boolean isNullable) { this.isNullable = isNullable; } + private int computeHashCode() { + return Objects.hash(getTypeCode().name().hashCode(), isNullable()); + } + @Override public TypeCode getTypeCode() { return TypeCode.UUID; @@ -3059,6 +3069,29 @@ public PUuidType toProto(@Nonnull final PlanSerializationContext serializationCo .build(); } + @Override + public int hashCode() { + return hashFunctionSupplier.get(); + } + + @Override + public boolean equals(final Object other) { + if (other == null) { + return false; + } + + if (other == this) { + return true; + } + + if (getClass() != other.getClass()) { + return false; + } + + final var otherType = (Uuid)other; + return getTypeCode() == otherType.getTypeCode() && isNullable() == otherType.isNullable(); + } + @Override public boolean isUuid() { return true;