Skip to content

Commit c291768

Browse files
author
nguyenaiden
committed
Renamed Target position methods
combined conditionals for cleanliness
1 parent b78199f commit c291768

File tree

4 files changed

+6
-13
lines changed

4 files changed

+6
-13
lines changed

airbyte-integrations/bases/debezium/src/main/java/io/airbyte/integrations/debezium/CdcTargetPosition.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ default boolean isHeartbeatSupported() {
6161
* @param event Event from the CDC load
6262
* @return Returns `true` when the record is behind the offset. Otherwise, it returns `false`
6363
*/
64-
default boolean isRecordBehindOffset(final Map<String, String> offset, final ChangeEventWithMetadata event) {
64+
default boolean isEventAheadOffset(final Map<String, String> offset, final ChangeEventWithMetadata event) {
6565
return false;
6666
}
6767

airbyte-integrations/bases/debezium/src/main/java/io/airbyte/integrations/debezium/internals/DebeziumStateDecoratingIterator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ protected AirbyteMessage computeNext() {
162162
if (checkpointOffsetToSend.size() == 1
163163
&& changeEventIterator.hasNext()
164164
&& !event.isSnapshotEvent()
165-
&& targetPosition.isRecordBehindOffset(checkpointOffsetToSend, event)) {
165+
&& targetPosition.isEventAheadOffset(checkpointOffsetToSend, event)) {
166166
sendCheckpointMessage = true;
167167
}
168168
}

airbyte-integrations/bases/debezium/src/main/java/io/airbyte/integrations/debezium/internals/mysql/MySqlCdcTargetPosition.java

+3-10
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public boolean isHeartbeatSupported() {
105105
}
106106

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

127127
@Override
128128
public boolean isSameOffset(final Map<String, String> offsetA, final Map<String, String> offsetB) {
129-
if (offsetA == null || offsetA.size() != 1) {
130-
return false;
131-
}
132-
if (offsetB == null || offsetB.size() != 1) {
129+
if ((offsetA == null || offsetA.size() != 1) || (offsetB == null || offsetB.size() != 1)) {
133130
return false;
134131
}
135132

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

144-
if (offsetAFileName.compareTo(offsetBFileName) != 0) {
145-
return false;
146-
}
147-
148-
return offsetAPosition == offsetBPosition;
141+
return offsetAFileName.equals(offsetBFileName) && offsetAPosition == offsetBPosition;
149142
}
150143

151144
@Override

airbyte-integrations/bases/debezium/src/main/java/io/airbyte/integrations/debezium/internals/postgres/PostgresCdcTargetPosition.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public Long extractPositionFromHeartbeatOffset(final Map<String, ?> sourceOffset
9494
}
9595

9696
@Override
97-
public boolean isRecordBehindOffset(final Map<String, String> offset, final ChangeEventWithMetadata event) {
97+
public boolean isEventAheadOffset(final Map<String, String> offset, final ChangeEventWithMetadata event) {
9898
if (offset.size() != 1) {
9999
return false;
100100
}

0 commit comments

Comments
 (0)