JingsongLi commented on code in PR #605:
URL: https://github.com/apache/flink-table-store/pull/605#discussion_r1136499298
##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/operation/AbstractFileStoreWrite.java:
##########
@@ -232,50 +210,131 @@ public void close() throws Exception {
}
}
+ @Override
+ public List<State> extractStateAndClose() throws Exception {
Review Comment:
Can we just have two methods: `checkpoint` and `close`?
##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/RecordWriter.java:
##########
@@ -51,6 +50,9 @@
*/
void addNewFiles(List<DataFileMeta> files);
+ /** Get all files maintained by this writer. */
+ List<DataFileMeta> allFiles();
Review Comment:
allFiles -> dataFiles?
##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/operation/AbstractFileStoreWrite.java:
##########
@@ -232,50 +210,131 @@ public void close() throws Exception {
}
}
+ @Override
+ public List<State> extractStateAndClose() throws Exception {
+ List<State> result = new ArrayList<>();
+ for (Map.Entry<BinaryRow, Map<Integer, WriterContainer<T>>>
partitionEntry :
+ writers.entrySet()) {
+ BinaryRow partition = partitionEntry.getKey();
+ for (Map.Entry<Integer, WriterContainer<T>> bucketEntry :
+ partitionEntry.getValue().entrySet()) {
+ int bucket = bucketEntry.getKey();
+ WriterContainer<T> writerContainer = bucketEntry.getValue();
+ CommitIncrement increment =
writerContainer.writer.extractStateAndClose();
+ // writer.allFiles() must be fetched after
writer.extractStateAndClose(), because
+ // compaction result might be updated when closing a writer
+ List<DataFileMeta> allFiles =
writerContainer.writer.allFiles();
+ result.add(
+ new State(
+ partition,
+ bucket,
+ writerContainer.baseSnapshotId,
+ writerContainer.lastModifiedCommitIdentifier,
+ allFiles,
+ increment));
+ }
+ }
+ writers.clear();
+ if (lazyCompactExecutor != null) {
+ lazyCompactExecutor.shutdownNow();
+ }
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Extracted state " + result.toString());
+ }
+ return result;
+ }
+
+ @Override
+ public void recoverFromState(List<State> states) {
Review Comment:
`restore`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]