Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1411,34 +1411,34 @@
* Special {@link Type.Record} that is undefined.
*/
class AnyRecord implements Type, Erasable {
private final boolean isNullable;

@Nonnull
private final Supplier<Integer> hashCodeSupplier = Suppliers.memoize(this::computeHashCode);

public AnyRecord(final boolean isNullable) {
this.isNullable = isNullable;
}

private int computeHashCode() {
return Objects.hash(getTypeCode().name().hashCode(), isNullable());
}

/**
* {@inheritDoc}
*/
@Override
public TypeCode getTypeCode() {
return TypeCode.RECORD;
}

/**
* {@inheritDoc}
*/
@Override
public boolean isNullable() {
return isNullable;
}

Check warning on line 1441 in fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/typing/Type.java

View check run for this annotation

fdb.teamscale.io / Teamscale | Findings

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/typing/Type.java#L1414-L1441

Clone with 2 instances of length 10 https://fdb.teamscale.io/findings/details/foundationdb-fdb-record-layer?t=FORK_MR%2F3679%2Fhazefully%2Fadd-hashcode-to-uuid%3AHEAD&id=59B84320436D9D4A2CDD11E8467116A6

@Nonnull
@Override
Expand Down Expand Up @@ -3002,21 +3002,31 @@

public static final String MESSAGE_NAME = TupleFieldsProto.UUID.getDescriptor().getName();

private final boolean isNullable;

/**
* Memoized hash function.
*/
@Nonnull
private final Supplier<Integer> 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;
}

@Override
public boolean isNullable() {
return isNullable;
}

Check warning on line 3029 in fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/typing/Type.java

View check run for this annotation

fdb.teamscale.io / Teamscale | Findings

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/typing/Type.java#L3005-L3029

Clone with 2 instances of length 10 https://fdb.teamscale.io/findings/details/foundationdb-fdb-record-layer?t=FORK_MR%2F3679%2Fhazefully%2Fadd-hashcode-to-uuid%3AHEAD&id=4955A71AAC61CE6496FD95431560244F

@Nonnull
@Override
Expand Down Expand Up @@ -3059,6 +3069,29 @@
.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;
Expand Down
Loading