Source:
<code>private List<Metric> _fillLine(List<String> constants, long relativeTo) { SystemAssert.requireArgument(constants != null && constants.size() == 5, "Line Filling Transform needs 5 constants (start, end, interval, offset, value)!"); long startTimestamp = _parseStartAndEndTimestamps(constants.get(0), relativeTo); long endTimestamp = _parseStartAndEndTimestamps(constants.get(1), relativeTo); long windowSizeInSeconds = _parseTimeIntervalInSeconds(constants.get(2)); long offsetInSeconds = _parseTimeIntervalInSeconds(constants.get(3)); double value = Double.parseDouble(constants.get(4)); SystemAssert.requireArgument(startTimestamp < endTimestamp, "End time must occur later than start time!"); <START> SystemAssert.requireArgument(windowSizeInSeconds >= 0, "Window size must be greater than ZERO!"); <END> Metric metric = new Metric(DEFAULT_SCOPE_NAME, DEFAULT_METRIC_NAME); Map<Long, Double> filledDatapoints = new TreeMap<>(); while (startTimestamp < endTimestamp) { filledDatapoints.put(startTimestamp, value); startTimestamp += windowSizeInSeconds * 1000; } filledDatapoints.put(endTimestamp, value); Map<Long, Double> newFilledDatapoints = new TreeMap<>(); for (Map.Entry<Long, Double> entry : filledDatapoints.entrySet()) { newFilledDatapoints.put(entry.getKey() + offsetInSeconds * 1000, entry.getValue()); } metric.setDatapoints(newFilledDatapoints); List<Metric> lineMetrics = new ArrayList<Metric>(); lineMetrics.add(metric); return lineMetrics; }</code><technical_language>need this snapping logic if window is divisible step size</technical_language>

Target:
private List<Metric> _fillLine(List<String> constants, long relativeTo) { SystemAssert.requireArgument(constants != null && constants.size() == 5, "Line Filling Transform needs 5 constants (start, end, interval, offset, value)!"); long windowSizeInSeconds = _parseTimeIntervalInSeconds(constants.get(2)); long startTimestamp = _parseStartAndEndTimestamps(constants.get(0), relativeTo, windowSizeInSeconds >= 60); long endTimestamp = _parseStartAndEndTimestamps(constants.get(1), relativeTo, windowSizeInSeconds >= 60); long offsetInSeconds = _parseTimeIntervalInSeconds(constants.get(3)); double value = Double.parseDouble(constants.get(4)); boolean isDivisible = ((startTimestamp - endTimestamp) % (windowSizeInSeconds * 1000)) == 0; if (!isDivisible) { long startSnapping = startTimestamp % (windowSizeInSeconds * 1000); startTimestamp = startTimestamp - startSnapping; long endSnapping = endTimestamp % (windowSizeInSeconds * 1000); endTimestamp = endTimestamp - endSnapping; } SystemAssert.requireArgument(startTimestamp < endTimestamp, "End time must occur later than start time!"); SystemAssert.requireArgument(windowSizeInSeconds >= 0, "Window size must be greater than ZERO!"); Metric metric = new Metric(DEFAULT_SCOPE_NAME, DEFAULT_METRIC_NAME); Map<Long, Double> filledDatapoints = new TreeMap<>(); while (startTimestamp < endTimestamp) { filledDatapoints.put(startTimestamp, value); startTimestamp += windowSizeInSeconds * 1000; } filledDatapoints.put(endTimestamp, value); Map<Long, Double> newFilledDatapoints = new TreeMap<>(); for (Map.Entry<Long, Double> entry : filledDatapoints.entrySet()) { newFilledDatapoints.put(entry.getKey() + offsetInSeconds * 1000, entry.getValue()); } metric.setDatapoints(newFilledDatapoints); List<Metric> lineMetrics = new ArrayList<Metric>(); lineMetrics.add(metric); return lineMetrics; }