Skip to content

Commit

Permalink
remove one method
Browse files Browse the repository at this point in the history
  • Loading branch information
askwang committed Oct 30, 2024
1 parent 084c5fd commit 3caa5de
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -577,16 +577,16 @@ public void renameTag(String tagName, String targetTagName) {
}

@Override
public void replaceTag(String tagName, @Nullable Duration timeRetained) {
Snapshot latestSnapshot = snapshotManager().latestSnapshot();
SnapshotNotExistException.checkNotNull(
latestSnapshot, "Cannot replace tag because latest snapshot doesn't exist.");
tagManager().replaceTag(latestSnapshot, tagName, timeRetained);
}

@Override
public void replaceTag(String tagName, long fromSnapshotId, @Nullable Duration timeRetained) {
tagManager().replaceTag(findSnapshot(fromSnapshotId), tagName, timeRetained);
public void replaceTag(
String tagName, @Nullable Long fromSnapshotId, @Nullable Duration timeRetained) {
if (fromSnapshotId == null) {
Snapshot latestSnapshot = snapshotManager().latestSnapshot();
SnapshotNotExistException.checkNotNull(
latestSnapshot, "Cannot replace tag because latest snapshot doesn't exist.");
tagManager().replaceTag(latestSnapshot, tagName, timeRetained);
} else {
tagManager().replaceTag(findSnapshot(fromSnapshotId), tagName, timeRetained);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,7 @@ public void renameTag(String tagName, String targetTagName) {
}

@Override
public void replaceTag(String tagName, Duration timeRetained) {
wrapped.replaceTag(tagName, timeRetained);
}

@Override
public void replaceTag(String tagName, long fromSnapshotId, Duration timeRetained) {
public void replaceTag(String tagName, Long fromSnapshotId, Duration timeRetained) {
wrapped.replaceTag(tagName, fromSnapshotId, timeRetained);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,7 @@ default void renameTag(String tagName, String targetTagName) {
}

@Override
default void replaceTag(String tagName, Duration timeRetained) {
throw new UnsupportedOperationException();
}

@Override
default void replaceTag(String tagName, long fromSnapshotId, Duration timeRetained) {
default void replaceTag(String tagName, Long fromSnapshotId, Duration timeRetained) {
throw new UnsupportedOperationException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,7 @@ default void renameTag(String tagName, String targetTagName) {
}

@Override
default void replaceTag(String tagName, Duration timeRetained) {
throw new UnsupportedOperationException(
String.format(
"Readonly Table %s does not support replaceTag.",
this.getClass().getSimpleName()));
}

@Override
default void replaceTag(String tagName, long fromSnapshotId, Duration timeRetained) {
default void replaceTag(String tagName, Long fromSnapshotId, Duration timeRetained) {
throw new UnsupportedOperationException(
String.format(
"Readonly Table %s does not support replaceTag.",
Expand Down
6 changes: 1 addition & 5 deletions paimon-core/src/main/java/org/apache/paimon/table/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,9 @@ default String fullName() {
@Experimental
void renameTag(String tagName, String targetTagName);

/** Replace a tag with new time retained. */
@Experimental
void replaceTag(String tagName, Duration timeRetained);

/** Replace a tag with new snapshot id and new time retained. */
@Experimental
void replaceTag(String tagName, long fromSnapshotId, Duration timeRetained);
void replaceTag(String tagName, Long fromSnapshotId, Duration timeRetained);

/** Delete a tag by name. */
@Experimental
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ public class ReplaceTagProcedure extends CreateOrReplaceTagBaseProcedure {

@Override
void createOrReplaceTag(Table table, String tagName, Long snapshotId, Duration timeRetained) {
if (snapshotId == null) {
table.replaceTag(tagName, timeRetained);
} else {
table.replaceTag(tagName, snapshotId, timeRetained);
}
table.replaceTag(tagName, snapshotId, timeRetained);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ public ReplaceTagAction(

@Override
public void run() throws Exception {
if (snapshotId == null) {
table.replaceTag(tagName, timeRetained);
} else {
table.replaceTag(tagName, snapshotId, timeRetained);
}
table.replaceTag(tagName, snapshotId, timeRetained);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ public class ReplaceTagProcedure extends CreateOrReplaceTagBaseProcedure {

@Override
void createOrReplaceTag(Table table, String tagName, Long snapshotId, Duration timeRetained) {
if (snapshotId == null) {
table.replaceTag(tagName, timeRetained);
} else {
table.replaceTag(tagName, snapshotId, timeRetained);
}
table.replaceTag(tagName, snapshotId, timeRetained);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ private ReplaceTagProcedure(TableCatalog tableCatalog) {

@Override
void createOrReplaceTag(Table table, String tagName, Long snapshotId, Duration timeRetained) {
if (snapshotId == null) {
table.replaceTag(tagName, timeRetained);
} else {
table.replaceTag(tagName, snapshotId, timeRetained);
}
table.replaceTag(tagName, snapshotId, timeRetained);
}

public static ProcedureBuilder builder() {
Expand Down

0 comments on commit 3caa5de

Please sign in to comment.