LadyForest commented on code in PR #119:
URL: https://github.com/apache/flink-table-store/pull/119#discussion_r876859381
##########
flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/TableStoreFactory.java:
##########
@@ -165,7 +187,36 @@ public void onDropTable(Context context, boolean
ignoreIfNotExists) {
@Override
public Map<String, String> onCompactTable(
Context context, CatalogPartitionSpec catalogPartitionSpec) {
- throw new UnsupportedOperationException("Not implement yet");
+ Map<String, String> newOptions = new
HashMap<>(context.getCatalogTable().getOptions());
+ FileStore fileStore = buildTableStore(context).buildFileStore();
+ Predicate partitionFilter =
+ PredicateConverter.CONVERTER.fromMap(
+ catalogPartitionSpec.getPartitionSpec(),
fileStore.partitionType());
+ FileStoreScan.Plan plan =
fileStore.newScan().withPartitionFilter(partitionFilter).plan();
+ Map<BinaryRowData, Map<Integer, List<DataFileMeta>>> groupBy =
plan.groupByPartFiles();
+
+ Map<BinaryRowData, Map<Integer, List<DataFileMeta>>> filteredGroupBy;
+ if
(Boolean.parseBoolean(newOptions.get(COMPACTION_RESCALE_BUCKET.key()))) {
+ filteredGroupBy = groupBy;
+ } else {
+ filteredGroupBy =
+ pickManifest(
+ groupBy,
+ new
FileStoreOptions(Configuration.fromMap(newOptions))
+ .mergeTreeOptions(),
+ fileStore.keyType().getChildren());
+ }
+ PartitionedManifestMeta manifestMeta =
+ new PartitionedManifestMeta(plan.snapshotId(),
filteredGroupBy);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(
+ "Data files to be compacted for managed table {} are {}
with root path {}",
+ context.getObjectIdentifier().asSerializableString(),
+ manifestMeta.asString(fileStore.partitionType()),
+ newOptions.get(PATH.key()));
+ }
+ newOptions.put(COMPACTION_SCANNED_MANIFEST.key(),
manifestMeta.toJson());
Review Comment:
> Okay, looks like we are just encoding the object into this option by this
method, rather than by manual.
Yes, `COMPACTION_SCANNED_MANIFEST` is an internal option.
--
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]