-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from meta-soul/flink_cdc_test
Fix flink cdc write event order
- Loading branch information
Showing
18 changed files
with
181 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...soul-flink/src/main/java/org/apache/flink/lakeSoul/sink/bucket/LakeSoulCDCComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.apache.flink.lakeSoul.sink.bucket; | ||
|
||
import org.apache.flink.table.data.RowData; | ||
import org.apache.flink.table.runtime.generated.RecordComparator; | ||
|
||
import java.io.Serializable; | ||
import java.util.Comparator; | ||
|
||
public class LakeSoulCDCComparator implements Comparator<LakeSoulCDCElement>, Serializable { | ||
private RecordComparator rc; | ||
public LakeSoulCDCComparator(RecordComparator rc){ | ||
this.rc=rc; | ||
} | ||
@Override | ||
public int compare(LakeSoulCDCElement E1, LakeSoulCDCElement E2) { | ||
int res=rc.compare(E1.element,E2.element); | ||
if(res!=0){ | ||
return res; | ||
}else{ | ||
res=compareLong(E1.timedata,E2.timedata); | ||
if(res!=0){ | ||
return res; | ||
}else{ | ||
return compareEvent(E1.element,E2.element); | ||
} | ||
} | ||
} | ||
public int compareLong(long e1,long e2){ | ||
long res=e1-e2; | ||
if(res==0){ | ||
return 0; | ||
}else{ | ||
if(res<0){ | ||
return -1; | ||
}else{ | ||
return 1; | ||
} | ||
} | ||
} | ||
public int compareEvent(RowData e1,RowData e2){ | ||
return Byte.compare(e1.getRowKind().toByteValue(),e2.getRowKind().toByteValue()); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
lakesoul-flink/src/main/java/org/apache/flink/lakeSoul/sink/bucket/LakeSoulCDCElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* | ||
* Copyright [2022] [DMetaSoul Team] | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* | ||
*/ | ||
package org.apache.flink.lakeSoul.sink.bucket; | ||
|
||
import org.apache.flink.table.data.RowData; | ||
|
||
public class LakeSoulCDCElement { | ||
public RowData element; | ||
public long timedata; | ||
public LakeSoulCDCElement(RowData rd, long td){ | ||
this.element=rd; | ||
this.timedata=td; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.