Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Aitozi committed Apr 1, 2024
1 parent d871ee5 commit cabfcb6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
5 changes: 2 additions & 3 deletions paimon-core/src/main/java/org/apache/paimon/Changelog.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@
/**
* The metadata of changelog. It generates from the snapshot file during expiration. So that the
* changelog of the table can outlive the snapshot's lifecycle. A table's changelog can come from
* two source:
* one source:
* <li>The changelog file. Eg: from the changelog-producer = 'input'
* <li>The delta files in the APPEND commits when the changelog-producer = 'none'
*/
public class Changelog extends Snapshot {

private static final int CURRENT_VERSION = 1;
private static final int CURRENT_VERSION = Snapshot.CURRENT_VERSION;

public Changelog(
long id,
Expand Down
2 changes: 1 addition & 1 deletion paimon-core/src/main/java/org/apache/paimon/Snapshot.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class Snapshot {
public static final long FIRST_SNAPSHOT_ID = 1;

public static final int TABLE_STORE_02_VERSION = 1;
private static final int CURRENT_VERSION = 3;
protected static final int CURRENT_VERSION = 3;

protected static final String FIELD_VERSION = "version";
protected static final String FIELD_ID = "id";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package org.apache.paimon.operation;

import org.apache.paimon.Changelog;
import org.apache.paimon.CoreOptions;
import org.apache.paimon.Snapshot;
import org.apache.paimon.data.BinaryRow;
Expand Down Expand Up @@ -387,10 +386,6 @@ private List<ManifestFileMeta> readManifests(Snapshot snapshot) {
case DELTA:
return snapshot.deltaManifests(manifestList);
case CHANGELOG:
if (snapshot instanceof Changelog) {
return snapshot.changelogManifests(manifestList);
}

if (snapshot.version() > Snapshot.TABLE_STORE_02_VERSION) {
return snapshot.changelogManifests(manifestList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ public int expireUntil(long earliestId, long endExclusiveId) {
snapshot.changelogRecordCount(),
snapshot.watermark(),
null);
commitChangelog(changelog);
snapshotDeletion.cleanUnusedManifests(snapshot, skippingSet, false);
} else {
// no changelog
Expand All @@ -264,14 +265,9 @@ public int expireUntil(long earliestId, long endExclusiveId) {
snapshot.changelogRecordCount(),
snapshot.watermark(),
snapshot.statistics());
commitChangelog(changelog);
snapshotDeletion.cleanUnusedManifests(snapshot, skippingSet, true);
}
try {
snapshotManager.commitChangelog(changelog, id);
snapshotManager.commitLongLivedChangelogLatestHint(id);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
} else {
snapshotDeletion.cleanUnusedManifests(snapshot, skippingSet, true);
}
Expand All @@ -282,6 +278,15 @@ public int expireUntil(long earliestId, long endExclusiveId) {
return (int) (endExclusiveId - beginInclusiveId);
}

private void commitChangelog(Changelog changelog) {
try {
snapshotManager.commitChangelog(changelog, changelog.id());
snapshotManager.commitLongLivedChangelogLatestHint(changelog.id());
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}

private void writeEarliestHint(long earliest) {
try {
snapshotManager.commitEarliestHint(earliest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ private List<Changelog> cleanLongLivedChangelogDataFiles(Snapshot retainedSnapsh
if (changelog.changelogManifestList() != null) {
snapshotDeletion.deleteAddedDataFiles(changelog.changelogManifestList());
}
if (changelog.deltaManifestList() != null) {
snapshotDeletion.deleteAddedDataFiles(changelog.deltaManifestList());
}
}

// delete directories
Expand Down

0 comments on commit cabfcb6

Please sign in to comment.