Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify type of value in Aggregator #94

Merged
merged 1 commit into from
Mar 22, 2024
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
22 changes: 11 additions & 11 deletions src/main/java/org/kairosdb/client/builder/AggregatorFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public enum FilterOperation
* @param unit unit of time
* @return min aggregator
*/
public static SamplingAggregator createMinAggregator(int value, TimeUnit unit)
public static SamplingAggregator createMinAggregator(long value, TimeUnit unit)
{
return new SamplingAggregator("min", value, unit);
}
Expand All @@ -72,7 +72,7 @@ public static SamplingAggregator createMinAggregator(int value, TimeUnit unit)
* @param unit unit of time
* @return max aggregator
*/
public static SamplingAggregator createMaxAggregator(int value, TimeUnit unit)
public static SamplingAggregator createMaxAggregator(long value, TimeUnit unit)
{
return new SamplingAggregator("max", value, unit);
}
Expand All @@ -85,7 +85,7 @@ public static SamplingAggregator createMaxAggregator(int value, TimeUnit unit)
* @param unit unit of time
* @return average aggregator
*/
public static SamplingAggregator createAverageAggregator(int value, TimeUnit unit)
public static SamplingAggregator createAverageAggregator(long value, TimeUnit unit)
{
return new SamplingAggregator("avg", value, unit);
}
Expand All @@ -98,7 +98,7 @@ public static SamplingAggregator createAverageAggregator(int value, TimeUnit uni
* @param unit unit of time
* @return standard deviation aggregator
*/
public static SamplingAggregator createStandardDeviationAggregator(int value, TimeUnit unit)
public static SamplingAggregator createStandardDeviationAggregator(long value, TimeUnit unit)
{
return new SamplingAggregator("dev", value, unit);
}
Expand All @@ -111,7 +111,7 @@ public static SamplingAggregator createStandardDeviationAggregator(int value, Ti
* @param unit unit of time
* @return sum aggregator
*/
public static SamplingAggregator createSumAggregator(int value, TimeUnit unit)
public static SamplingAggregator createSumAggregator(long value, TimeUnit unit)
{
return new SamplingAggregator("sum", value, unit);
}
Expand All @@ -124,7 +124,7 @@ public static SamplingAggregator createSumAggregator(int value, TimeUnit unit)
* @param unit unit of time
* @return count aggregator
*/
public static SamplingAggregator createCountAggregator(int value, TimeUnit unit)
public static SamplingAggregator createCountAggregator(long value, TimeUnit unit)
{
return new SamplingAggregator("count", value, unit);
}
Expand All @@ -138,7 +138,7 @@ public static SamplingAggregator createCountAggregator(int value, TimeUnit unit)
* @param unit unit of time
* @return percentile aggregator
*/
public static PercentileAggregator createPercentileAggregator(double percentile, int value, TimeUnit unit)
public static PercentileAggregator createPercentileAggregator(double percentile, long value, TimeUnit unit)
{
return new PercentileAggregator(percentile, value, unit);
}
Expand All @@ -162,7 +162,7 @@ public static CustomAggregator createDivAggregator(double divisor)
* @param unit unit of time
* @return last aggregator
*/
public static SamplingAggregator createLastAggregator(int value, TimeUnit unit)
public static SamplingAggregator createLastAggregator(long value, TimeUnit unit)
{
return new SamplingAggregator("last", value, unit);
}
Expand All @@ -174,7 +174,7 @@ public static SamplingAggregator createLastAggregator(int value, TimeUnit unit)
* @param unit unit of time
* @return first aggregator
*/
public static SamplingAggregator createFirstAggregator(int value, TimeUnit unit)
public static SamplingAggregator createFirstAggregator(long value, TimeUnit unit)
{
return new SamplingAggregator("first", value, unit);
}
Expand All @@ -186,7 +186,7 @@ public static SamplingAggregator createFirstAggregator(int value, TimeUnit unit)
* @param unit unit of time
* @return gap marking aggregator
*/
public static SamplingAggregator createDataGapsMarkingAggregator(int value, TimeUnit unit)
public static SamplingAggregator createDataGapsMarkingAggregator(long value, TimeUnit unit)
{
return new SamplingAggregator("gaps", value, unit);
}
Expand All @@ -198,7 +198,7 @@ public static SamplingAggregator createDataGapsMarkingAggregator(int value, Time
* @param unit unit of time
* @return least squares aggregator
*/
public static SamplingAggregator createLeastSquaresAggregator(int value, TimeUnit unit)
public static SamplingAggregator createLeastSquaresAggregator(long value, TimeUnit unit)
{
return new SamplingAggregator("least_squares", value, unit);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class PercentileAggregator extends SamplingAggregator
{
private double percentile;

public PercentileAggregator(double percentile, int value, TimeUnit unit)
public PercentileAggregator(double percentile, long value, TimeUnit unit)
{
super("percentile", value, unit);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ public class SamplingAggregator extends Aggregator
@SerializedName("start_time")
private Long startTime;

public SamplingAggregator(String name, int value, TimeUnit unit)
public SamplingAggregator(String name, long value, TimeUnit unit)
{
super(name);
checkArgument(value > 0, "value must be greater than 0.");

sampling = new Sampling(value, unit);
}

public int getValue()
public long getValue()
{
return sampling.value;
}
Expand Down Expand Up @@ -185,13 +185,13 @@ public long getStartTimeAlignmentStartTime()

private class Sampling
{
private Sampling(int value, TimeUnit unit)
private Sampling(long value, TimeUnit unit)
{
this.value = value;
this.unit = requireNonNull(unit);
}

private int value;
private long value;
private TimeUnit unit;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void test_createMinAggregator()
SamplingAggregator minAggregator = AggregatorFactory.createMinAggregator(1, TimeUnit.MINUTES);

assertThat(minAggregator.getName(), equalTo("min"));
assertThat(minAggregator.getValue(), equalTo(1));
assertThat(minAggregator.getValue(), equalTo(1L));
assertThat(minAggregator.getUnit(), equalTo(TimeUnit.MINUTES));
}

Expand All @@ -33,7 +33,7 @@ public void test_createMaxAggregator()
SamplingAggregator minAggregator = AggregatorFactory.createMaxAggregator(1, TimeUnit.MINUTES);

assertThat(minAggregator.getName(), equalTo("max"));
assertThat(minAggregator.getValue(), equalTo(1));
assertThat(minAggregator.getValue(), equalTo(1L));
assertThat(minAggregator.getUnit(), equalTo(TimeUnit.MINUTES));
}

Expand All @@ -43,7 +43,7 @@ public void test_createAverageAggregator()
SamplingAggregator aggregator = AggregatorFactory.createAverageAggregator(2, TimeUnit.YEARS);

assertThat(aggregator.getName(), equalTo("avg"));
assertThat(aggregator.getValue(), equalTo(2));
assertThat(aggregator.getValue(), equalTo(2L));
assertThat(aggregator.getUnit(), equalTo(TimeUnit.YEARS));
}

Expand All @@ -53,7 +53,7 @@ public void test_createStandardDeviationAggregator()
SamplingAggregator aggregator = AggregatorFactory.createStandardDeviationAggregator(3, TimeUnit.DAYS);

assertThat(aggregator.getName(), equalTo("dev"));
assertThat(aggregator.getValue(), equalTo(3));
assertThat(aggregator.getValue(), equalTo(3L));
assertThat(aggregator.getUnit(), equalTo(TimeUnit.DAYS));
}

Expand All @@ -63,7 +63,7 @@ public void test_createSumAggregator()
SamplingAggregator aggregator = AggregatorFactory.createSumAggregator(3, TimeUnit.DAYS);

assertThat(aggregator.getName(), equalTo("sum"));
assertThat(aggregator.getValue(), equalTo(3));
assertThat(aggregator.getValue(), equalTo(3L));
assertThat(aggregator.getUnit(), equalTo(TimeUnit.DAYS));
}

Expand All @@ -73,7 +73,7 @@ public void test_createCountAggregator()
SamplingAggregator aggregator = AggregatorFactory.createCountAggregator(3, TimeUnit.DAYS);

assertThat(aggregator.getName(), equalTo("count"));
assertThat(aggregator.getValue(), equalTo(3));
assertThat(aggregator.getValue(), equalTo(3L));
assertThat(aggregator.getUnit(), equalTo(TimeUnit.DAYS));
}

Expand All @@ -84,7 +84,7 @@ public void test_createPercentileAggregator()

assertThat(aggregator.getName(), equalTo("percentile"));
assertThat(aggregator.getPercentile(),equalTo(0.5));
assertThat(aggregator.getValue(), equalTo(3));
assertThat(aggregator.getValue(), equalTo(3L));
assertThat(aggregator.getUnit(), equalTo(TimeUnit.DAYS));
}

Expand Down Expand Up @@ -121,7 +121,7 @@ public void test_createLastAggregator()
SamplingAggregator aggregator = AggregatorFactory.createLastAggregator(3, TimeUnit.DAYS);

assertThat(aggregator.getName(), equalTo("last"));
assertThat(aggregator.getValue(), equalTo(3));
assertThat(aggregator.getValue(), equalTo(3L));
assertThat(aggregator.getUnit(), equalTo(TimeUnit.DAYS));
}

Expand All @@ -131,7 +131,7 @@ public void test_createLeastSquaresAggregator()
SamplingAggregator aggregator = AggregatorFactory.createLeastSquaresAggregator(3, TimeUnit.DAYS);

assertThat(aggregator.getName(), equalTo("least_squares"));
assertThat(aggregator.getValue(), equalTo(3));
assertThat(aggregator.getValue(), equalTo(3L));
assertThat(aggregator.getUnit(), equalTo(TimeUnit.DAYS));
}

Expand Down