Skip to content

Commit

Permalink
feat: encapsulate timing information from which to get cursors
Browse files Browse the repository at this point in the history
  • Loading branch information
metacosm committed Feb 5, 2025
1 parent 147e0b9 commit 92fc624
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ public synchronized TimestampedMeasures getNthTimestampedMeasures(int n) {
return new TimestampedMeasures(timestamps[n], result);
}

public Cursor.PartialCursor getCursorOver(long timestamp, Duration duration) {
return Cursor.cursorOver(timestamps, timestamp, duration, startedAt, samplePeriod);
public Timing timingInfo() {
final var result = new long[timestamps.length];
System.arraycopy(timestamps, 0, result, 0, timestamps.length);
return new Timing(result, startedAt, samplePeriod);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.laprun.sustainability.power.measure;

import java.time.Duration;

public record Timing(long[] timestamps, long startedAt, long samplePeriod) {
public PartialCursor cursorOver(long timestamp, Duration duration) {
return Cursor.cursorOver(timestamps, timestamp, duration, startedAt, samplePeriod);
}
}

0 comments on commit 92fc624

Please sign in to comment.