Improved the readability and fixed few java warnings (#9163)

* Improved the readability and fixed few java warnings

* Fix the checkstyle

Co-authored-by: Gian Merlino <gianmerlino@gmail.com>
This commit is contained in:
Srinivas Reddy 2020-02-22 06:30:11 +08:00 committed by GitHub
parent f707064bed
commit 05258dca37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 23 additions and 24 deletions

View File

@ -264,12 +264,7 @@ public class Expressions
rexNode,
postAggregatorVisitor
);
if (expression == null) {
return null;
} else {
return expression;
}
return expression;
}
}

View File

@ -48,7 +48,7 @@ public abstract class TimeArithmeticOperatorConversion implements SqlOperatorCon
{
this.operator = operator;
this.direction = direction;
Preconditions.checkArgument(direction > 0 || direction < 0);
Preconditions.checkArgument(direction != 0);
}
@Override

View File

@ -24,6 +24,8 @@ import org.apache.druid.query.filter.BoundDimFilter;
import org.apache.druid.query.filter.SelectorDimFilter;
import org.apache.druid.query.ordering.StringComparator;
import java.util.Objects;
public class BoundRefKey
{
private final String dimension;
@ -82,13 +84,13 @@ public class BoundRefKey
BoundRefKey boundRefKey = (BoundRefKey) o;
if (dimension != null ? !dimension.equals(boundRefKey.dimension) : boundRefKey.dimension != null) {
if (!Objects.equals(dimension, boundRefKey.dimension)) {
return false;
}
if (extractionFn != null ? !extractionFn.equals(boundRefKey.extractionFn) : boundRefKey.extractionFn != null) {
if (!Objects.equals(extractionFn, boundRefKey.extractionFn)) {
return false;
}
return comparator != null ? comparator.equals(boundRefKey.comparator) : boundRefKey.comparator == null;
return Objects.equals(comparator, boundRefKey.comparator);
}
@Override

View File

@ -22,6 +22,8 @@ package org.apache.druid.sql.calcite.filtration;
import org.apache.druid.java.util.common.ISE;
import org.apache.druid.query.ordering.StringComparator;
import java.util.Objects;
public class BoundValue implements Comparable<BoundValue>
{
private final String value;
@ -55,10 +57,10 @@ public class BoundValue implements Comparable<BoundValue>
BoundValue that = (BoundValue) o;
if (value != null ? !value.equals(that.value) : that.value != null) {
if (!Objects.equals(value, that.value)) {
return false;
}
return comparator != null ? comparator.equals(that.comparator) : that.comparator == null;
return Objects.equals(comparator, that.comparator);
}

View File

@ -66,11 +66,7 @@ public class ConvertSelectorsToIns extends BottomUpTransform
SimpleExtraction.of(selector.getDimension(), selector.getExtractionFn())
)
);
List<SelectorDimFilter> filterList = selectors.get(boundRefKey);
if (filterList == null) {
filterList = new ArrayList<>();
selectors.put(boundRefKey, filterList);
}
List<SelectorDimFilter> filterList = selectors.computeIfAbsent(boundRefKey, k -> new ArrayList<>());
filterList.add(selector);
}
}

View File

@ -32,6 +32,7 @@ import org.apache.druid.sql.calcite.table.RowSignature;
import org.joda.time.Interval;
import java.util.List;
import java.util.Objects;
public class Filtration
{
@ -162,10 +163,10 @@ public class Filtration
Filtration that = (Filtration) o;
if (intervals != null ? !intervals.equals(that.intervals) : that.intervals != null) {
if (!Objects.equals(intervals, that.intervals)) {
return false;
}
return dimFilter != null ? dimFilter.equals(that.dimFilter) : that.dimFilter == null;
return Objects.equals(dimFilter, that.dimFilter);
}

View File

@ -73,7 +73,7 @@ public class DruidConvention implements Convention
@Override
public boolean satisfies(RelTrait trait)
{
return trait == this;
return trait.equals(this);
}
@Override

View File

@ -34,6 +34,8 @@ import org.apache.calcite.sql.SqlCall;
import org.apache.calcite.sql.SqlNode;
import org.apache.druid.query.DataSource;
import java.util.Objects;
public class DruidTable implements TranslatableTable
{
private final DataSource dataSource;
@ -111,10 +113,10 @@ public class DruidTable implements TranslatableTable
DruidTable that = (DruidTable) o;
if (dataSource != null ? !dataSource.equals(that.dataSource) : that.dataSource != null) {
if (!Objects.equals(dataSource, that.dataSource)) {
return false;
}
return rowSignature != null ? rowSignature.equals(that.rowSignature) : that.rowSignature == null;
return Objects.equals(rowSignature, that.rowSignature);
}
@Override

View File

@ -42,6 +42,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* Type signature for a row in a Druid dataSource ("DruidTable") or query result. Rows have an ordering and every
@ -196,10 +197,10 @@ public class RowSignature
RowSignature that = (RowSignature) o;
if (columnTypes != null ? !columnTypes.equals(that.columnTypes) : that.columnTypes != null) {
if (!Objects.equals(columnTypes, that.columnTypes)) {
return false;
}
return columnNames != null ? columnNames.equals(that.columnNames) : that.columnNames == null;
return Objects.equals(columnNames, that.columnNames);
}
@Override