Skip to content

[CALCITE-3954] Always compare types using equals#1942

Merged
danny0405 merged 1 commit intoapache:masterfrom
danny0405:CALCITE-3954
Apr 27, 2020
Merged

[CALCITE-3954] Always compare types using equals#1942
danny0405 merged 1 commit intoapache:masterfrom
danny0405:CALCITE-3954

Conversation

@danny0405
Copy link
Contributor

Current interning of types use weak references.
Change from MUST intern to SHOULD intern, and always
compare types using equals.

We clearly want to do some interning, especially within a query, so that
there aren't hundreds of copies of the same record type all over the
place. But if people don't intern, or intern in different query-specific
caches, then the logic will still work.

If equals is written using the standard template

return this == o
  || o instanceof TheType && field1 == o.field1 && field2 == o.field2

(that is, avoiding deep comparison if possible) then the performance
will be pretty much the same.

Copy link
Member

@hsyuan hsyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You must also change RelDataTypeImpl.equals.

@danny0405
Copy link
Contributor Author

You must also change RelDataTypeImpl.equals.

Yep, thanks for the reminder ~

Current interning of types use weak references.
Change from MUST intern to SHOULD intern, and always
compare types using equals.

We clearly want to do some interning, especially within a query, so that
there aren't hundreds of copies of the same record type all over the
place. But if people don't intern, or intern in different query-specific
caches, then the logic will still work.

If equals is written using the standard template
```java
return this == o
  || o instanceof TheType && field1 == o.field1 && field2 == o.field2
```
(that is, avoiding deep comparison if possible) then the performance
will be pretty much the same.
@danny0405 danny0405 added the LGTM-will-merge-soon Overall PR looks OK. Only minor things left. label Apr 25, 2020
@danny0405 danny0405 merged commit 2129000 into apache:master Apr 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LGTM-will-merge-soon Overall PR looks OK. Only minor things left.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants