Skip to content

Commit

Permalink
refactor: inline method
Browse files Browse the repository at this point in the history
We're going to need to change the stoppedByVisitor boolean on line 360
depending on the if condition (deadline <= timestamp). We'll need to
inline the method to make that possible.

Note that the names deadline and messageKey were changed to
deadlineEntry and messageKeyEntry respectively. This is because the
method was static, but when inline this is no longer the case. The
variables would otherwise hide fields with the same names.
  • Loading branch information
korthout committed Mar 7, 2023
1 parent e64778c commit 9b338a8
Showing 1 changed file with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,12 @@ public boolean visitMessagesWithDeadlineBeforeTimestamp(
deadlineColumnFamily.whileTrue(
startAtKey,
(key, value) -> {
final var shouldContinue = visit(timestamp, visitor, key);
boolean shouldContinue = false;
final long deadlineEntry = key.first().getValue();
if (deadlineEntry <= timestamp) {
final long messageKeyEntry = key.second().inner().getValue();
shouldContinue = visitor.visit(deadlineEntry, messageKeyEntry);
}
stoppedByVisitor.set(!shouldContinue);
return shouldContinue;
});
Expand All @@ -368,16 +373,4 @@ public boolean exist(

return messageIdColumnFamily.exists(nameCorrelationMessageIdKey);
}

private static boolean visit(
final long timestamp,
final ExpiredMessageVisitor visitor,
final DbCompositeKey<DbLong, DbForeignKey<DbLong>> compositeDeadlineKey) {
final long deadline = compositeDeadlineKey.first().getValue();
if (deadline <= timestamp) {
final long messageKey = compositeDeadlineKey.second().inner().getValue();
return visitor.visit(deadline, messageKey);
}
return false;
}
}

0 comments on commit 9b338a8

Please sign in to comment.