Skip to content

Commit

Permalink
[CALCITE-4314] Suppress warnings on Guava's @beta API usage
Browse files Browse the repository at this point in the history
@beta APIs should not be used in library code as they are subject to change

See https://github.com/google/guava/wiki/PhilosophyExplained#beta-apis
  • Loading branch information
vlsi committed Oct 6, 2020
1 parent 2cbb0c4 commit 995b90b
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 4 deletions.
2 changes: 2 additions & 0 deletions core/src/main/java/org/apache/calcite/plan/RelTraitDef.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ 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 @@ -95,6 +96,7 @@ 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 @@ -857,7 +857,7 @@ public SqlNode toSql(RexProgram program, RexNode rex) {

/** Converts a Sarg to SQL, generating "operand IN (c1, c2, ...)" if the
* ranges are all points. */
@SuppressWarnings("UnstableApiUsage")
@SuppressWarnings({"BetaApi", "UnstableApiUsage"})
private <C extends Comparable<C>> SqlNode toSql(RexProgram program,
RexNode operand, RelDataType type, Sarg<C> sarg) {
final List<SqlNode> orList = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ 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 @@ -264,6 +265,7 @@ 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 @@ -61,6 +61,7 @@ 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 @@ -348,6 +349,7 @@ 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: 1 addition & 0 deletions core/src/main/java/org/apache/calcite/rex/RexAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ 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
3 changes: 2 additions & 1 deletion core/src/main/java/org/apache/calcite/rex/RexBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,7 @@ private 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 @@ -1370,7 +1371,7 @@ && areAssignable(arg, Arrays.asList(lower, upper))) {

/** Converts a list of expressions to a search argument, or returns null if
* not possible. */
@SuppressWarnings("UnstableApiUsage")
@SuppressWarnings({"BetaApi", "UnstableApiUsage"})
private static <C extends Comparable<C>> Sarg<C> toSarg(Class<C> clazz,
List<? extends RexNode> ranges, boolean containsNull) {
if (ranges.isEmpty()) {
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/java/org/apache/calcite/rex/RexSimplify.java
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,7 @@ 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 @@ -1689,6 +1690,7 @@ 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 <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 @@ -2352,6 +2354,7 @@ 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 @@ -2695,6 +2698,7 @@ RexNode fix(RexBuilder rexBuilder, RexNode term) {
*
* <p>The {@link SargCollector#fix} method converts it to an immutable
* literal. */
@SuppressWarnings("BetaApi")
static class RexSargBuilder extends RexNode {
final RexNode ref;
private final RexBuilder rexBuilder;
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/org/apache/calcite/rex/RexUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ public static RexNode expandSearch(RexBuilder rexBuilder,
return node.accept(shuttle);
}

@SuppressWarnings("BetaApi")
private static <C extends Comparable<C>> RexNode
visitSearch(RexBuilder rexBuilder,
@Nullable RexProgram program, RexCall call) {
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/org/apache/calcite/sql/SqlUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,7 @@ 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
4 changes: 2 additions & 2 deletions core/src/main/java/org/apache/calcite/util/RangeSets.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
import java.util.function.Function;

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

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

Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/org/apache/calcite/util/Sarg.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
*
* @see SqlStdOperatorTable#SEARCH
*/
@SuppressWarnings("BetaApi")
public class Sarg<C extends Comparable<C>> implements Comparable<Sarg<C>> {
public final RangeSet<C> rangeSet;
public final boolean containsNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ private DruidDateTimeUtils() {
* reference a single column: the timestamp column.
*/
@Nullable
@SuppressWarnings("BetaApi")
public static List<Interval> createInterval(RexNode e) {
final List<Range<Long>> ranges = extractRanges(e, false);
if (ranges == null) {
Expand Down Expand Up @@ -166,6 +167,7 @@ protected static List<Range<Long>> extractRanges(RexNode node, boolean withNot)
}

@Nullable
@SuppressWarnings("BetaApi")
protected static 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 @@ -258,6 +258,7 @@ protected DruidFilterRule(Config 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

0 comments on commit 995b90b

Please sign in to comment.