Skip to content

Commit

Permalink
[CALCITE-6609] Remove redundant warning suppression for Guava's Beta …
Browse files Browse the repository at this point in the history
…and Unstable APIs
  • Loading branch information
zabetak committed Oct 3, 2024
1 parent 60e0a3f commit 331c2c1
Show file tree
Hide file tree
Showing 22 changed files with 7 additions and 44 deletions.
2 changes: 0 additions & 2 deletions core/src/main/java/org/apache/calcite/plan/RelTraitDef.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public abstract class RelTraitDef<T extends RelTrait> {
*
* <p>Uses weak interner to allow GC.
*/
@SuppressWarnings("BetaApi")
private final Interner<T> interner = Interners.newWeakInterner();

//~ Constructors -----------------------------------------------------------
Expand Down Expand Up @@ -98,7 +97,6 @@ public boolean multiple() {
* @param trait a possibly non-canonical RelTrait
* @return a canonical RelTrait.
*/
@SuppressWarnings("BetaApi")
public final T canonize(T trait) {
if (!(trait instanceof RelCompositeTrait)) {
assert getTraitClass().isInstance(trait)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ public Object toJson(AggregateCall node) {
return map;
}

@SuppressWarnings({"BetaApi", "UnstableApiUsage"}) // RangeSet GA in Guava 32
public @Nullable Object toJson(@Nullable Object value) {
if (value == null
|| value instanceof Number
Expand Down Expand Up @@ -507,7 +506,6 @@ public <C extends Comparable<C>> Object toJson(Sarg<C> node) {
return map;
}

@SuppressWarnings({"BetaApi", "UnstableApiUsage"}) // RangeSet GA in Guava 32
public <C extends Comparable<C>> List<List<String>> toJson(
RangeSet<C> rangeSet) {
final List<List<String>> list = new ArrayList<>();
Expand Down Expand Up @@ -879,8 +877,6 @@ public RexNode toRex(RelOptCluster cluster, Object o) {
* nullAs: "UNKNOWN"}} represents the range x &ge; 0 and x &le; 5 or
* x &gt; 10.
*/
// BetaApi is no longer a concern; the Beta tag was removed in Guava 32.0
@SuppressWarnings({"BetaApi", "unchecked"})
public static <C extends Comparable<C>> Sarg<C> sargFromJson(
Map<String, Object> map) {
final String nullAs = requireNonNull((String) map.get("nullAs"), "nullAs");
Expand All @@ -891,7 +887,6 @@ public static <C extends Comparable<C>> Sarg<C> sargFromJson(
}

/** Converts a JSON list to a {@link RangeSet}. */
@SuppressWarnings({"BetaApi", "UnstableApiUsage"}) // RangeSet GA in Guava 32
public static <C extends Comparable<C>> RangeSet<C> rangeSetFromJson(
List<List<String>> rangeSetsJson) {
final ImmutableRangeSet.Builder<C> builder = ImmutableRangeSet.builder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,6 @@ protected RexCall reverseCall(RexCall call) {

/** Converts a Sarg to SQL, generating "operand IN (c1, c2, ...)" if the
* ranges are all points. */
@SuppressWarnings({"BetaApi", "UnstableApiUsage"})
private <C extends Comparable<C>> SqlNode toSql(@Nullable RexProgram program,
RexNode operand, RelDataType type, Sarg<C> sarg) {
final List<SqlNode> orList = new ArrayList<>();
Expand Down Expand Up @@ -946,7 +945,6 @@ private <C extends Comparable<C>> SqlNode toSql(@Nullable RexProgram program,
return SqlUtil.createCall(SqlStdOperatorTable.OR, POS, orList);
}

@SuppressWarnings("BetaApi")
private <C extends Comparable<C>> SqlNode toIn(SqlNode operandSql,
SqlBinaryOperator eqOp, SqlBinaryOperator inOp,
@Nullable RexProgram program, RelDataType type, RangeSet<C> rangeSet) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ static ImmutableSortedSet<TimeUnitRange> extractTimeUnits(RexNode e) {

/** Replaces calls to EXTRACT, FLOOR and CEIL in an expression. */
@VisibleForTesting
@SuppressWarnings("BetaApi")
public static RexNode replaceTimeUnits(RexBuilder rexBuilder, RexNode e,
String timeZone) {
ImmutableSortedSet<TimeUnitRange> timeUnits = extractTimeUnits(e);
Expand Down Expand Up @@ -277,7 +276,6 @@ private ExtractFinder() {
/** Walks over an expression, replacing calls to
* {@code EXTRACT}, {@code FLOOR} and {@code CEIL} with date ranges. */
@VisibleForTesting
@SuppressWarnings("BetaApi")
static class ExtractShuttle extends RexShuttle {
private final RexBuilder rexBuilder;
private final TimeUnitRange timeUnit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public abstract class RelDataTypeFactoryImpl implements RelDataTypeFactory {
/**
* Global cache for RelDataType.
*/
@SuppressWarnings("BetaApi")
private static final Interner<RelDataType> DATATYPE_CACHE =
Interners.newWeakInterner();

Expand Down Expand Up @@ -417,7 +416,6 @@ private RelDataType copyRecordType(
*
* @throws NullPointerException if type is null
*/
@SuppressWarnings("BetaApi")
protected RelDataType canonize(final RelDataType type) {
return DATATYPE_CACHE.intern(type);
}
Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/org/apache/calcite/rex/RexAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public RexAnalyzer(RexNode e, RelOptPredicateList predicates) {

/** Generates a map of variables and lists of values that could be assigned
* to them. */
@SuppressWarnings("BetaApi")
public Iterable<Map<RexNode, Comparable>> assignments() {
final List<List<Comparable>> generators =
variables.stream().map(RexAnalyzer::getComparables)
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/org/apache/calcite/rex/RexBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -1786,7 +1786,6 @@ private static boolean areAssignable(RexNode arg, List<? extends RexNode> bounds
* <p>If the expressions are all literals of compatible type, creates a call
* to {@link Sarg} literal, {@code SEARCH(arg, SARG([lower..upper])};
* otherwise creates a disjunction, {@code arg >= lower AND arg <= upper}. */
@SuppressWarnings("BetaApi")
public RexNode makeBetween(RexNode arg, RexNode lower, RexNode upper) {
final Comparable lowerValue = toComparable(Comparable.class, lower);
final Comparable upperValue = toComparable(Comparable.class, upper);
Expand All @@ -1811,7 +1810,6 @@ && areAssignable(arg, Arrays.asList(lower, upper))) {

/** Converts a list of expressions to a search argument, or returns null if
* not possible. */
@SuppressWarnings({"BetaApi", "UnstableApiUsage"})
private static <C extends Comparable<C>> @Nullable Sarg<C> toSarg(Class<C> clazz,
List<? extends RexNode> ranges, RexUnknownAs unknownAs) {
if (ranges.isEmpty()) {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/apache/calcite/rex/RexInterpreter.java
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ private Comparable similar(List<Comparable> values) {
}
}

@SuppressWarnings({"BetaApi", "rawtypes", "unchecked", "UnstableApiUsage"})
@SuppressWarnings({"rawtypes", "unchecked"})
private static Comparable search(SqlTypeName typeName, List<Comparable> values) {
final Comparable value = values.get(0);
final Sarg sarg = (Sarg) values.get(1);
Expand All @@ -316,7 +316,7 @@ private static Comparable search(SqlTypeName typeName, List<Comparable> values)
/** Translates the values in a RangeSet from literal format to runtime format.
* For example the DATE SQL type uses DateString for literals and Integer at
* runtime. */
@SuppressWarnings({"BetaApi", "rawtypes", "unchecked", "UnstableApiUsage"})
@SuppressWarnings({"rawtypes", "unchecked"})
private static RangeSet translate(RangeSet rangeSet, SqlTypeName typeName) {
switch (typeName) {
case DATE:
Expand Down
8 changes: 2 additions & 6 deletions core/src/main/java/org/apache/calcite/rex/RexSimplify.java
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,6 @@ private <C extends Comparable<C>> RexNode simplifyAnd2ForUnknownAsFalse(
return RexUtil.composeConjunction(rexBuilder, terms);
}

@SuppressWarnings("BetaApi")
private <C extends Comparable<C>> RexNode simplifyUsingPredicates(RexNode e,
Class<C> clazz) {
if (predicates.pulledUpPredicates.isEmpty()) {
Expand Down Expand Up @@ -1904,7 +1903,6 @@ private <C extends Comparable<C>> RexNode simplifyUsingPredicates(RexNode e,
* <li>{@code residue($0 < 10, [$0 < 20, $0 > 0])} returns {@code $0 < 10}
* </ul>
*/
@SuppressWarnings("BetaApi")
private static <C extends Comparable<C>> RangeSet<C> residue(RexNode ref,
RangeSet<C> r0, List<RexNode> predicates, Class<C> clazz) {
RangeSet<C> result = r0;
Expand Down Expand Up @@ -2680,7 +2678,6 @@ private static <C extends Comparable<C>> Range<C> range(SqlKind comparison,
}
}

@SuppressWarnings("BetaApi")
private static <C extends Comparable<C>> RangeSet<C> rangeSet(SqlKind comparison,
C c) {
switch (comparison) {
Expand Down Expand Up @@ -3118,7 +3115,6 @@ static RexNode fix(RexBuilder rexBuilder, RexNode term,
* {@code TRUE OR UNKNOWN OR FALSE} returns {@code TRUE};
* {@code UNKNOWN OR FALSE OR UNKNOWN} returns {@code UNKNOWN};
* {@code FALSE OR FALSE} returns {@code FALSE}. */
@SuppressWarnings("BetaApi")
private static class RexSargBuilder extends RexNode {
final RexNode ref;
final RexBuilder rexBuilder;
Expand All @@ -3144,7 +3140,7 @@ <C extends Comparable<C>> Sarg<C> build() {
return build(negate);
}

@SuppressWarnings({"rawtypes", "unchecked", "UnstableApiUsage"})
@SuppressWarnings({"rawtypes", "unchecked"})
<C extends Comparable<C>> Sarg<C> build(boolean negate) {
final RangeSet<C> r = (RangeSet) this.rangeSet;
if (negate) {
Expand Down Expand Up @@ -3192,7 +3188,7 @@ void addRange(Range<Comparable> range, RelDataType type) {
nullAs = nullAs.or(UNKNOWN);
}

@SuppressWarnings({"UnstableApiUsage", "rawtypes", "unchecked"})
@SuppressWarnings({"rawtypes", "unchecked"})
void addSarg(Sarg sarg, boolean negate, RelDataType type) {
final RangeSet r;
final RexUnknownAs nullAs;
Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/org/apache/calcite/rex/RexUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,6 @@ public static RexShuttle searchShuttle(RexBuilder rexBuilder,
return new SearchExpandingShuttle(program, rexBuilder, maxComplexity);
}

@SuppressWarnings("BetaApi")
public static <C extends Comparable<C>> RexNode sargRef(RexBuilder rexBuilder,
RexNode ref, Sarg<C> sarg, RelDataType type, RexUnknownAs unknownAs) {
if (sarg.isAll() || sarg.isNone()) {
Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/org/apache/calcite/sql/SqlUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,6 @@ public static Charset getCharset(String charsetName) {
* @throws RuntimeException If the given value cannot be represented in the
* given charset
*/
@SuppressWarnings("BetaApi")
public static void validateCharset(ByteString value, Charset charset) {
if (charset == StandardCharsets.UTF_8) {
final byte[] bytes = value.getBytes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@
* <p>The public entry points are: {@link #convertQuery},
* {@link #convertExpression(SqlNode)}.
*/
@SuppressWarnings("UnstableApiUsage")
@Value.Enclosing
public class SqlToRelConverter {
//~ Static fields/initializers ---------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/org/apache/calcite/util/RangeSets.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@
import static java.util.Objects.requireNonNull;

/** Utilities for Guava {@link com.google.common.collect.RangeSet}. */
@SuppressWarnings({"BetaApi", "UnstableApiUsage"})
public class RangeSets {
private RangeSets() {}

@SuppressWarnings({"BetaApi", "rawtypes"})
@SuppressWarnings("rawtypes")
private static final ImmutableRangeSet ALL =
ImmutableRangeSet.of().complement();

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/apache/calcite/util/Sarg.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
*
* @see SqlStdOperatorTable#SEARCH
*/
@SuppressWarnings({"BetaApi", "type.argument.type.incompatible", "UnstableApiUsage"})
@SuppressWarnings("type.argument.type.incompatible")
public class Sarg<C extends Comparable<C>> implements Comparable<Sarg<C>> {
public final RangeSet<C> rangeSet;
public final RexUnknownAs nullAs;
Expand Down
3 changes: 0 additions & 3 deletions core/src/test/java/org/apache/calcite/rex/RexProgramTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,6 @@ private void checkExponentialCnf(int n) {
"false");
}

@SuppressWarnings("UnstableApiUsage")
@Test void testRangeSetMinus() {
final RangeSet<Integer> setNone = ImmutableRangeSet.of();
final RangeSet<Integer> setAll = setNone.complement();
Expand Down Expand Up @@ -3359,7 +3358,6 @@ private void checkSarg(String message, Sarg sarg,
}

/** Tests {@link Sarg#complexity()}. */
@SuppressWarnings("UnstableApiUsage")
@Test void testSargComplexity() {
checkSarg("complexity of 'x is not null'",
Sarg.of(RexUnknownAs.FALSE, RangeSets.<Integer>rangeSetAll()),
Expand Down Expand Up @@ -3424,7 +3422,6 @@ private void checkSarg(String message, Sarg sarg,
* <a href="https://issues.apache.org/jira/browse/CALCITE-5722">[CALCITE-5722]
* {@code Sarg.isComplementedPoints} fails with anti-points which are equal
* under {@code compareTo} but not {@code equals}</a>. */
@SuppressWarnings("UnstableApiUsage")
@Test void testSargAntiPoint() {
final Sarg<BigDecimal> sarg =
Sarg.of(RexUnknownAs.UNKNOWN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ public RexNode fuzzCase(Random r, int depth, Function<Random, RexNode> resultFac
return case_(args);
}

@SuppressWarnings("UnstableApiUsage")
public RexNode fuzzSearch(Random r, RexNode intExpression) {
final RangeSet<BigDecimal> rangeSet = TreeRangeSet.create();
final Generator<BigDecimal> integerGenerator = RexFuzzer::fuzzInt;
Expand Down
2 changes: 0 additions & 2 deletions core/src/test/java/org/apache/calcite/util/RangeSetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
* Unit test for {@link RangeSets} and other utilities relating to Guava
* {@link Range} and {@link RangeSet}.
*/
@SuppressWarnings("UnstableApiUsage")
class RangeSetTest {

/** Tests {@link org.apache.calcite.rel.externalize.RelJson#toJson(Range)}
Expand Down Expand Up @@ -107,7 +106,6 @@ class RangeSetTest {
}

/** Tests {@link RangeSets#minus(RangeSet, Range)}. */
@SuppressWarnings("UnstableApiUsage")
@Test void testRangeSetMinus() {
final RangeSet<Integer> setNone = ImmutableRangeSet.of();
final RangeSet<Integer> setAll = setNone.complement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ private DruidDateTimeUtils() {
* expression. Assumes that all the predicates in the input
* reference a single column: the timestamp column.
*/
@SuppressWarnings("BetaApi")
public static @Nullable List<Interval> createInterval(RexNode e) {
final List<Range<Long>> ranges = extractRanges(e, false);
if (ranges == null) {
Expand Down Expand Up @@ -166,7 +165,6 @@ protected static List<Interval> toInterval(
}
}

@SuppressWarnings("BetaApi")
protected static @Nullable List<Range<Long>> leafToRanges(RexCall call, boolean withNot) {
final ImmutableList.Builder<Range<Long>> ranges;
switch (call.getKind()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ protected DruidFilterRule(DruidFilterRuleConfig config) {
* 2-m) condition filters that can be pushed to Druid,
* 3-r) condition filters that cannot be pushed to Druid.
*/
@SuppressWarnings("BetaApi")
private static Triple<List<RexNode>, List<RexNode>, List<RexNode>> splitFilters(
final List<RexNode> validPreds,
final List<RexNode> nonValidPreds, final int timestampFieldIdx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,12 @@ static boolean canBeTranslatedToTermsQuery(RexCall search) {
return isSearchWithPoints(search) || isSearchWithComplementedPoints(search);
}

@SuppressWarnings("BetaApi")
static boolean isSearchWithPoints(RexCall search) {
RexLiteral literal = (RexLiteral) search.getOperands().get(1);
final Sarg<?> sarg = requireNonNull(literal.getValueAs(Sarg.class), "Sarg");
return sarg.isPoints();
}

@SuppressWarnings("BetaApi")
static boolean isSearchWithComplementedPoints(RexCall search) {
RexLiteral literal = (RexLiteral) search.getOperands().get(1);
final Sarg<?> sarg = requireNonNull(literal.getValueAs(Sarg.class), "Sarg");
Expand Down Expand Up @@ -1035,7 +1033,6 @@ String stringValue() {
return RexLiteral.stringValue(literal);
}

@SuppressWarnings("BetaApi")
List<Object> sargValue() {
final Sarg sarg = requireNonNull(literal.getValueAs(Sarg.class), "Sarg");
final RelDataType type = literal.getType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public static Matcher<RelNode> hasHints(final String value) {
* <p>This method is necessary because {@link RangeSet#toString()} changed
* behavior. Guava 19 - 28 used a unicode symbol; Guava 29 onwards uses "..".
*/
@SuppressWarnings({"BetaApi", "rawtypes"})
@SuppressWarnings("rawtypes")
public static Matcher<RangeSet> isRangeSet(final String value) {
return compose(Is.is(value), input -> sanitizeRangeSet(input.toString()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ public abstract class QuidemTest {
return m;
}

@SuppressWarnings({"BetaApi", "UnstableApiUsage"})
protected static Collection<String> data(String first) {
// inUrl = "file:/home/fred/calcite/core/target/test-classes/sql/agg.iq"
final URL inUrl = QuidemTest.class.getResource("/" + n2u(first));
Expand Down

0 comments on commit 331c2c1

Please sign in to comment.