Skip to content

Commit

Permalink
Renamed Target position methods
Browse files Browse the repository at this point in the history
combined conditionals for cleanliness
  • Loading branch information
nguyenaiden committed Aug 21, 2023
1 parent 143a24a commit a275611
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ default boolean isHeartbeatSupported() {
* @param event Event from the CDC load
* @return Returns `true` when the record is behind the offset. Otherwise, it returns `false`
*/
default boolean isRecordBehindOffset(final Map<String, String> offset, final ChangeEventWithMetadata event) {
default boolean isEventAheadOffset(final Map<String, String> offset, final ChangeEventWithMetadata event) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ protected AirbyteMessage computeNext() {
if (checkpointOffsetToSend.size() == 1
&& changeEventIterator.hasNext()
&& !event.isSnapshotEvent()
&& targetPosition.isRecordBehindOffset(checkpointOffsetToSend, event)) {
&& targetPosition.isEventAheadOffset(checkpointOffsetToSend, event)) {
sendCheckpointMessage = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public boolean isHeartbeatSupported() {
}

@Override
public boolean isRecordBehindOffset(final Map<String, String> offset, final ChangeEventWithMetadata event) {
public boolean isEventAheadOffset(final Map<String, String> offset, final ChangeEventWithMetadata event) {
if (offset.size() != 1) {
return false;
}
Expand All @@ -126,10 +126,7 @@ public boolean isRecordBehindOffset(final Map<String, String> offset, final Chan

@Override
public boolean isSameOffset(final Map<String, String> offsetA, final Map<String, String> offsetB) {
if (offsetA == null || offsetA.size() != 1) {
return false;
}
if (offsetB == null || offsetB.size() != 1) {
if ((offsetA == null || offsetA.size() != 1) || (offsetB == null || offsetB.size() != 1)) {
return false;
}

Expand All @@ -141,11 +138,7 @@ public boolean isSameOffset(final Map<String, String> offsetA, final Map<String,
final String offsetBFileName = offsetJsonB.get("file").asText();
final long offsetBPosition = offsetJsonB.get("pos").asLong();

if (offsetAFileName.compareTo(offsetBFileName) != 0) {
return false;
}

return offsetAPosition == offsetBPosition;
return offsetAFileName.equals(offsetBFileName) && offsetAPosition == offsetBPosition;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public Long extractPositionFromHeartbeatOffset(final Map<String, ?> sourceOffset
}

@Override
public boolean isRecordBehindOffset(final Map<String, String> offset, final ChangeEventWithMetadata event) {
public boolean isEventAheadOffset(final Map<String, String> offset, final ChangeEventWithMetadata event) {
if (offset.size() != 1) {
return false;
}
Expand Down

0 comments on commit a275611

Please sign in to comment.