forked from debezium/debezium
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CXP-2779: introduced SchemaHistorySnapshot interface
- Loading branch information
1 parent
493101f
commit c7393e7
Showing
4 changed files
with
75 additions
and
16 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
53 changes: 53 additions & 0 deletions
53
...ium-core/src/main/java/io/debezium/relational/history/snapshot/SchemaHistorySnapshot.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,53 @@ | ||
/* | ||
* Copyright Debezium Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.debezium.relational.history.snapshot; | ||
|
||
import io.debezium.relational.Tables; | ||
|
||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
public interface SchemaHistorySnapshot { | ||
|
||
String CONFIGURATION_FIELD_PREFIX_STRING = "schema.history.internal.snapshot."; | ||
|
||
void save(Map<String, ?> source, Map<String, ?> position, Tables schema); | ||
|
||
void read(Map<Map<String, ?>, Map<String, ?>> offsets, Tables schema); | ||
|
||
/** | ||
* TODO: use connectorOffsets to: | ||
* 1. find all serialized snapshots | ||
* 2. filter out the ones not matching source partition | ||
* 3. filter out the ones with offset structure which differs from given | ||
* 4. sort the list by offsets using HistoryRecordComparator | ||
* 5. find the closest (smaller) offsets to the given ones | ||
* | ||
* TODO: implement offset -> snapshot name | ||
* TODO: implement snapshot name -> offset | ||
* | ||
* @param connectorOffsets | ||
* @return | ||
*/ | ||
Map<Map<String, ?>, Map<String, ?>> getOffsets(Map<Map<String, ?>, Map<String, ?>> connectorOffsets); | ||
|
||
SchemaHistorySnapshot NOOP = new SchemaHistorySnapshot() { | ||
@Override | ||
public void save(Map<String, ?> source, Map<String, ?> position, Tables schema) { | ||
|
||
} | ||
|
||
@Override | ||
public void read(Map<Map<String, ?>, Map<String, ?>> offsets, Tables schema) { | ||
|
||
} | ||
|
||
@Override | ||
public Map<Map<String, ?>, Map<String, ?>> getOffsets(Map<Map<String, ?>, Map<String, ?>> connectorOffsets) { | ||
return connectorOffsets.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> null)); | ||
} | ||
}; | ||
} |