Last active
February 19, 2020 12:15
-
-
Save wuchong/9df3c63bd41ec7d2b9f1b8ee09270390 to your computer and use it in GitHub Desktop.
New Source Sink Interface
This file contains hidden or 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
public enum ChangelogMode { | |
/** | |
* Only contains {@link ChangeType#INSERT} messages. | |
*/ | |
INSERT_ONLY(true, false, false, false), | |
/** | |
* Contains {@link ChangeType#INSERT}, {@link ChangeType#DELETE} and {@link ChangeType#UPDATE_AFTER} messages, | |
* but without {@link ChangeType#UPDATE_BEFORE}. | |
*/ | |
UPSERET(true, true, false, true), | |
/** | |
* Contains all possible {@link ChangeType} messages. | |
*/ | |
FULL_CHANGES(true, true, true, true); | |
// TODO: will introduce more modes in the future, e.g. without delete messages. | |
private final boolean hasInsert; | |
private final boolean hasDelete; | |
private final boolean hasUpdateOld; | |
private final boolean hasUpdateNew; | |
private ChangelogMode(boolean hasInsert, boolean hasDelete, boolean hasUpdateOld, boolean hasUpdateNew) { | |
this.hasInsert = hasInsert; | |
this.hasDelete = hasDelete; | |
this.hasUpdateOld = hasUpdateOld; | |
this.hasUpdateNew = hasUpdateNew; | |
} | |
public boolean containsInsertMessages() { | |
return hasInsert; | |
} | |
public boolean containsDeleteMessage() { | |
return hasDelete; | |
} | |
public boolean containsUpdateBeforeMessages() { | |
return hasUpdateOld; | |
} | |
public boolean containsUpdateAfterMessage() { | |
return hasUpdateNew; | |
} | |
} |
This file contains hidden or 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
/** | |
* The set of changes a {@link ScanTableReader} produces and {@link TableWriter} consumes. | |
*/ | |
public enum ChangeMode { | |
INSERT_ONLY( | |
Kind.INSERT), | |
UPSERT( | |
Kind.INSERT, | |
Kind.UPDATE_AFTER, | |
Kind.DELETE), | |
ALL( | |
Kind.INSERT, | |
Kind.UPDATE_BEFORE, | |
Kind.UPDATE_AFTER, | |
Kind.DELETE); | |
private final Set<Kind> kinds; | |
ChangeMode(Kind firstKind, Kind... otherKinds) { | |
this.kinds = Collections.unmodifiableSet(EnumSet.of(firstKind, otherKinds)); | |
} | |
public Set<Kind> getSupportedKinds() { | |
return kinds; | |
} | |
public boolean supportsKind(Kind kind) { | |
return kinds.contains(kind); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment