Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions codestyle/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@
<Bug pattern="NP_LOAD_OF_KNOWN_NULL_VALUE"/>
<Bug pattern="NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION"/>
<Bug pattern="NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/>
<Bug pattern="NP_NONNULL_PARAM_VIOLATION"/>
<Bug pattern="NP_NONNULL_PARAM_VIOLATION"/>
<Bug pattern="NP_NONNULL_RETURN_VIOLATION"/>
<Bug pattern="NP_NULL_ON_SOME_PATH"/>
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.druid.java.util.common.Pair;

import javax.annotation.Nullable;

public class SerializablePair<T1, T2> extends Pair<T1, T2>
{
@JsonCreator
public SerializablePair(@JsonProperty("lhs") T1 lhs, @JsonProperty("rhs") T2 rhs)
public SerializablePair(@JsonProperty("lhs") T1 lhs, @JsonProperty("rhs") @Nullable T2 rhs)
{
super(lhs, rhs);
}
Expand All @@ -38,6 +40,7 @@ public T1 getLhs()
}

@JsonProperty
@Nullable
public T2 getRhs()
{
return rhs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.apache.druid.query.aggregation.post.PostAggregatorIds;
import org.apache.druid.query.cache.CacheKeyBuilder;

import javax.annotation.Nullable;

import java.util.Comparator;
import java.util.HashSet;
import java.util.Map;
Expand All @@ -39,13 +41,14 @@ public class SketchEstimatePostAggregator implements PostAggregator

private final String name;
private final PostAggregator field;
@Nullable
private final Integer errorBoundsStdDev;

@JsonCreator
public SketchEstimatePostAggregator(
@JsonProperty("name") String name,
@JsonProperty("field") PostAggregator field,
@JsonProperty("errorBoundsStdDev") Integer errorBoundsStdDev
@JsonProperty("errorBoundsStdDev") @Nullable Integer errorBoundsStdDev
)
{
this.name = Preconditions.checkNotNull(name, "name is null");
Expand All @@ -56,9 +59,7 @@ public SketchEstimatePostAggregator(
@Override
public Set<String> getDependentFields()
{
Set<String> dependentFields = new HashSet<>();
dependentFields.addAll(field.getDependentFields());
return dependentFields;
return new HashSet<>(field.getDependentFields());
}

@Override
Expand Down Expand Up @@ -111,6 +112,7 @@ public PostAggregator getField()
return field;
}

@Nullable
@JsonProperty
public Integer getErrorBoundsStdDev()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import com.google.common.base.Preconditions;
import com.google.common.primitives.Floats;

import javax.annotation.Nullable;

import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -470,11 +472,6 @@ protected void shiftLeft(int start, int end)
}
}

public ApproximateHistogram fold(ApproximateHistogram h)
{
return fold(h, null, null, null);
}

public ApproximateHistogram fold(ApproximateHistogram h, float[] mergedPositions, long[] mergedBins, float[] deltas)
{
if (size == 0) {
Expand All @@ -496,7 +493,7 @@ public ApproximateHistogram foldFast(ApproximateHistogram h)
*
* @return returns this histogram with h folded into it
*/
public ApproximateHistogram foldFast(ApproximateHistogram h, float[] mergedPositions, long[] mergedBins)
public ApproximateHistogram foldFast(ApproximateHistogram h, @Nullable float[] mergedPositions, @Nullable long[] mergedBins)
{
if (size == 0) {
return copy(h);
Expand Down Expand Up @@ -612,7 +609,7 @@ protected ApproximateHistogram foldMin(
return this;
}

protected ApproximateHistogram foldRule(ApproximateHistogram h, float[] mergedPositions, long[] mergedBins)
protected ApproximateHistogram foldRule(ApproximateHistogram h, @Nullable float[] mergedPositions, @Nullable long[] mergedBins)
{
// ruleCombine bins requires at least one bin
if (h.binCount == 0) {
Expand Down Expand Up @@ -1079,8 +1076,8 @@ private static int combineBins(
float[] rightPositions,
long[] rightBins,
float[] mergedPositions,
long[] mergedBins,
float[] deltas
@Nullable long[] mergedBins,
@Nullable float[] deltas
)
{
int i = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private float[] getErrors()
for (int i = 0; i < numValues; ++i) {
tmp.offer(values[i]);
if ((i + 1) % numPerHist == 0) {
ah1.fold(tmp);
ah1.fold(tmp, null, null, null);
ah2.foldRule(tmp, null, null);
tmp = new ApproximateHistogram(resolution);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public void testFold()
h2.offer(VALUES[i]);
}

merged.fold(h1);
merged.fold(h2);
merged.fold(h1, null, null, null);
merged.fold(h2, null, null, null);
mergedFast.foldFast(h1);
mergedFast.foldFast(h2);

Expand Down Expand Up @@ -144,7 +144,7 @@ public void testFold()
ApproximateHistogram aFast = buildHistogram(10, new float[]{1, 2, 3, 4, 5, 6});
ApproximateHistogram b = buildHistogram(5, new float[]{3, 4, 5, 6});

a.fold(b);
a.fold(b, null, null, null);
aFast.foldFast(b);

Assert.assertEquals(
Expand Down Expand Up @@ -172,7 +172,7 @@ public void testFold()
for (float v : VALUES4) {
h4.offer(v);
}
h3.fold(h4);
h3.fold(h4, null, null, null);
Assert.assertArrayEquals(
"final bin positions match expected positions",
new float[]{-50.98f, -21.77f, -9.81f, 3.73f, 13.72f, 20.1f, 29f, 44.79f, 53.8f, 64.67f},
Expand All @@ -191,7 +191,7 @@ public void testFoldNothing()
ApproximateHistogram h1 = new ApproximateHistogram(10);
ApproximateHistogram h2 = new ApproximateHistogram(10);

h1.fold(h2);
h1.fold(h2, null, null, null);
h1.foldFast(h2);
}

Expand All @@ -210,8 +210,8 @@ public void testFoldNothing2()
h4Fast.offer(v);
}

h1.fold(h3);
h4.fold(h2);
h1.fold(h3, null, null, null);
h4.fold(h2, null, null, null);
h1Fast.foldFast(h3);
h4Fast.foldFast(h2);

Expand Down Expand Up @@ -300,7 +300,7 @@ public void testSerializeCompact()
ApproximateHistogram h = buildHistogram(5, VALUES);
Assert.assertEquals(h, ApproximateHistogram.fromBytes(h.toBytes()));

ApproximateHistogram h2 = new ApproximateHistogram(50).fold(h);
ApproximateHistogram h2 = new ApproximateHistogram(50).fold(h, null, null, null);
Assert.assertEquals(h2, ApproximateHistogram.fromBytes(h2.toBytes()));
}

Expand Down Expand Up @@ -331,7 +331,7 @@ public void testSerializeCompactExact()
h = buildHistogram(5, new float[]{1f, 2f, 3f});
Assert.assertEquals(h, ApproximateHistogram.fromBytes(h.toBytes()));

h = new ApproximateHistogram(40).fold(h);
h = new ApproximateHistogram(40).fold(h, null, null, null);
Assert.assertEquals(h, ApproximateHistogram.fromBytes(h.toBytes()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
*/
public class VarianceAggregatorCollector
{
public static boolean isVariancePop(String estimator)
public static boolean isVariancePop(@Nullable String estimator)
{
return estimator != null && "population".equalsIgnoreCase(estimator);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class VarianceAggregatorFactory extends AggregatorFactory
{
protected final String fieldName;
protected final String name;
@Nullable
protected final String estimator;
private final String inputType;

Expand All @@ -62,8 +63,8 @@ public class VarianceAggregatorFactory extends AggregatorFactory
public VarianceAggregatorFactory(
@JsonProperty("name") String name,
@JsonProperty("fieldName") String fieldName,
@JsonProperty("estimator") String estimator,
@JsonProperty("inputType") String inputType
@JsonProperty("estimator") @Nullable String estimator,
@JsonProperty("inputType") @Nullable String inputType
)
{
Preconditions.checkNotNull(name, "Must have a valid, non-null aggregator name");
Expand Down Expand Up @@ -238,6 +239,7 @@ public String getName()
return name;
}

@Nullable
@JsonProperty
public String getEstimator()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;

import javax.annotation.Nullable;

/**
*/
@JsonTypeName("varianceFold")
Expand All @@ -30,7 +32,7 @@ public class VarianceFoldingAggregatorFactory extends VarianceAggregatorFactory
public VarianceFoldingAggregatorFactory(
@JsonProperty("name") String name,
@JsonProperty("fieldName") String fieldName,
@JsonProperty("estimator") String estimator
@JsonProperty("estimator") @Nullable String estimator
)
{
super(name, fieldName, estimator, "variance");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class DoubleMaxAggregatorFactory extends SimpleDoubleAggregatorFactory
public DoubleMaxAggregatorFactory(
@JsonProperty("name") String name,
@JsonProperty("fieldName") final String fieldName,
@JsonProperty("expression") String expression,
@JsonProperty("expression") @Nullable String expression,
@JacksonInject ExprMacroTable macroTable
)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class DoubleMinAggregatorFactory extends SimpleDoubleAggregatorFactory
public DoubleMinAggregatorFactory(
@JsonProperty("name") String name,
@JsonProperty("fieldName") final String fieldName,
@JsonProperty("expression") String expression,
@JsonProperty("expression") @Nullable String expression,
@JacksonInject ExprMacroTable macroTable
)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class DoubleSumAggregatorFactory extends SimpleDoubleAggregatorFactory
public DoubleSumAggregatorFactory(
@JsonProperty("name") String name,
@JsonProperty("fieldName") final String fieldName,
@JsonProperty("expression") String expression,
@JsonProperty("expression") @Nullable String expression,
@JacksonInject ExprMacroTable macroTable
)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class FloatMaxAggregatorFactory extends SimpleFloatAggregatorFactory
public FloatMaxAggregatorFactory(
@JsonProperty("name") String name,
@JsonProperty("fieldName") final String fieldName,
@JsonProperty("expression") String expression,
@JsonProperty("expression") @Nullable String expression,
@JacksonInject ExprMacroTable macroTable
)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class FloatMinAggregatorFactory extends SimpleFloatAggregatorFactory
public FloatMinAggregatorFactory(
@JsonProperty("name") String name,
@JsonProperty("fieldName") final String fieldName,
@JsonProperty("expression") String expression,
@JsonProperty("expression") @Nullable String expression,
@JacksonInject ExprMacroTable macroTable
)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class FloatSumAggregatorFactory extends SimpleFloatAggregatorFactory
public FloatSumAggregatorFactory(
@JsonProperty("name") String name,
@JsonProperty("fieldName") final String fieldName,
@JsonProperty("expression") String expression,
@JsonProperty("expression") @Nullable String expression,
@JacksonInject ExprMacroTable macroTable
)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class LongMaxAggregatorFactory extends SimpleLongAggregatorFactory
public LongMaxAggregatorFactory(
@JsonProperty("name") String name,
@JsonProperty("fieldName") final String fieldName,
@JsonProperty("expression") String expression,
@JsonProperty("expression") @Nullable String expression,
@JacksonInject ExprMacroTable macroTable
)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class LongMinAggregatorFactory extends SimpleLongAggregatorFactory
public LongMinAggregatorFactory(
@JsonProperty("name") String name,
@JsonProperty("fieldName") final String fieldName,
@JsonProperty("expression") String expression,
@JsonProperty("expression") @Nullable String expression,
@JacksonInject ExprMacroTable macroTable
)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class LongSumAggregatorFactory extends SimpleLongAggregatorFactory
public LongSumAggregatorFactory(
@JsonProperty("name") String name,
@JsonProperty("fieldName") final String fieldName,
@JsonProperty("expression") String expression,
@JsonProperty("expression") @Nullable String expression,
@JacksonInject ExprMacroTable macroTable
)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public interface PostAggregator extends Cacheable
@Nullable
Object compute(Map<String, Object> combinedAggregators);

@Nullable
String getName();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.druid.collections.SerializablePair;

import javax.annotation.Nullable;

public class SerializablePairLongString extends SerializablePair<Long, String>
{
@JsonCreator
public SerializablePairLongString(@JsonProperty("lhs") Long lhs, @JsonProperty("rhs") String rhs)
public SerializablePairLongString(@JsonProperty("lhs") Long lhs, @JsonProperty("rhs") @Nullable String rhs)
{
super(lhs, rhs);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public Object get(ByteBuffer buf, int position)
mutationBuffer.position(position);

Long timeValue = mutationBuffer.getLong(position);
Integer stringSizeBytes = mutationBuffer.getInt(position + Long.BYTES);
int stringSizeBytes = mutationBuffer.getInt(position + Long.BYTES);

SerializablePairLongString serializablePair;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.apache.druid.query.aggregation.PostAggregator;
import org.apache.druid.query.cache.CacheKeyBuilder;

import javax.annotation.Nullable;

import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -71,7 +73,7 @@ public ArithmeticPostAggregator(
@JsonProperty("name") String name,
@JsonProperty("fn") String fnName,
@JsonProperty("fields") List<PostAggregator> fields,
@JsonProperty("ordering") String ordering
@JsonProperty("ordering") @Nullable String ordering
)
{
Preconditions.checkArgument(fnName != null, "fn cannot not be null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class ExpressionPostAggregator implements PostAggregator
public ExpressionPostAggregator(
@JsonProperty("name") String name,
@JsonProperty("expression") String expression,
@JsonProperty("ordering") String ordering,
@JsonProperty("ordering") @Nullable String ordering,
@JacksonInject ExprMacroTable macroTable
)
{
Expand Down
Loading