Skip to content

Commit

Permalink
Annotate equals methods with Nullable in src/core/main
Browse files Browse the repository at this point in the history
  • Loading branch information
vlsi committed Aug 31, 2020
1 parent 8391c91 commit 1d4a816
Show file tree
Hide file tree
Showing 109 changed files with 329 additions and 125 deletions.
1 change: 1 addition & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ dependencies {
implementation("net.hydromatic:aggdesigner-algorithm")
implementation("org.apache.commons:commons-dbcp2")
implementation("org.apache.commons:commons-lang3")
implementation("org.checkerframework:checker-qual")
implementation("commons-io:commons-io")
implementation("org.codehaus.janino:commons-compiler")
implementation("org.codehaus.janino:janino")
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/org/apache/calcite/interpreter/Row.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.calcite.interpreter;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.Arrays;

/**
Expand Down Expand Up @@ -64,7 +66,7 @@ public static Row of(Object...values) {
return Arrays.hashCode(values);
}

@Override public boolean equals(Object obj) {
@Override public boolean equals(@Nullable Object obj) {
return obj == this
|| obj instanceof Row
&& Arrays.equals(values, ((Row) obj).values);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.apache.calcite.rel.type.RelDataTypeField;
import org.apache.calcite.rel.type.RelRecordType;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.List;
import java.util.Objects;

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

@Override public boolean equals(Object obj) {
@Override public boolean equals(@Nullable Object obj) {
return this == obj
|| obj instanceof JavaRecordType
&& fieldList.equals(((JavaRecordType) obj).fieldList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ public int compareTo(@Nonnull Measure measure) {
return Objects.hash(agg, args);
}

@Override public boolean equals(Object obj) {
@Override public boolean equals(@Nullable Object obj) {
return obj == this
|| obj instanceof Measure
&& this.agg.equals(((Measure) obj).agg)
Expand Down Expand Up @@ -664,7 +664,7 @@ public int compareTo(Column column) {
return ordinal;
}

@Override public boolean equals(Object obj) {
@Override public boolean equals(@Nullable Object obj) {
return obj == this
|| obj instanceof Column
&& this.ordinal == ((Column) obj).ordinal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ public int hashCode() {
return ordinalInQuery;
}

public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
return this == obj
|| obj instanceof TableRef
&& ordinalInQuery == ((TableRef) obj).ordinalInQuery;
Expand All @@ -658,7 +658,7 @@ private static class StepRef extends DefaultEdge {
return ordinalInQuery;
}

@Override public boolean equals(Object obj) {
@Override public boolean equals(@Nullable Object obj) {
return this == obj
|| obj instanceof StepRef
&& ((StepRef) obj).ordinalInQuery == ordinalInQuery;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.apache.calcite.rel.type.RelDataTypeField;
import org.apache.calcite.util.Util;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.Objects;
import javax.annotation.Nonnull;

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

@Override public boolean equals(Object obj) {
@Override public boolean equals(@Nullable Object obj) {
return this == obj
|| obj instanceof LatticeTable
&& t.getQualifiedName().equals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -97,7 +99,7 @@ static class QueryKey {
this.path = path;
}

@Override public boolean equals(Object obj) {
@Override public boolean equals(@Nullable Object obj) {
return obj == this
|| obj instanceof QueryKey
&& sql.equals(((QueryKey) obj).sql)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.calcite.materialize;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.io.Serializable;
import java.util.UUID;

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

@Override public boolean equals(Object obj) {
@Override public boolean equals(@Nullable Object obj) {
return this == obj
|| obj instanceof MaterializationKey
&& uuid.equals(((MaterializationKey) obj).uuid);
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/org/apache/calcite/materialize/Path.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import com.google.common.collect.ImmutableList;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.List;

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

@Override public boolean equals(Object obj) {
@Override public boolean equals(@Nullable Object obj) {
return this == obj
|| obj instanceof Path
&& id == ((Path) obj).id;
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/org/apache/calcite/materialize/Step.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Ordering;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.List;
import java.util.Objects;

Expand Down Expand Up @@ -68,7 +70,7 @@ static Step create(LatticeTable source, LatticeTable target,
return Objects.hash(source, target, keys);
}

@Override public boolean equals(Object obj) {
@Override public boolean equals(@Nullable Object obj) {
return this == obj
|| obj instanceof Step
&& ((Step) obj).source.equals(source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import com.google.common.collect.ImmutableList;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.Objects;

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

@Override public boolean equals(Object obj) {
@Override public boolean equals(@Nullable Object obj) {
return obj == this
|| obj instanceof TileKey
&& lattice == ((TileKey) obj).lattice
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Ordering;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -78,7 +80,7 @@ public RelTraitDef getTraitDef() {
return Arrays.hashCode(traits);
}

@Override public boolean equals(Object obj) {
@Override public boolean equals(@Nullable Object obj) {
return this == obj
|| obj instanceof RelCompositeTrait
&& Arrays.equals(traits, ((RelCompositeTrait) obj).traits);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.calcite.plan;

import org.checkerframework.checker.nullness.qual.Nullable;

/**
* RelOptCostImpl provides a default implementation for the {@link RelOptCost}
* interface. It it defined in terms of a single scalar quantity; somewhat
Expand Down Expand Up @@ -76,7 +78,7 @@ public boolean equals(RelOptCost other) {
return getRows() == other.getRows();
}

@Override public boolean equals(Object obj) {
@Override public boolean equals(@Nullable Object obj) {
if (obj instanceof RelOptCostImpl) {
return equals((RelOptCost) obj);
}
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/org/apache/calcite/plan/RelOptRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -462,7 +464,7 @@ public int hashCode() {
return description.hashCode();
}

public boolean equals(Object obj) {
@Override public boolean equals(@Nullable Object obj) {
return (obj instanceof RelOptRule)
&& equals((RelOptRule) obj);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import com.google.common.collect.ImmutableList;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
Expand Down Expand Up @@ -170,7 +172,7 @@ public int hashCode() {
return Objects.hash(clazz, trait, children);
}

public boolean equals(Object obj) {
@Override public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/org/apache/calcite/plan/RelTraitSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

import com.google.common.collect.ImmutableList;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.AbstractList;
import java.util.Arrays;
import java.util.HashMap;
Expand Down Expand Up @@ -420,7 +422,7 @@ public <T extends RelTrait> T canonize(T trait) {
* @param obj another RelTraitSet
* @return true if traits are equal and in the same order, false otherwise
*/
@Override public boolean equals(Object obj) {
@Override public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.lang.reflect.Method;

/**
Expand All @@ -35,7 +37,7 @@
class HepRelMetadataProvider implements RelMetadataProvider {
//~ Methods ----------------------------------------------------------------

@Override public boolean equals(Object obj) {
@Override public boolean equals(@Nullable Object obj) {
return obj instanceof HepRelMetadataProvider;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.apache.calcite.plan.RelOptCostFactory;
import org.apache.calcite.plan.RelOptUtil;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.Objects;

/**
Expand Down Expand Up @@ -131,7 +133,7 @@ public boolean equals(RelOptCost other) {
&& (this.io == ((VolcanoCost) other).io);
}

@Override public boolean equals(Object obj) {
@Override public boolean equals(@Nullable Object obj) {
if (obj instanceof VolcanoCost) {
return equals((VolcanoCost) obj);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.lang.reflect.Method;

/**
Expand All @@ -35,7 +37,7 @@
public class VolcanoRelMetadataProvider implements RelMetadataProvider {
//~ Methods ----------------------------------------------------------------

@Override public boolean equals(Object obj) {
@Override public boolean equals(@Nullable Object obj) {
return obj instanceof VolcanoRelMetadataProvider;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@

import com.google.common.collect.ImmutableList;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.AbstractList;
import java.util.Collection;
import java.util.List;
Expand Down Expand Up @@ -221,7 +223,7 @@ public Expression getExpression(Class clazz) {
extendedTable, expressionFunction, getRowCount());
}

@Override public boolean equals(Object obj) {
@Override public boolean equals(@Nullable Object obj) {
return obj instanceof RelOptTableImpl
&& this.rowType.equals(((RelOptTableImpl) obj).getRowType())
&& this.table == ((RelOptTableImpl) obj).table;
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/org/apache/calcite/profile/Profiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSortedSet;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
Expand Down Expand Up @@ -81,7 +83,7 @@ static ImmutableBitSet toOrdinals(Iterable<Column> columns) {
return ordinal;
}

@Override public boolean equals(Object o) {
@Override public boolean equals(@Nullable Object o) {
return this == o
|| o instanceof Column
&& ordinal == ((Column) o).ordinal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import com.google.common.collect.Ordering;
import com.yahoo.sketches.hll.HllSketch;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayDeque;
Expand Down Expand Up @@ -465,7 +467,7 @@ static class Space {
return columnOrdinals.hashCode();
}

@Override public boolean equals(Object o) {
@Override public boolean equals(@Nullable Object o) {
return o == this
|| o instanceof Space
&& columnOrdinals.equals(((Space) o).columnOrdinals);
Expand Down
Loading

0 comments on commit 1d4a816

Please sign in to comment.