mirror of https://github.com/apache/druid.git
Add Checkstyle framework (#3551)
* Add Checkstyle framework * Avoid star import * Need braces for control flow statements * Redundant imports * Add NewLineAtEndOfFile check
This commit is contained in:
parent
85ac8eff90
commit
5dc95389f7
|
@ -19,7 +19,6 @@
|
|||
|
||||
package io.druid.benchmark.datagen;
|
||||
|
||||
import io.druid.benchmark.datagen.BenchmarkColumnSchema;
|
||||
import io.druid.query.aggregation.AggregatorFactory;
|
||||
import org.joda.time.Interval;
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!DOCTYPE suppressions PUBLIC
|
||||
"-//Puppy Crawl//DTD Suppressions 1.0//EN"
|
||||
"http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
|
||||
|
||||
<!--
|
||||
~ Licensed to Metamarkets Group Inc. (Metamarkets) under one
|
||||
~ or more contributor license agreements. See the NOTICE file
|
||||
~ distributed with this work for additional information
|
||||
~ regarding copyright ownership. Metamarkets licenses this file
|
||||
~ to you under the Apache License, Version 2.0 (the
|
||||
~ "License"); you may not use this file except in compliance
|
||||
~ with the License. You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<suppressions>
|
||||
<!-- See http://checkstyle.sourceforge.net/config_filters.html#SuppressionFilter for examples -->
|
||||
</suppressions>
|
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" ?>
|
||||
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
|
||||
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
|
||||
|
||||
<!--
|
||||
~ Licensed to Metamarkets Group Inc. (Metamarkets) under one
|
||||
~ or more contributor license agreements. See the NOTICE file
|
||||
~ distributed with this work for additional information
|
||||
~ regarding copyright ownership. Metamarkets licenses this file
|
||||
~ to you under the Apache License, Version 2.0 (the
|
||||
~ "License"); you may not use this file except in compliance
|
||||
~ with the License. You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<module name="Checker">
|
||||
<module name="NewlineAtEndOfFile"/>
|
||||
|
||||
<module name="TreeWalker">
|
||||
<!-- See http://checkstyle.sourceforge.net/checks.html for examples -->
|
||||
|
||||
<!--<module name="LineLength">-->
|
||||
<!--<property name="max" value="120"/>-->
|
||||
<!--</module>-->
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="RedundantImport"/>
|
||||
<module name="NeedBraces"/>
|
||||
</module>
|
||||
</module>
|
|
@ -73,7 +73,9 @@ public class AzureTaskLogs implements TaskLogs {
|
|||
final String taskKey = getTaskLogKey(taskid);
|
||||
|
||||
try {
|
||||
if (!azureStorage.getBlobExists(container, taskKey)) return Optional.absent();
|
||||
if (!azureStorage.getBlobExists(container, taskKey)) {
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
return Optional.<ByteSource>of(
|
||||
new ByteSource() {
|
||||
|
|
|
@ -34,16 +34,23 @@ import com.alibaba.rocketmq.remoting.exception.RemotingException;
|
|||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.metamx.common.logger.Logger;
|
||||
import com.metamx.common.parsers.ParseException;
|
||||
import io.druid.data.input.ByteBufferInputRowParser;
|
||||
import io.druid.data.input.Firehose;
|
||||
import io.druid.data.input.FirehoseFactory;
|
||||
import io.druid.data.input.InputRow;
|
||||
import com.metamx.common.logger.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
|
|
@ -199,16 +199,19 @@ public class OrcHadoopInputRowParser implements InputRowParser<OrcStruct>
|
|||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (!(o instanceof OrcHadoopInputRowParser))
|
||||
if (!(o instanceof OrcHadoopInputRowParser)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
OrcHadoopInputRowParser other = (OrcHadoopInputRowParser)o;
|
||||
|
||||
if (!parseSpec.equals(other.parseSpec))
|
||||
if (!parseSpec.equals(other.parseSpec)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!typeString.equals(other.typeString))
|
||||
if (!typeString.equals(other.typeString)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,13 @@ import com.google.inject.Binder;
|
|||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.name.Names;
|
||||
import io.druid.data.input.impl.*;
|
||||
import io.druid.data.input.impl.DimensionSchema;
|
||||
import io.druid.data.input.impl.DimensionsSpec;
|
||||
import io.druid.data.input.impl.InputRowParser;
|
||||
import io.druid.data.input.impl.ParseSpec;
|
||||
import io.druid.data.input.impl.StringDimensionSchema;
|
||||
import io.druid.data.input.impl.TimeAndDimsParseSpec;
|
||||
import io.druid.data.input.impl.TimestampSpec;
|
||||
import io.druid.guice.GuiceInjectors;
|
||||
import io.druid.initialization.Initialization;
|
||||
import io.druid.jackson.DefaultObjectMapper;
|
||||
|
|
|
@ -96,7 +96,9 @@ public class LoadingLookupFactory implements LookupExtractorFactory
|
|||
@Nullable LookupExtractorFactory lookupExtractorFactory
|
||||
)
|
||||
{
|
||||
if (lookupExtractorFactory == null) return true;
|
||||
if (lookupExtractorFactory == null) {
|
||||
return true;
|
||||
}
|
||||
return !this.equals(lookupExtractorFactory);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,10 +27,11 @@ public class AWSSessionCredentialsAdapter extends AWSSessionCredentials {
|
|||
|
||||
public AWSSessionCredentialsAdapter(AWSCredentialsProvider provider) {
|
||||
super(null, null, null);
|
||||
if(provider.getCredentials() instanceof com.amazonaws.auth.AWSSessionCredentials)
|
||||
if(provider.getCredentials() instanceof com.amazonaws.auth.AWSSessionCredentials) {
|
||||
this.provider = provider;
|
||||
else
|
||||
} else {
|
||||
throw new IllegalArgumentException("provider does not contain session credentials");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
24
pom.xml
24
pom.xml
|
@ -690,6 +690,30 @@
|
|||
<artifactId>coveralls-maven-plugin</artifactId>
|
||||
<version>4.0.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>2.17</version>
|
||||
<configuration>
|
||||
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
|
||||
<includeTestSourceDirectory>true</includeTestSourceDirectory>
|
||||
<configLocation>codestyle/checkstyle.xml</configLocation>
|
||||
<suppressionsLocation>codestyle/checkstyle-suppressions.xml</suppressionsLocation>
|
||||
<suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression>
|
||||
<encoding>UTF-8</encoding>
|
||||
<consoleOutput>true</consoleOutput>
|
||||
<failsOnError>true</failsOnError>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>validate</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
|
|
|
@ -111,8 +111,11 @@ public class PeriodGranularity extends BaseQueryGranularity
|
|||
y -= y % years;
|
||||
long tt = chronology.years().add(origin, y);
|
||||
// always round down to the previous period (for timestamps prior to origin)
|
||||
if(t < tt) t = chronology.years().add(tt, -years);
|
||||
else t = tt;
|
||||
if(t < tt) {
|
||||
t = chronology.years().add(tt, -years);
|
||||
} else {
|
||||
t = tt;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
else
|
||||
|
@ -130,8 +133,11 @@ public class PeriodGranularity extends BaseQueryGranularity
|
|||
m -= m % months;
|
||||
long tt = chronology.months().add(origin, m);
|
||||
// always round down to the previous period (for timestamps prior to origin)
|
||||
if(t < tt) t = chronology.months().add(tt, -months);
|
||||
else t = tt;
|
||||
if(t < tt) {
|
||||
t = chronology.months().add(tt, -months);
|
||||
} else {
|
||||
t = tt;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
else
|
||||
|
@ -150,8 +156,11 @@ public class PeriodGranularity extends BaseQueryGranularity
|
|||
w -= w % weeks;
|
||||
long tt = chronology.weeks().add(origin, w);
|
||||
// always round down to the previous period (for timestamps prior to origin)
|
||||
if(t < tt) t = chronology.weeks().add(tt, -weeks);
|
||||
else t = tt;
|
||||
if(t < tt) {
|
||||
t = chronology.weeks().add(tt, -weeks);
|
||||
} else {
|
||||
t = tt;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
else
|
||||
|
@ -172,8 +181,11 @@ public class PeriodGranularity extends BaseQueryGranularity
|
|||
d -= d % days;
|
||||
long tt = chronology.days().add(origin, d);
|
||||
// always round down to the previous period (for timestamps prior to origin)
|
||||
if(t < tt) t = chronology.days().add(tt, -days);
|
||||
else t = tt;
|
||||
if(t < tt) {
|
||||
t = chronology.days().add(tt, -days);
|
||||
} else {
|
||||
t = tt;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
else
|
||||
|
@ -193,8 +205,11 @@ public class PeriodGranularity extends BaseQueryGranularity
|
|||
h -= h % hours;
|
||||
long tt = chronology.hours().add(origin, h);
|
||||
// always round down to the previous period (for timestamps prior to origin)
|
||||
if(t < tt) t = chronology.hours().add(tt, -hours);
|
||||
else t = tt;
|
||||
if(t < tt) {
|
||||
t = chronology.hours().add(tt, -hours);
|
||||
} else {
|
||||
t = tt;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
else
|
||||
|
@ -214,8 +229,11 @@ public class PeriodGranularity extends BaseQueryGranularity
|
|||
m -= m % minutes;
|
||||
long tt = chronology.minutes().add(origin, m);
|
||||
// always round down to the previous period (for timestamps prior to origin)
|
||||
if(t < tt) t = chronology.minutes().add(tt, -minutes);
|
||||
else t = tt;
|
||||
if(t < tt) {
|
||||
t = chronology.minutes().add(tt, -minutes);
|
||||
} else {
|
||||
t = tt;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
else
|
||||
|
@ -235,8 +253,11 @@ public class PeriodGranularity extends BaseQueryGranularity
|
|||
s -= s % seconds;
|
||||
long tt = chronology.seconds().add(origin, s);
|
||||
// always round down to the previous period (for timestamps prior to origin)
|
||||
if(t < tt) t = chronology.seconds().add(tt, -seconds);
|
||||
else t = tt;
|
||||
if(t < tt) {
|
||||
t = chronology.seconds().add(tt, -seconds);
|
||||
} else {
|
||||
t = tt;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
else
|
||||
|
@ -254,8 +275,11 @@ public class PeriodGranularity extends BaseQueryGranularity
|
|||
ms -= ms % millis;
|
||||
long tt = chronology.millis().add(origin, ms);
|
||||
// always round down to the previous period (for timestamps prior to origin)
|
||||
if(t < tt) t = chronology.millis().add(tt, -millis);
|
||||
else t = tt;
|
||||
if(t < tt) {
|
||||
t = chronology.millis().add(tt, -millis);
|
||||
} else {
|
||||
t = tt;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
else {
|
||||
|
@ -274,7 +298,9 @@ public class PeriodGranularity extends BaseQueryGranularity
|
|||
{
|
||||
if(v > 0)
|
||||
{
|
||||
if(single) return true;
|
||||
if(single) {
|
||||
return true;
|
||||
}
|
||||
single = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -172,13 +172,21 @@ public class DoubleMaxAggregatorFactory extends AggregatorFactory
|
|||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DoubleMaxAggregatorFactory that = (DoubleMaxAggregatorFactory) o;
|
||||
|
||||
if (fieldName != null ? !fieldName.equals(that.fieldName) : that.fieldName != null) return false;
|
||||
if (name != null ? !name.equals(that.name) : that.name != null) return false;
|
||||
if (fieldName != null ? !fieldName.equals(that.fieldName) : that.fieldName != null) {
|
||||
return false;
|
||||
}
|
||||
if (name != null ? !name.equals(that.name) : that.name != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -172,13 +172,21 @@ public class DoubleMinAggregatorFactory extends AggregatorFactory
|
|||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DoubleMinAggregatorFactory that = (DoubleMinAggregatorFactory) o;
|
||||
|
||||
if (fieldName != null ? !fieldName.equals(that.fieldName) : that.fieldName != null) return false;
|
||||
if (name != null ? !name.equals(that.name) : that.name != null) return false;
|
||||
if (fieldName != null ? !fieldName.equals(that.fieldName) : that.fieldName != null) {
|
||||
return false;
|
||||
}
|
||||
if (name != null ? !name.equals(that.name) : that.name != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -51,12 +51,18 @@ public class Histogram
|
|||
this.bins = bins;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
for(long k : bins) this.count += k;
|
||||
for(long k : bins) {
|
||||
this.count += k;
|
||||
}
|
||||
}
|
||||
|
||||
public void offer(float d) {
|
||||
if(d > max) max = d;
|
||||
if(d < min) min = d;
|
||||
if(d > max) {
|
||||
max = d;
|
||||
}
|
||||
if(d < min) {
|
||||
min = d;
|
||||
}
|
||||
|
||||
int index = Arrays.binarySearch(breaks, d);
|
||||
int pos = (index >= 0) ? index : -(index + 1);
|
||||
|
@ -67,8 +73,12 @@ public class Histogram
|
|||
public Histogram fold(Histogram h) {
|
||||
Preconditions.checkArgument(Arrays.equals(breaks, h.breaks), "Cannot fold histograms with different breaks");
|
||||
|
||||
if(h.min < min) min = h.min;
|
||||
if(h.max > max) max = h.max;
|
||||
if(h.min < min) {
|
||||
min = h.min;
|
||||
}
|
||||
if(h.max > max) {
|
||||
max = h.max;
|
||||
}
|
||||
|
||||
count += h.count;
|
||||
for (int i = 0; i < bins.length; ++i) {
|
||||
|
@ -124,8 +134,12 @@ public class Histogram
|
|||
Longs.BYTES * bins.length + Floats.BYTES * 2);
|
||||
|
||||
buf.putInt(breaks.length);
|
||||
for(float b : breaks) buf.putFloat(b);
|
||||
for(long c : bins ) buf.putLong(c);
|
||||
for(float b : breaks) {
|
||||
buf.putFloat(b);
|
||||
}
|
||||
for(long c : bins ) {
|
||||
buf.putLong(c);
|
||||
}
|
||||
buf.putFloat(min);
|
||||
buf.putFloat(max);
|
||||
|
||||
|
@ -141,7 +155,9 @@ public class Histogram
|
|||
*/
|
||||
public HistogramVisual asVisual() {
|
||||
float[] visualCounts = new float[bins.length - 2];
|
||||
for(int i = 0; i < visualCounts.length; ++i) visualCounts[i] = (float)bins[i + 1];
|
||||
for(int i = 0; i < visualCounts.length; ++i) {
|
||||
visualCounts[i] = (float) bins[i + 1];
|
||||
}
|
||||
return new HistogramVisual(breaks, visualCounts, new float[]{min, max});
|
||||
}
|
||||
|
||||
|
@ -155,8 +171,12 @@ public class Histogram
|
|||
float[] breaks = new float[n];
|
||||
long[] bins = new long[n + 1];
|
||||
|
||||
for (int i = 0; i < breaks.length; ++i) breaks[i] = buf.getFloat();
|
||||
for (int i = 0; i < bins.length ; ++i) bins[i] = buf.getLong();
|
||||
for (int i = 0; i < breaks.length; ++i) {
|
||||
breaks[i] = buf.getFloat();
|
||||
}
|
||||
for (int i = 0; i < bins.length ; ++i) {
|
||||
bins[i] = buf.getLong();
|
||||
}
|
||||
|
||||
float min = buf.getFloat();
|
||||
float max = buf.getFloat();
|
||||
|
|
|
@ -60,8 +60,12 @@ public class HistogramBufferAggregator implements BufferAggregator
|
|||
final int minPos = position + minOffset;
|
||||
final int maxPos = position + maxOffset;
|
||||
|
||||
if(value < buf.getFloat(minPos)) buf.putFloat(minPos, value);
|
||||
if(value > buf.getFloat(maxPos)) buf.putFloat(maxPos, value);
|
||||
if(value < buf.getFloat(minPos)) {
|
||||
buf.putFloat(minPos, value);
|
||||
}
|
||||
if(value > buf.getFloat(maxPos)) {
|
||||
buf.putFloat(maxPos, value);
|
||||
}
|
||||
|
||||
int index = Arrays.binarySearch(breaks, value);
|
||||
index = (index >= 0) ? index : -(index + 1);
|
||||
|
|
|
@ -62,9 +62,15 @@ public class HistogramVisual
|
|||
this.breaks = new double[breaks.length];
|
||||
this.counts = new double[counts.length];
|
||||
this.quantiles = new double[quantiles.length];
|
||||
for(int i = 0; i < breaks.length; ++i) this.breaks[i] = breaks[i];
|
||||
for(int i = 0; i < counts.length; ++i) this.counts[i] = counts[i];
|
||||
for(int i = 0; i < quantiles.length; ++i) this.quantiles[i] = quantiles[i];
|
||||
for(int i = 0; i < breaks.length; ++i) {
|
||||
this.breaks[i] = breaks[i];
|
||||
}
|
||||
for(int i = 0; i < counts.length; ++i) {
|
||||
this.counts[i] = counts[i];
|
||||
}
|
||||
for(int i = 0; i < quantiles.length; ++i) {
|
||||
this.quantiles[i] = quantiles[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -168,13 +168,21 @@ public class LongMaxAggregatorFactory extends AggregatorFactory
|
|||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LongMaxAggregatorFactory that = (LongMaxAggregatorFactory) o;
|
||||
|
||||
if (fieldName != null ? !fieldName.equals(that.fieldName) : that.fieldName != null) return false;
|
||||
if (name != null ? !name.equals(that.name) : that.name != null) return false;
|
||||
if (fieldName != null ? !fieldName.equals(that.fieldName) : that.fieldName != null) {
|
||||
return false;
|
||||
}
|
||||
if (name != null ? !name.equals(that.name) : that.name != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -168,13 +168,21 @@ public class LongMinAggregatorFactory extends AggregatorFactory
|
|||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LongMinAggregatorFactory that = (LongMinAggregatorFactory) o;
|
||||
|
||||
if (fieldName != null ? !fieldName.equals(that.fieldName) : that.fieldName != null) return false;
|
||||
if (name != null ? !name.equals(that.name) : that.name != null) return false;
|
||||
if (fieldName != null ? !fieldName.equals(that.fieldName) : that.fieldName != null) {
|
||||
return false;
|
||||
}
|
||||
if (name != null ? !name.equals(that.name) : that.name != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -227,13 +227,21 @@ public class HyperUniquesAggregatorFactory extends AggregatorFactory
|
|||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HyperUniquesAggregatorFactory that = (HyperUniquesAggregatorFactory) o;
|
||||
|
||||
if (!fieldName.equals(that.fieldName)) return false;
|
||||
if (!name.equals(that.name)) return false;
|
||||
if (!fieldName.equals(that.fieldName)) {
|
||||
return false;
|
||||
}
|
||||
if (!name.equals(that.name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -88,13 +88,21 @@ public class FieldAccessPostAggregator implements PostAggregator
|
|||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FieldAccessPostAggregator that = (FieldAccessPostAggregator) o;
|
||||
|
||||
if (fieldName != null ? !fieldName.equals(that.fieldName) : that.fieldName != null) return false;
|
||||
if (name != null ? !name.equals(that.name) : that.name != null) return false;
|
||||
if (fieldName != null ? !fieldName.equals(that.fieldName) : that.fieldName != null) {
|
||||
return false;
|
||||
}
|
||||
if (name != null ? !name.equals(that.name) : that.name != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -128,14 +128,22 @@ public class DefaultDimensionSpec implements DimensionSpec
|
|||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
// LegacyDimensionSpec can be equal to DefaultDimensionSpec
|
||||
if (!(o instanceof DefaultDimensionSpec)) return false;
|
||||
if (!(o instanceof DefaultDimensionSpec)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DefaultDimensionSpec that = (DefaultDimensionSpec) o;
|
||||
|
||||
if (dimension != null ? !dimension.equals(that.dimension) : that.dimension != null) return false;
|
||||
if (outputName != null ? !outputName.equals(that.outputName) : that.outputName != null) return false;
|
||||
if (dimension != null ? !dimension.equals(that.dimension) : that.dimension != null) {
|
||||
return false;
|
||||
}
|
||||
if (outputName != null ? !outputName.equals(that.outputName) : that.outputName != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -121,15 +121,24 @@ public class ExtractionDimensionSpec implements DimensionSpec
|
|||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ExtractionDimensionSpec that = (ExtractionDimensionSpec) o;
|
||||
|
||||
if (extractionFn != null ? !extractionFn.equals(that.extractionFn) : that.extractionFn != null)
|
||||
if (extractionFn != null ? !extractionFn.equals(that.extractionFn) : that.extractionFn != null) {
|
||||
return false;
|
||||
if (dimension != null ? !dimension.equals(that.dimension) : that.dimension != null) return false;
|
||||
if (outputName != null ? !outputName.equals(that.outputName) : that.outputName != null) return false;
|
||||
}
|
||||
if (dimension != null ? !dimension.equals(that.dimension) : that.dimension != null) {
|
||||
return false;
|
||||
}
|
||||
if (outputName != null ? !outputName.equals(that.outputName) : that.outputName != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -256,11 +256,11 @@ public class SearchQueryRunner implements QueryRunner<Result<SearchResultValue>>
|
|||
int mid = (low + high) >>> 1;
|
||||
long midVal = timeValues.getLongSingleValueRow(mid);
|
||||
|
||||
if (midVal < time)
|
||||
if (midVal < time) {
|
||||
low = mid + 1;
|
||||
else if (midVal > time)
|
||||
} else if (midVal > time) {
|
||||
high = mid - 1;
|
||||
else { // key found
|
||||
} else { // key found
|
||||
int i;
|
||||
// rewind the index of the same time values
|
||||
for (i = mid - 1; i >= 0; i--) {
|
||||
|
|
|
@ -223,18 +223,36 @@ public class SearchQuery extends BaseQuery<Result<SearchResultValue>>
|
|||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
if (!super.equals(o)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SearchQuery that = (SearchQuery) o;
|
||||
|
||||
if (limit != that.limit) return false;
|
||||
if (dimFilter != null ? !dimFilter.equals(that.dimFilter) : that.dimFilter != null) return false;
|
||||
if (dimensions != null ? !dimensions.equals(that.dimensions) : that.dimensions != null) return false;
|
||||
if (granularity != null ? !granularity.equals(that.granularity) : that.granularity != null) return false;
|
||||
if (querySpec != null ? !querySpec.equals(that.querySpec) : that.querySpec != null) return false;
|
||||
if (sortSpec != null ? !sortSpec.equals(that.sortSpec) : that.sortSpec != null) return false;
|
||||
if (limit != that.limit) {
|
||||
return false;
|
||||
}
|
||||
if (dimFilter != null ? !dimFilter.equals(that.dimFilter) : that.dimFilter != null) {
|
||||
return false;
|
||||
}
|
||||
if (dimensions != null ? !dimensions.equals(that.dimensions) : that.dimensions != null) {
|
||||
return false;
|
||||
}
|
||||
if (granularity != null ? !granularity.equals(that.granularity) : that.granularity != null) {
|
||||
return false;
|
||||
}
|
||||
if (querySpec != null ? !querySpec.equals(that.querySpec) : that.querySpec != null) {
|
||||
return false;
|
||||
}
|
||||
if (sortSpec != null ? !sortSpec.equals(that.sortSpec) : that.sortSpec != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -227,17 +227,33 @@ public class SelectQuery extends BaseQuery<Result<SelectResultValue>>
|
|||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
if (!super.equals(o)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SelectQuery that = (SelectQuery) o;
|
||||
|
||||
if (dimFilter != null ? !dimFilter.equals(that.dimFilter) : that.dimFilter != null) return false;
|
||||
if (dimensions != null ? !dimensions.equals(that.dimensions) : that.dimensions != null) return false;
|
||||
if (granularity != null ? !granularity.equals(that.granularity) : that.granularity != null) return false;
|
||||
if (metrics != null ? !metrics.equals(that.metrics) : that.metrics != null) return false;
|
||||
if (pagingSpec != null ? !pagingSpec.equals(that.pagingSpec) : that.pagingSpec != null) return false;
|
||||
if (dimFilter != null ? !dimFilter.equals(that.dimFilter) : that.dimFilter != null) {
|
||||
return false;
|
||||
}
|
||||
if (dimensions != null ? !dimensions.equals(that.dimensions) : that.dimensions != null) {
|
||||
return false;
|
||||
}
|
||||
if (granularity != null ? !granularity.equals(that.granularity) : that.granularity != null) {
|
||||
return false;
|
||||
}
|
||||
if (metrics != null ? !metrics.equals(that.metrics) : that.metrics != null) {
|
||||
return false;
|
||||
}
|
||||
if (pagingSpec != null ? !pagingSpec.equals(that.pagingSpec) : that.pagingSpec != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -68,12 +68,18 @@ public class MultipleIntervalSegmentSpec implements QuerySegmentSpec
|
|||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MultipleIntervalSegmentSpec that = (MultipleIntervalSegmentSpec) o;
|
||||
|
||||
if (intervals != null ? !intervals.equals(that.intervals) : that.intervals != null) return false;
|
||||
if (intervals != null ? !intervals.equals(that.intervals) : that.intervals != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -95,13 +95,21 @@ public class MultipleSpecificSegmentSpec implements QuerySegmentSpec
|
|||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MultipleSpecificSegmentSpec that = (MultipleSpecificSegmentSpec) o;
|
||||
|
||||
if (descriptors != null ? !descriptors.equals(that.descriptors) : that.descriptors != null) return false;
|
||||
if (intervals != null ? !intervals.equals(that.intervals) : that.intervals != null) return false;
|
||||
if (descriptors != null ? !descriptors.equals(that.descriptors) : that.descriptors != null) {
|
||||
return false;
|
||||
}
|
||||
if (intervals != null ? !intervals.equals(that.intervals) : that.intervals != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -57,12 +57,18 @@ public class SpecificSegmentSpec implements QuerySegmentSpec
|
|||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SpecificSegmentSpec that = (SpecificSegmentSpec) o;
|
||||
|
||||
if (descriptor != null ? !descriptor.equals(that.descriptor) : that.descriptor != null) return false;
|
||||
if (descriptor != null ? !descriptor.equals(that.descriptor) : that.descriptor != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ import io.druid.query.Result;
|
|||
import io.druid.query.filter.DimFilter;
|
||||
import io.druid.query.spec.MultipleIntervalSegmentSpec;
|
||||
import io.druid.query.spec.QuerySegmentSpec;
|
||||
import io.druid.query.filter.DimFilter;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Interval;
|
||||
|
||||
|
|
|
@ -190,18 +190,30 @@ public class TimeseriesQuery extends BaseQuery<Result<TimeseriesResultValue>>
|
|||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
if (!super.equals(o)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TimeseriesQuery that = (TimeseriesQuery) o;
|
||||
|
||||
if (aggregatorSpecs != null ? !aggregatorSpecs.equals(that.aggregatorSpecs) : that.aggregatorSpecs != null)
|
||||
if (aggregatorSpecs != null ? !aggregatorSpecs.equals(that.aggregatorSpecs) : that.aggregatorSpecs != null) {
|
||||
return false;
|
||||
if (dimFilter != null ? !dimFilter.equals(that.dimFilter) : that.dimFilter != null) return false;
|
||||
if (granularity != null ? !granularity.equals(that.granularity) : that.granularity != null) return false;
|
||||
if (postAggregatorSpecs != null ? !postAggregatorSpecs.equals(that.postAggregatorSpecs) : that.postAggregatorSpecs != null)
|
||||
}
|
||||
if (dimFilter != null ? !dimFilter.equals(that.dimFilter) : that.dimFilter != null) {
|
||||
return false;
|
||||
}
|
||||
if (granularity != null ? !granularity.equals(that.granularity) : that.granularity != null) {
|
||||
return false;
|
||||
}
|
||||
if (postAggregatorSpecs != null ? !postAggregatorSpecs.equals(that.postAggregatorSpecs) : that.postAggregatorSpecs != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -174,12 +174,18 @@ public class NumericTopNMetricSpec implements TopNMetricSpec
|
|||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NumericTopNMetricSpec that = (NumericTopNMetricSpec) o;
|
||||
|
||||
if (metric != null ? !metric.equals(that.metric) : that.metric != null) return false;
|
||||
if (metric != null ? !metric.equals(that.metric) : that.metric != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -282,23 +282,39 @@ public class TopNQuery extends BaseQuery<Result<TopNResultValue>>
|
|||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
if (!super.equals(o)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TopNQuery topNQuery = (TopNQuery) o;
|
||||
|
||||
if (threshold != topNQuery.threshold) return false;
|
||||
if (aggregatorSpecs != null ? !aggregatorSpecs.equals(topNQuery.aggregatorSpecs) : topNQuery.aggregatorSpecs != null)
|
||||
if (threshold != topNQuery.threshold) {
|
||||
return false;
|
||||
if (dimFilter != null ? !dimFilter.equals(topNQuery.dimFilter) : topNQuery.dimFilter != null) return false;
|
||||
if (dimensionSpec != null ? !dimensionSpec.equals(topNQuery.dimensionSpec) : topNQuery.dimensionSpec != null)
|
||||
}
|
||||
if (aggregatorSpecs != null ? !aggregatorSpecs.equals(topNQuery.aggregatorSpecs) : topNQuery.aggregatorSpecs != null) {
|
||||
return false;
|
||||
if (granularity != null ? !granularity.equals(topNQuery.granularity) : topNQuery.granularity != null) return false;
|
||||
if (postAggregatorSpecs != null ? !postAggregatorSpecs.equals(topNQuery.postAggregatorSpecs) : topNQuery.postAggregatorSpecs != null)
|
||||
}
|
||||
if (dimFilter != null ? !dimFilter.equals(topNQuery.dimFilter) : topNQuery.dimFilter != null) {
|
||||
return false;
|
||||
if (topNMetricSpec != null ? !topNMetricSpec.equals(topNQuery.topNMetricSpec) : topNQuery.topNMetricSpec != null)
|
||||
}
|
||||
if (dimensionSpec != null ? !dimensionSpec.equals(topNQuery.dimensionSpec) : topNQuery.dimensionSpec != null) {
|
||||
return false;
|
||||
}
|
||||
if (granularity != null ? !granularity.equals(topNQuery.granularity) : topNQuery.granularity != null) {
|
||||
return false;
|
||||
}
|
||||
if (postAggregatorSpecs != null ? !postAggregatorSpecs.equals(topNQuery.postAggregatorSpecs) : topNQuery.postAggregatorSpecs != null) {
|
||||
return false;
|
||||
}
|
||||
if (topNMetricSpec != null ? !topNMetricSpec.equals(topNQuery.topNMetricSpec) : topNQuery.topNMetricSpec != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -324,7 +324,9 @@ public final class ProtoTestEventWrapper {
|
|||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized != -1) return isInitialized == 1;
|
||||
if (isInitialized != -1) {
|
||||
return isInitialized == 1;
|
||||
}
|
||||
|
||||
if (!hasEventType()) {
|
||||
memoizedIsInitialized = 0;
|
||||
|
@ -378,7 +380,9 @@ public final class ProtoTestEventWrapper {
|
|||
private int memoizedSerializedSize = -1;
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSerializedSize;
|
||||
if (size != -1) return size;
|
||||
if (size != -1) {
|
||||
return size;
|
||||
}
|
||||
|
||||
size = 0;
|
||||
if (((bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
|
@ -649,7 +653,9 @@ public final class ProtoTestEventWrapper {
|
|||
}
|
||||
|
||||
public Builder mergeFrom(ProtoTestEventWrapper.ProtoTestEvent other) {
|
||||
if (other == ProtoTestEventWrapper.ProtoTestEvent.getDefaultInstance()) return this;
|
||||
if (other == ProtoTestEventWrapper.ProtoTestEvent.getDefaultInstance()) {
|
||||
return this;
|
||||
}
|
||||
if (other.hasEventType()) {
|
||||
setEventType(other.getEventType());
|
||||
}
|
||||
|
|
|
@ -38,7 +38,9 @@ public class HistogramTest
|
|||
Histogram hExpected = new Histogram(breaks, new long[]{1,3,2,3,1,1}, -3f, 2f);
|
||||
|
||||
Histogram h = new Histogram(breaks);
|
||||
for(float v : values) h.offer(v);
|
||||
for(float v : values) {
|
||||
h.offer(v);
|
||||
}
|
||||
|
||||
Assert.assertEquals("histogram matches expected histogram", hExpected, h);
|
||||
}
|
||||
|
|
|
@ -83,7 +83,9 @@ public class HyperLogLogCollectorBenchmark extends SimpleBenchmark
|
|||
int pos = 0;
|
||||
for(int i = 0; i < count; ++i) {
|
||||
HyperLogLogCollector c = HyperLogLogCollector.makeLatestCollector();
|
||||
for(int k = 0; k < 40; ++k) c.add(fn.hashInt(++val).asBytes());
|
||||
for(int k = 0; k < 40; ++k) {
|
||||
c.add(fn.hashInt(++val).asBytes());
|
||||
}
|
||||
final ByteBuffer sparseHeapCopy = c.toByteBuffer();
|
||||
int size = sparseHeapCopy.remaining();
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
package io.druid.query.lookup;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.druid.query.lookup.LookupExtractionFn;
|
||||
import io.druid.query.extraction.MapLookupExtractor;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -30,7 +30,6 @@ import com.google.common.collect.Maps;
|
|||
import com.google.common.collect.Sets;
|
||||
import com.metamx.common.IAE;
|
||||
import io.druid.jackson.DefaultObjectMapper;
|
||||
import io.druid.query.lookup.LookupExtractionFn;
|
||||
import io.druid.query.extraction.MapLookupExtractor;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -24,7 +24,6 @@ import com.google.common.collect.ImmutableMap;
|
|||
import com.google.common.collect.Lists;
|
||||
import io.druid.jackson.DefaultObjectMapper;
|
||||
import io.druid.query.extraction.MapLookupExtractor;
|
||||
import io.druid.query.lookup.LookupExtractor;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.Lists;
|
||||
|
||||
import io.druid.jackson.DefaultObjectMapper;
|
||||
import io.druid.query.ordering.StringComparator;
|
||||
|
||||
public class StringComparatorsTest
|
||||
{
|
||||
|
|
|
@ -244,13 +244,16 @@ public abstract class LoadRule implements Rule
|
|||
}
|
||||
|
||||
protected void validateTieredReplicants(Map<String, Integer> tieredReplicants){
|
||||
if(tieredReplicants.size() == 0)
|
||||
if(tieredReplicants.size() == 0) {
|
||||
throw new IAE("A rule with empty tiered replicants is invalid");
|
||||
}
|
||||
for (Map.Entry<String, Integer> entry: tieredReplicants.entrySet()) {
|
||||
if (entry.getValue() == null)
|
||||
if (entry.getValue() == null) {
|
||||
throw new IAE("Replicant value cannot be empty");
|
||||
if (entry.getValue() < 0)
|
||||
}
|
||||
if (entry.getValue() < 0) {
|
||||
throw new IAE("Replicant value [%d] is less than 0, which is not allowed", entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package io.druid.server.lookup.cache;
|
||||
|
||||
import io.druid.server.lookup.cache.LookupCoordinatorManagerConfig;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
|
Loading…
Reference in New Issue