Skip to content

Commit

Permalink
rename method; add comment
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Kao <[email protected]>
  • Loading branch information
seankao-az committed Oct 25, 2024
1 parent 7a8e1f3 commit d80d34d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,8 @@ class FlintSpark(val spark: SparkSession) extends FlintSparkTransactionSupport w

/**
* Handles refresh for refresh mode AUTO, which is used exclusively by auto refresh index with
* internal scheduler.
* internal scheduler. Refresh start time and complete time aren't tracked for streaming job.
* TODO: in future, track MicroBatchExecution time for streaming job and update as well
*/
private def refreshIndexAuto(
index: FlintSparkIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ object FlintMetadataCache {
val refreshInterval = if (indexOptions.autoRefresh()) {
indexOptions
.refreshInterval()
.map(IntervalSchedulerParser.parseMillis)
.map(IntervalSchedulerParser.parseAndConvertToMillis)
.map(millis => (millis / 1000).toInt) // convert to seconds
} else {
None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class IntervalSchedulerParser {
* @return the parsed integer
* @throws IllegalArgumentException if the schedule string is invalid
*/
public static Long parseMillis(String scheduleStr) {
public static Long parseAndConvertToMillis(String scheduleStr) {
if (Strings.isNullOrEmpty(scheduleStr)) {
throw new IllegalArgumentException("Schedule string must not be null or empty.");
}
Expand All @@ -41,7 +41,7 @@ public static Long parseMillis(String scheduleStr) {
*/
public static IntervalSchedule parse(String scheduleStr) {
// Convert milliseconds to minutes (rounding down)
int minutes = (int) (parseMillis(scheduleStr) / (60 * 1000));
int minutes = (int) (parseAndConvertToMillis(scheduleStr) / (60 * 1000));

// Use the current time as the start time
Instant startTime = Instant.now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void testParseNull() {

@Test(expected = IllegalArgumentException.class)
public void testParseMillisNull() {
IntervalSchedulerParser.parseMillis(null);
IntervalSchedulerParser.parseAndConvertToMillis(null);
}

@Test(expected = IllegalArgumentException.class)
Expand All @@ -35,7 +35,7 @@ public void testParseEmptyString() {

@Test(expected = IllegalArgumentException.class)
public void testParseMillisEmptyString() {
IntervalSchedulerParser.parseMillis("");
IntervalSchedulerParser.parseAndConvertToMillis("");
}

@Test
Expand All @@ -49,7 +49,7 @@ public void testParseString() {

@Test
public void testParseMillisString() {
Long millis = IntervalSchedulerParser.parseMillis("10 minutes");
Long millis = IntervalSchedulerParser.parseAndConvertToMillis("10 minutes");
assertEquals(600000, millis.longValue());
}

Expand All @@ -60,7 +60,7 @@ public void testParseInvalidFormat() {

@Test(expected = IllegalArgumentException.class)
public void testParseMillisInvalidFormat() {
IntervalSchedulerParser.parseMillis("invalid format");
IntervalSchedulerParser.parseAndConvertToMillis("invalid format");
}

@Test
Expand All @@ -72,7 +72,7 @@ public void testParseStringScheduleMinutes() {

@Test
public void testParseMillisStringScheduleMinutes() {
Long millis = IntervalSchedulerParser.parseMillis("5 minutes");
Long millis = IntervalSchedulerParser.parseAndConvertToMillis("5 minutes");
assertEquals(300000, millis.longValue());
}

Expand All @@ -85,7 +85,7 @@ public void testParseStringScheduleHours() {

@Test
public void testParseMillisStringScheduleHours() {
Long millis = IntervalSchedulerParser.parseMillis("2 hours");
Long millis = IntervalSchedulerParser.parseAndConvertToMillis("2 hours");
assertEquals(7200000, millis.longValue());
}

Expand All @@ -98,7 +98,7 @@ public void testParseStringScheduleDays() {

@Test
public void testParseMillisStringScheduleDays() {
Long millis = IntervalSchedulerParser.parseMillis("1 day");
Long millis = IntervalSchedulerParser.parseAndConvertToMillis("1 day");
assertEquals(86400000, millis.longValue());
}

Expand Down

0 comments on commit d80d34d

Please sign in to comment.