Skip to content

Commit

Permalink
[CALCITE-4314] Suppress the current CatchAndPrintStackTrace, MissingS…
Browse files Browse the repository at this point in the history
…ummary, etc
  • Loading branch information
vlsi committed Oct 6, 2020
1 parent 5bf678e commit 1552765
Show file tree
Hide file tree
Showing 28 changed files with 37 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static EnumerableTableScan create(RelOptCluster cluster,

/** Returns whether EnumerableTableScan can generate code to handle a
* particular variant of the Table SPI.
* @deprecated
* @deprecated remove before Calcite 2.0
**/
@Deprecated
public static boolean canHandle(Table table) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public JdbcImplementor(SqlDialect dialect, JavaTypeFactory typeFactory) {

// CHECKSTYLE: IGNORE 1
/** @see #dispatch */
@SuppressWarnings("MissingSummary")
public Result visit(JdbcTableScan scan) {
return result(scan.jdbcTable.tableName(),
ImmutableList.of(Clause.FROM), scan, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ private Bindables() {}

// CHECKSTYLE: IGNORE 1
/** @deprecated Use {@link #BINDABLE_SET_OP_RULE}. */
@SuppressWarnings("MissingSummary")
public static final RelOptRule BINDABLE_SETOP_RULE =
BINDABLE_SET_OP_RULE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ private RelNode optimize(RelNode rootRel) {
};
}

@SuppressWarnings("CatchAndPrintStackTrace")
private void start() {
// We rely on the nodes being ordered leaves first.
for (Map.Entry<RelNode, NodeInfo> entry : nodes.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CachingLatticeStatisticProvider implements LatticeStatisticProvider {
CachingLatticeStatisticProvider(final Lattice lattice,
final LatticeStatisticProvider provider) {
this.lattice = lattice;
cache = CacheBuilder.<Lattice.Column>newBuilder().build(
cache = CacheBuilder.newBuilder().build(
CacheLoader.from(key -> provider.cardinality(ImmutableList.of(key))));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,11 @@ public RelOptPredicateList getPredicates(Exchange exchange,
}

// CHECKSTYLE: IGNORE 1
/** @see RelMetadataQuery#getPulledUpPredicates(RelNode) */
/**
* Returns the
* {@link BuiltInMetadata.Predicates#getPredicates()}
* statistic.
* @see RelMetadataQuery#getPulledUpPredicates(RelNode) */
public RelOptPredicateList getPredicates(RelSubset r,
RelMetadataQuery mq) {
if (!Bug.CALCITE_1048_FIXED) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public Double getRowCount(RelNode rel, RelMetadataQuery mq) {
return rel.estimateRowCount(mq);
}

@SuppressWarnings("CatchAndPrintStackTrace")
public Double getRowCount(RelSubset subset, RelMetadataQuery mq) {
if (!Bug.CALCITE_1048_FIXED) {
return mq.getRowCount(Util.first(subset.getBest(), subset.getOriginal()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,7 @@ private ComparableEmptyList() {
*
* @param <T> element type
*/
@SuppressWarnings("ComparableType")
public interface ComparableList<T> extends List<T>, Comparable<List> {
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/apache/calcite/runtime/Hook.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public <T> Closeable add(final Consumer<T> handler) {

// CHECKSTYLE: IGNORE 1
/** @deprecated Use {@link #add(Consumer)}. */
@SuppressWarnings("Guava")
@SuppressWarnings({"Guava", "ReturnValueIgnored"})
@Deprecated // to be removed before 2.0
public <T, R> Closeable add(final Function<T, R> handler) {
return add((Consumer<T>) handler::apply);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2429,7 +2429,7 @@ public static long currentTimestamp(DataContext root) {
public static int currentTime(DataContext root) {
int time = (int) (currentTimestamp(root) % DateTimeUtils.MILLIS_PER_DAY);
if (time < 0) {
time += DateTimeUtils.MILLIS_PER_DAY;
time = (int) (time + DateTimeUtils.MILLIS_PER_DAY);
}
return time;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/**
* Socket factory that trusts all SSL connections.
*/
@SuppressWarnings("CatchAndPrintStackTrace")
public class TrustAllSslSocketFactory extends SocketFactoryImpl {
private static final TrustAllSslSocketFactory DEFAULT =
new TrustAllSslSocketFactory();
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/org/apache/calcite/sql/SqlNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@ public abstract class SqlNode implements Cloneable {
/** @deprecated Please use {@link #clone(SqlNode)}; this method brings
* along too much baggage from early versions of Java */
@Deprecated
@SuppressWarnings("MethodDoesntCallSuperMethod")
@SuppressWarnings({"MethodDoesntCallSuperMethod", "AmbiguousMethodReference"})
@Override public Object clone() {
return clone(getParserPosition());
}

/** Creates a copy of a SqlNode. */
@SuppressWarnings("AmbiguousMethodReference")
public static <E extends SqlNode> E clone(E e) {
//noinspection unchecked
return (E) e.clone(e.pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public int[][] getExpectedTokenSequences() {
}

// override Exception
@Override public Throwable getCause() {
@Override public synchronized Throwable getCause() {
return parserException;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ && canConvertStringInCompare(family1)) {
}

/** Returns the least restrictive type T, such that a value of type T can be
* compared with values of type {@code type0} and {@code type1} using
* compared with values of type {@code type1} and {@code type2} using
* {@code =}. */
public static RelDataType leastRestrictiveForComparison(
RelDataTypeFactory typeFactory, RelDataType type1, RelDataType type2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2778,9 +2778,11 @@ private CorelMap(Multimap<RelNode, CorRef> mapRefRelToCorRef,
+ "\n";
}

@SuppressWarnings("UndefinedEquals")
@Override public boolean equals(Object obj) {
return obj == this
|| obj instanceof CorelMap
// TODO: Multimap does not have well-defined equals behavior
&& mapRefRelToCorRef.equals(((CorelMap) obj).mapRefRelToCorRef)
&& mapCorToCorRel.equals(((CorelMap) obj).mapCorToCorRel)
&& mapFieldAccessToCorRef.equals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* makes instantiating one of these (or a sub-class) more efficient.</p>
*/
public class ControlFlowException extends RuntimeException {
@Override public Throwable fillInStackTrace() {
@Override public synchronized Throwable fillInStackTrace() {
return this;
}
}
1 change: 1 addition & 0 deletions core/src/main/java/org/apache/calcite/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,7 @@ public static Error newInternal(Throwable e) {
/** @deprecated Throw new {@link AssertionError} if applicable;
* or {@link RuntimeException} if e is checked;
* or raw exception if e is unchecked or {@link Error}. */
@SuppressWarnings("MissingSummary")
public static Error newInternal(Throwable e, String s) {
return new AssertionError("Internal error: " + s, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ private static DruidJsonFilter toBetweenDruidFilter(RexNode rexNode, RelDataType
return null;
}
final boolean isNumeric = lhs.getType().getFamily() == SqlTypeFamily.NUMERIC
|| lhs.getType().getFamily() == SqlTypeFamily.NUMERIC;
|| rhs.getType().getFamily() == SqlTypeFamily.NUMERIC;
final Pair<String, ExtractionFunction> druidColumn = DruidQuery
.toDruidColumn(refNode, rowType, query);
final String columnName = druidColumn.left;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,15 +589,15 @@ public DruidTable getDruidTable() {
}

private double getIntervalCostMultiplier() {
int days = 0;
long days = 0;
for (Interval interval : intervals) {
days += interval.toDuration().getStandardDays();
}
// Cost increases with the wider interval being queries.
// A plan querying 10 or more years of data will have 10x the cost of a
// plan returning 1 day data.
// A plan where least interval is queries will be preferred.
return RelMdUtil.linear(days, 1, DAYS_IN_TEN_YEARS, 0.1d, 1d);
return RelMdUtil.linear((int) days, 1, DAYS_IN_TEN_YEARS, 0.1d, 1d);
}

private double getQueryTypeCostMultiplier() {
Expand Down Expand Up @@ -1196,7 +1196,7 @@ private String planAsTimeSeries(List<DimensionSpec> groupByKeyDims, DruidJsonFil
// cannot use timeseries
boolean hasExpressionOnTopOfTimeExtract = false;
for (JsonExpressionPostAgg postAgg : postAggregations) {
if (postAgg instanceof JsonExpressionPostAgg) {
if (postAgg != null) {
if (postAgg.expression.contains(groupByKeyDims.get(0).getOutputName())) {
hasExpressionOnTopOfTimeExtract = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static DruidType getTypeFromMetric(String type) {
}

/** Returns a DruidType matching the String from a meta data query. */
protected static DruidType getTypeFromMetaData(String type) {
static DruidType getTypeFromMetaData(String type) {
assert type != null;
switch (type) {
case "LONG":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ void closeScroll(Iterable<String> scrollIds) {
try {
final String json = mapper().writeValueAsString(payload);
request.setEntity(new StringEntity(json, ContentType.APPLICATION_JSON));
rawHttp().apply(request);
@SuppressWarnings("unused")
Response response = rawHttp().apply(request);
} catch (IOException | UncheckedIOException e) {
LOGGER.warn("Failed to close scroll(s): {}", scrollIds, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ private static String convertQueryString(List<Expression> fields, Expression que
Preconditions.checkArgument(query instanceof LiteralExpression,
"Query string must be a string literal");
String queryString = ((LiteralExpression) query).stringValue();
@SuppressWarnings("ModifiedButNotUsed")
Map<String, String> fieldMap = new LinkedHashMap<>();
for (Expression expr : fields) {
if (expr instanceof NamedFieldExpression) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -101,7 +100,7 @@ public GeodeAggregate(RelOptCluster cluster,
geodeImplementContext.addGroupBy(groupByFields);

// Find the aggregate functions (e.g. MAX, SUM ...)
Builder<String, String> aggregateFunctionMap = ImmutableMap.builder();
ImmutableMap.Builder<String, String> aggregateFunctionMap = ImmutableMap.builder();
for (AggregateCall aggCall : aggCalls) {

List<String> aggCallFieldNames = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.apache.geode.cache.query.SelectResults;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
import com.google.common.collect.ImmutableMap;

import org.slf4j.Logger;
Expand Down Expand Up @@ -129,7 +128,7 @@ public Enumerable<Object> query(final GemFireCache clientCache,
}

// Construct the list of fields to project
Builder<String> selectBuilder = ImmutableList.builder();
ImmutableList.Builder<String> selectBuilder = ImmutableList.builder();
if (!groupByFields.isEmpty()) {
// manually add GROUP BY to select clause (GeodeProjection was not visited)
for (String groupByField : groupByFields) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ private static Object handlePdxInstanceEntry(
return values;
}

@SuppressWarnings("CatchAndPrintStackTrace")
private static Object handleJavaObjectEntry(
List<RelDataTypeField> relDataTypeFields, Object obj) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ private static String model() {
}

/** Main entry point. */
@SuppressWarnings("CatchAndPrintStackTrace")
public static void main(String[] args) {
try (PrintWriter err =
new PrintWriter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected SplunkDriver() {
private static class MockSplunkConnection implements SplunkConnection {
@Override public Enumerator<Object> getSearchResultEnumerator(String search,
Map<String, String> otherArgs, List<String> fieldList) {
throw null;
throw new NullPointerException();
}

@Override public void getSearchResults(String search, Map<String, String> otherArgs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private static void close(Closeable c) {
}
}

@SuppressWarnings("CatchAndPrintStackTrace")
private void connect() {
BufferedReader rd = null;

Expand Down

0 comments on commit 1552765

Please sign in to comment.