Skip to content

Commit 6fcb6be

Browse files
committed
refactor: rename PartialCursor to simply Cursor
1 parent 08adc7c commit 6fcb6be

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

measure/src/main/java/net/laprun/sustainability/power/measure/PartialCursor.java renamed to measure/src/main/java/net/laprun/sustainability/power/measure/Cursor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package net.laprun.sustainability.power.measure;
22

3-
public record PartialCursor(int startIndex, int endIndex, double firstMeasureRatio, double lastMeasureRatio) {
3+
public record Cursor(int startIndex, int endIndex, double firstMeasureRatio, double lastMeasureRatio) {
44

5-
public static final PartialCursor empty = new PartialCursor(-1, -1, 0.0, 0.0);
5+
public static final Cursor empty = new Cursor(-1, -1, 0.0, 0.0);
66

77
public double sum(double[] values) {
88
if (values == null || values.length == 0 || this == empty || values.length <= endIndex) {

measure/src/main/java/net/laprun/sustainability/power/measure/Cursors.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
public enum Cursors {
66
;
77

8-
public static PartialCursor cursorOver(long[] timestamps, long timestamp, Duration duration, long initialOffset,
8+
public static Cursor cursorOver(long[] timestamps, long timestamp, Duration duration, long initialOffset,
99
long averagePeriodHint) {
1010
// adjusted timestamp for modding
1111
final var timestampForDiv = timestamp - initialOffset;
1212
final var durationAsMs = duration.toMillis();
1313

1414
// cannot find an interval for a timestamp that is before the recording started
1515
if (timestampForDiv < 0) {
16-
return PartialCursor.empty;
16+
return Cursor.empty;
1717
}
1818

1919
if (timestamps.length < 2) {
@@ -22,7 +22,7 @@ public static PartialCursor cursorOver(long[] timestamps, long timestamp, Durati
2222
if (averagePeriodHint > 0) {
2323
ratio = (double) durationAsMs / averagePeriodHint;
2424
}
25-
return new PartialCursor(0, 0, ratio, ratio);
25+
return new Cursor(0, 0, ratio, ratio);
2626
}
2727

2828
// estimate sample period based on 2 samples interval
@@ -38,7 +38,7 @@ public static PartialCursor cursorOver(long[] timestamps, long timestamp, Durati
3838
final long previousTimestamp = startIndex == 0 ? initialOffset : timestamps[startIndex - 1];
3939
final long slotDuration = timestamps[startIndex] - previousTimestamp;
4040
var ratio = (double) durationAsMs / slotDuration;
41-
return new PartialCursor(startIndex, endIndex, ratio, -1);
41+
return new Cursor(startIndex, endIndex, ratio, -1);
4242
}
4343

4444
// get the index with the timestamp right after the one we're looking for since what we're interested in is the portion of the measure that gets recorded after the timestamp we want
@@ -58,6 +58,6 @@ public static PartialCursor cursorOver(long[] timestamps, long timestamp, Durati
5858
endRatio = (double) endOffset / slotDuration;
5959
}
6060

61-
return new PartialCursor(startIndex, endIndex, startRatio, endRatio);
61+
return new Cursor(startIndex, endIndex, startRatio, endRatio);
6262
}
6363
}

measure/src/main/java/net/laprun/sustainability/power/measure/MeasureBackedCursor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import net.laprun.sustainability.power.analysis.Recorder;
44

5-
public record MeasureBackedCursor(Recorder measure, PartialCursor cursor) {
5+
public record MeasureBackedCursor(Recorder measure, Cursor cursor) {
66
public double sum() {
77
return cursor.sum(measure.liveMeasures());
88
}

measure/src/main/java/net/laprun/sustainability/power/measure/Timing.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.time.Duration;
44

55
public record Timing(long[] timestamps, long startedAt, long samplePeriod) {
6-
public PartialCursor cursorOver(long timestamp, Duration duration) {
6+
public Cursor cursorOver(long timestamp, Duration duration) {
77
return Cursors.cursorOver(timestamps, timestamp, duration, startedAt, samplePeriod);
88
}
99
}

0 commit comments

Comments
 (0)