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

Handling null cases in sum,min,max series builders #14084

Merged
merged 4 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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,7 +39,7 @@ public MaxTimeSeriesBuilder(String id, TimeBuckets timeBuckets, List<String> tag

@Override
public void addValueAtIndex(int timeBucketIndex, Double value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest adding @Nullable annotation both to base class and the overrides

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack. Will add it in the next PR I am working on.

if (_values[timeBucketIndex] == null || value > _values[timeBucketIndex]) {
if (value != null && (_values[timeBucketIndex] == null || value > _values[timeBucketIndex])) {
_values[timeBucketIndex] = value;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public MinTimeSeriesBuilder(String id, TimeBuckets timeBuckets, List<String> tag

@Override
public void addValueAtIndex(int timeBucketIndex, Double value) {
if (_values[timeBucketIndex] == null || value < _values[timeBucketIndex]) {
_values[timeBucketIndex] = value;
if (value != null && (_values[timeBucketIndex] == null || value < _values[timeBucketIndex])) {
_values[timeBucketIndex] = value;
raghavyadav01 marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public SummingTimeSeriesBuilder(String id, TimeBuckets timeBuckets, List<String>

@Override
public void addValueAtIndex(int timeBucketIndex, Double value) {
_values[timeBucketIndex] = (_values[timeBucketIndex] == null ? 0 : _values[timeBucketIndex]) + value;
if (value != null) {
_values[timeBucketIndex] = (_values[timeBucketIndex] == null ? 0.0 : _values[timeBucketIndex]) + value;
}
}

@Override
Expand Down
Loading