Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public class SamplingAggregator extends Aggregator
@SerializedName("start_time")
private Long startTime;

@SerializedName("trim")
private Boolean trim;

public SamplingAggregator(String name, long value, TimeUnit unit)
{
super(name);
Expand All @@ -57,6 +60,19 @@ public TimeUnit getUnit()
return sampling.unit;
}

/**
* To trim off empty ranges before and after the actual data (issue #453 - https://github.com/kairosdb/kairosdb/issues/453)
* Default value is false.
*
* @return the SamplingAggregator
*/
public SamplingAggregator withTrim()
{
trim = true;

return this;
}

/**
* <p>
* Alignment based on the sampling size. For example if your sample size is either milliseconds,
Expand Down Expand Up @@ -163,6 +179,11 @@ public SamplingAggregator withAlignment(Boolean alignStartTime, Boolean alignSam
return this;
}

public Boolean isTrim()
{
return trim != null ? trim : false;
}

public Boolean isAlignStartTime()
{
return alignStartTime != null ? alignStartTime : false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ public void test_createPercentileAggregator()
assertThat(aggregator.getUnit(), equalTo(TimeUnit.DAYS));
}

@Test
public void test_createDataGapsMarkingAggregator()
{
SamplingAggregator aggregator = AggregatorFactory.createDataGapsMarkingAggregator(3, TimeUnit.DAYS).withTrim();

assertThat(aggregator.getName(), equalTo("gaps"));
assertThat(aggregator.isTrim(),equalTo(true));
assertThat(aggregator.getValue(), equalTo(3));
assertThat(aggregator.getUnit(), equalTo(TimeUnit.DAYS));
}

@Test
public void test_createRateAggregator()
{
Expand Down