Skip to content

Commit 9c71fe3

Browse files
committed
Annotate equals methods with Nullable in src/core/main
1 parent e315fbb commit 9c71fe3

File tree

109 files changed

+329
-125
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+329
-125
lines changed

core/build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ dependencies {
5656
implementation("net.hydromatic:aggdesigner-algorithm")
5757
implementation("org.apache.commons:commons-dbcp2")
5858
implementation("org.apache.commons:commons-lang3")
59+
implementation("org.checkerframework:checker-qual")
5960
implementation("commons-io:commons-io")
6061
implementation("org.codehaus.janino:commons-compiler")
6162
implementation("org.codehaus.janino:janino")

core/src/main/java/org/apache/calcite/interpreter/Row.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
package org.apache.calcite.interpreter;
1818

19+
import org.checkerframework.checker.nullness.qual.Nullable;
20+
1921
import java.util.Arrays;
2022

2123
/**
@@ -64,7 +66,7 @@ public static Row of(Object...values) {
6466
return Arrays.hashCode(values);
6567
}
6668

67-
@Override public boolean equals(Object obj) {
69+
@Override public boolean equals(@Nullable Object obj) {
6870
return obj == this
6971
|| obj instanceof Row
7072
&& Arrays.equals(values, ((Row) obj).values);

core/src/main/java/org/apache/calcite/jdbc/JavaRecordType.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import org.apache.calcite.rel.type.RelDataTypeField;
2020
import org.apache.calcite.rel.type.RelRecordType;
2121

22+
import org.checkerframework.checker.nullness.qual.Nullable;
23+
2224
import java.util.List;
2325
import java.util.Objects;
2426

@@ -37,7 +39,7 @@ public JavaRecordType(List<RelDataTypeField> fields, Class clazz) {
3739
this.clazz = Objects.requireNonNull(clazz);
3840
}
3941

40-
@Override public boolean equals(Object obj) {
42+
@Override public boolean equals(@Nullable Object obj) {
4143
return this == obj
4244
|| obj instanceof JavaRecordType
4345
&& fieldList.equals(((JavaRecordType) obj).fieldList)

core/src/main/java/org/apache/calcite/materialize/Lattice.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ public int compareTo(@Nonnull Measure measure) {
591591
return Objects.hash(agg, args);
592592
}
593593

594-
@Override public boolean equals(Object obj) {
594+
@Override public boolean equals(@Nullable Object obj) {
595595
return obj == this
596596
|| obj instanceof Measure
597597
&& this.agg.equals(((Measure) obj).agg)
@@ -664,7 +664,7 @@ public int compareTo(Column column) {
664664
return ordinal;
665665
}
666666

667-
@Override public boolean equals(Object obj) {
667+
@Override public boolean equals(@Nullable Object obj) {
668668
return obj == this
669669
|| obj instanceof Column
670670
&& this.ordinal == ((Column) obj).ordinal;

core/src/main/java/org/apache/calcite/materialize/LatticeSuggester.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ public int hashCode() {
632632
return ordinalInQuery;
633633
}
634634

635-
public boolean equals(Object obj) {
635+
public boolean equals(@Nullable Object obj) {
636636
return this == obj
637637
|| obj instanceof TableRef
638638
&& ordinalInQuery == ((TableRef) obj).ordinalInQuery;
@@ -658,7 +658,7 @@ private static class StepRef extends DefaultEdge {
658658
return ordinalInQuery;
659659
}
660660

661-
@Override public boolean equals(Object obj) {
661+
@Override public boolean equals(@Nullable Object obj) {
662662
return this == obj
663663
|| obj instanceof StepRef
664664
&& ((StepRef) obj).ordinalInQuery == ordinalInQuery;

core/src/main/java/org/apache/calcite/materialize/LatticeTable.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import org.apache.calcite.rel.type.RelDataTypeField;
2121
import org.apache.calcite.util.Util;
2222

23+
import org.checkerframework.checker.nullness.qual.Nullable;
24+
2325
import java.util.Objects;
2426
import javax.annotation.Nonnull;
2527

@@ -37,7 +39,7 @@ public class LatticeTable {
3739
return t.getQualifiedName().hashCode();
3840
}
3941

40-
@Override public boolean equals(Object obj) {
42+
@Override public boolean equals(@Nullable Object obj) {
4143
return this == obj
4244
|| obj instanceof LatticeTable
4345
&& t.getQualifiedName().equals(

core/src/main/java/org/apache/calcite/materialize/MaterializationActor.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import com.google.common.collect.HashMultimap;
2424
import com.google.common.collect.Multimap;
2525

26+
import org.checkerframework.checker.nullness.qual.Nullable;
27+
2628
import java.util.HashMap;
2729
import java.util.List;
2830
import java.util.Map;
@@ -97,7 +99,7 @@ static class QueryKey {
9799
this.path = path;
98100
}
99101

100-
@Override public boolean equals(Object obj) {
102+
@Override public boolean equals(@Nullable Object obj) {
101103
return obj == this
102104
|| obj instanceof QueryKey
103105
&& sql.equals(((QueryKey) obj).sql)

core/src/main/java/org/apache/calcite/materialize/MaterializationKey.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
package org.apache.calcite.materialize;
1818

19+
import org.checkerframework.checker.nullness.qual.Nullable;
20+
1921
import java.io.Serializable;
2022
import java.util.UUID;
2123

@@ -32,7 +34,7 @@ public class MaterializationKey implements Serializable {
3234
return uuid.hashCode();
3335
}
3436

35-
@Override public boolean equals(Object obj) {
37+
@Override public boolean equals(@Nullable Object obj) {
3638
return this == obj
3739
|| obj instanceof MaterializationKey
3840
&& uuid.equals(((MaterializationKey) obj).uuid);

core/src/main/java/org/apache/calcite/materialize/Path.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import com.google.common.collect.ImmutableList;
2020

21+
import org.checkerframework.checker.nullness.qual.Nullable;
22+
2123
import java.util.List;
2224

2325
/** A sequence of {@link Step}s from a root node (fact table) to another node
@@ -35,7 +37,7 @@ class Path {
3537
return id;
3638
}
3739

38-
@Override public boolean equals(Object obj) {
40+
@Override public boolean equals(@Nullable Object obj) {
3941
return this == obj
4042
|| obj instanceof Path
4143
&& id == ((Path) obj).id;

core/src/main/java/org/apache/calcite/materialize/Step.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import com.google.common.collect.ImmutableList;
2525
import com.google.common.collect.Ordering;
2626

27+
import org.checkerframework.checker.nullness.qual.Nullable;
28+
2729
import java.util.List;
2830
import java.util.Objects;
2931

@@ -68,7 +70,7 @@ static Step create(LatticeTable source, LatticeTable target,
6870
return Objects.hash(source, target, keys);
6971
}
7072

71-
@Override public boolean equals(Object obj) {
73+
@Override public boolean equals(@Nullable Object obj) {
7274
return this == obj
7375
|| obj instanceof Step
7476
&& ((Step) obj).source.equals(source)

core/src/main/java/org/apache/calcite/materialize/TileKey.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
import com.google.common.collect.ImmutableList;
2222

23+
import org.checkerframework.checker.nullness.qual.Nullable;
24+
2325
import java.util.Objects;
2426

2527
/** Definition of a particular combination of dimensions and measures of a
@@ -45,7 +47,7 @@ public TileKey(Lattice lattice, ImmutableBitSet dimensions,
4547
return Objects.hash(lattice, dimensions);
4648
}
4749

48-
@Override public boolean equals(Object obj) {
50+
@Override public boolean equals(@Nullable Object obj) {
4951
return obj == this
5052
|| obj instanceof TileKey
5153
&& lattice == ((TileKey) obj).lattice

core/src/main/java/org/apache/calcite/plan/RelCompositeTrait.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import com.google.common.collect.ImmutableList;
2020
import com.google.common.collect.Ordering;
2121

22+
import org.checkerframework.checker.nullness.qual.Nullable;
23+
2224
import java.util.Arrays;
2325
import java.util.List;
2426
import java.util.Objects;
@@ -78,7 +80,7 @@ public RelTraitDef getTraitDef() {
7880
return Arrays.hashCode(traits);
7981
}
8082

81-
@Override public boolean equals(Object obj) {
83+
@Override public boolean equals(@Nullable Object obj) {
8284
return this == obj
8385
|| obj instanceof RelCompositeTrait
8486
&& Arrays.equals(traits, ((RelCompositeTrait) obj).traits);

core/src/main/java/org/apache/calcite/plan/RelOptCostImpl.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
package org.apache.calcite.plan;
1818

19+
import org.checkerframework.checker.nullness.qual.Nullable;
20+
1921
/**
2022
* RelOptCostImpl provides a default implementation for the {@link RelOptCost}
2123
* interface. It it defined in terms of a single scalar quantity; somewhat
@@ -76,7 +78,7 @@ public boolean equals(RelOptCost other) {
7678
return getRows() == other.getRows();
7779
}
7880

79-
@Override public boolean equals(Object obj) {
81+
@Override public boolean equals(@Nullable Object obj) {
8082
if (obj instanceof RelOptCostImpl) {
8183
return equals((RelOptCost) obj);
8284
}

core/src/main/java/org/apache/calcite/plan/RelOptRule.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import com.google.common.collect.ImmutableList;
2626
import com.google.common.collect.Lists;
2727

28+
import org.checkerframework.checker.nullness.qual.Nullable;
29+
2830
import java.util.ArrayList;
2931
import java.util.List;
3032
import java.util.Objects;
@@ -462,7 +464,7 @@ public int hashCode() {
462464
return description.hashCode();
463465
}
464466

465-
public boolean equals(Object obj) {
467+
@Override public boolean equals(@Nullable Object obj) {
466468
return (obj instanceof RelOptRule)
467469
&& equals((RelOptRule) obj);
468470
}

core/src/main/java/org/apache/calcite/plan/RelOptRuleOperand.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
import com.google.common.collect.ImmutableList;
2222

23+
import org.checkerframework.checker.nullness.qual.Nullable;
24+
2325
import java.util.List;
2426
import java.util.Objects;
2527
import java.util.function.Predicate;
@@ -170,7 +172,7 @@ public int hashCode() {
170172
return Objects.hash(clazz, trait, children);
171173
}
172174

173-
public boolean equals(Object obj) {
175+
@Override public boolean equals(@Nullable Object obj) {
174176
if (this == obj) {
175177
return true;
176178
}

core/src/main/java/org/apache/calcite/plan/RelTraitSet.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
import com.google.common.collect.ImmutableList;
2626

27+
import org.checkerframework.checker.nullness.qual.Nullable;
28+
2729
import java.util.AbstractList;
2830
import java.util.Arrays;
2931
import java.util.HashMap;
@@ -420,7 +422,7 @@ public <T extends RelTrait> T canonize(T trait) {
420422
* @param obj another RelTraitSet
421423
* @return true if traits are equal and in the same order, false otherwise
422424
*/
423-
@Override public boolean equals(Object obj) {
425+
@Override public boolean equals(@Nullable Object obj) {
424426
if (this == obj) {
425427
return true;
426428
}

core/src/main/java/org/apache/calcite/plan/hep/HepRelMetadataProvider.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import com.google.common.collect.ImmutableMultimap;
2727
import com.google.common.collect.Multimap;
2828

29+
import org.checkerframework.checker.nullness.qual.Nullable;
30+
2931
import java.lang.reflect.Method;
3032

3133
/**
@@ -35,7 +37,7 @@
3537
class HepRelMetadataProvider implements RelMetadataProvider {
3638
//~ Methods ----------------------------------------------------------------
3739

38-
@Override public boolean equals(Object obj) {
40+
@Override public boolean equals(@Nullable Object obj) {
3941
return obj instanceof HepRelMetadataProvider;
4042
}
4143

core/src/main/java/org/apache/calcite/plan/volcano/VolcanoCost.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import org.apache.calcite.plan.RelOptCostFactory;
2121
import org.apache.calcite.plan.RelOptUtil;
2222

23+
import org.checkerframework.checker.nullness.qual.Nullable;
24+
2325
import java.util.Objects;
2426

2527
/**
@@ -131,7 +133,7 @@ public boolean equals(RelOptCost other) {
131133
&& (this.io == ((VolcanoCost) other).io);
132134
}
133135

134-
@Override public boolean equals(Object obj) {
136+
@Override public boolean equals(@Nullable Object obj) {
135137
if (obj instanceof VolcanoCost) {
136138
return equals((VolcanoCost) obj);
137139
}

core/src/main/java/org/apache/calcite/plan/volcano/VolcanoRelMetadataProvider.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import com.google.common.collect.ImmutableMultimap;
2727
import com.google.common.collect.Multimap;
2828

29+
import org.checkerframework.checker.nullness.qual.Nullable;
30+
2931
import java.lang.reflect.Method;
3032

3133
/**
@@ -35,7 +37,7 @@
3537
public class VolcanoRelMetadataProvider implements RelMetadataProvider {
3638
//~ Methods ----------------------------------------------------------------
3739

38-
@Override public boolean equals(Object obj) {
40+
@Override public boolean equals(@Nullable Object obj) {
3941
return obj instanceof VolcanoRelMetadataProvider;
4042
}
4143

core/src/main/java/org/apache/calcite/prepare/RelOptTableImpl.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060

6161
import com.google.common.collect.ImmutableList;
6262

63+
import org.checkerframework.checker.nullness.qual.Nullable;
64+
6365
import java.util.AbstractList;
6466
import java.util.Collection;
6567
import java.util.List;
@@ -221,7 +223,7 @@ public Expression getExpression(Class clazz) {
221223
extendedTable, expressionFunction, getRowCount());
222224
}
223225

224-
@Override public boolean equals(Object obj) {
226+
@Override public boolean equals(@Nullable Object obj) {
225227
return obj instanceof RelOptTableImpl
226228
&& this.rowType.equals(((RelOptTableImpl) obj).getRowType())
227229
&& this.table == ((RelOptTableImpl) obj).table;

core/src/main/java/org/apache/calcite/profile/Profiler.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import com.google.common.collect.ImmutableMap;
2626
import com.google.common.collect.ImmutableSortedSet;
2727

28+
import org.checkerframework.checker.nullness.qual.Nullable;
29+
2830
import java.math.BigDecimal;
2931
import java.math.MathContext;
3032
import java.math.RoundingMode;
@@ -81,7 +83,7 @@ static ImmutableBitSet toOrdinals(Iterable<Column> columns) {
8183
return ordinal;
8284
}
8385

84-
@Override public boolean equals(Object o) {
86+
@Override public boolean equals(@Nullable Object o) {
8587
return this == o
8688
|| o instanceof Column
8789
&& ordinal == ((Column) o).ordinal;

core/src/main/java/org/apache/calcite/profile/ProfilerImpl.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
import com.google.common.collect.Ordering;
3535
import com.yahoo.sketches.hll.HllSketch;
3636

37+
import org.checkerframework.checker.nullness.qual.Nullable;
38+
3739
import java.nio.ByteBuffer;
3840
import java.nio.charset.StandardCharsets;
3941
import java.util.ArrayDeque;
@@ -465,7 +467,7 @@ static class Space {
465467
return columnOrdinals.hashCode();
466468
}
467469

468-
@Override public boolean equals(Object o) {
470+
@Override public boolean equals(@Nullable Object o) {
469471
return o == this
470472
|| o instanceof Space
471473
&& columnOrdinals.equals(((Space) o).columnOrdinals);

0 commit comments

Comments
 (0)