-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-36541][pipeline-connector][paimon] pass checkpointId to StoreS…
…inkWrite#prepareCommit correctly.
- Loading branch information
Showing
4 changed files
with
161 additions
and
6 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
34 changes: 34 additions & 0 deletions
34
...aimon/src/main/java/org/apache/flink/cdc/connectors/paimon/sink/v2/PaimonWriterState.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,34 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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.cdc.connectors.paimon.sink.v2; | ||
|
||
import java.io.Serializable; | ||
|
||
/** State for {@link PaimonWriter}. */ | ||
public class PaimonWriterState implements Serializable { | ||
|
||
private final long checkpointId; | ||
|
||
public PaimonWriterState(long checkpointId) { | ||
this.checkpointId = checkpointId; | ||
} | ||
|
||
public long getCheckpointId() { | ||
return checkpointId; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...main/java/org/apache/flink/cdc/connectors/paimon/sink/v2/PaimonWriterStateSerializer.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,62 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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.cdc.connectors.paimon.sink.v2; | ||
|
||
import org.apache.flink.core.io.SimpleVersionedSerializer; | ||
import org.apache.flink.core.memory.DataInputViewStreamWrapper; | ||
import org.apache.flink.core.memory.DataOutputViewStreamWrapper; | ||
import org.apache.flink.table.api.TableException; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
|
||
/** A serializer for the {@link PaimonWriterState}. */ | ||
public class PaimonWriterStateSerializer implements SimpleVersionedSerializer<PaimonWriterState> { | ||
|
||
private static final int currentVersion = 0; | ||
|
||
@Override | ||
public int getVersion() { | ||
return currentVersion; | ||
} | ||
|
||
@Override | ||
public byte[] serialize(PaimonWriterState paimonWriterState) throws IOException { | ||
try (ByteArrayOutputStream bao = new ByteArrayOutputStream(256)) { | ||
DataOutputViewStreamWrapper view = new DataOutputViewStreamWrapper(bao); | ||
view.writeLong(paimonWriterState.getCheckpointId()); | ||
return bao.toByteArray(); | ||
} | ||
} | ||
|
||
@Override | ||
public PaimonWriterState deserialize(int version, byte[] serialized) throws IOException { | ||
if (version == 0) { | ||
try (ByteArrayInputStream bis = new ByteArrayInputStream(serialized)) { | ||
DataInputViewStreamWrapper view = new DataInputViewStreamWrapper(bis); | ||
long check = view.readLong(); | ||
return new PaimonWriterState(check); | ||
} | ||
} | ||
throw new TableException( | ||
String.format( | ||
"Can't serialized data with version %d because the max support version is %d.", | ||
version, currentVersion)); | ||
} | ||
} |