Skip to content

Commit

Permalink
Support list all paimon branch
Browse files Browse the repository at this point in the history
  • Loading branch information
huyuanfeng committed Sep 24, 2024
1 parent 7b27e16 commit dc78c5b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
import org.apache.commons.lang3.tuple.Pair;
import org.apache.iceberg.util.ThreadPools;

import javax.annotation.Nullable;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -82,7 +80,7 @@ public List<AmoroSnapshotsOfTable> getSnapshots(
}

public List<PartitionFileBaseInfo> getSnapshotDetail(
TableIdentifier tableIdentifier, String snapshotId, @Nullable String ref) {
TableIdentifier tableIdentifier, String snapshotId, String ref) {
AmoroTable<?> amoroTable = loadTable(tableIdentifier);
FormatTableDescriptor formatTableDescriptor = formatDescriptorMap.get(amoroTable.format());
return formatTableDescriptor.getSnapshotDetail(amoroTable, snapshotId, ref);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import org.apache.amoro.TableFormat;
import org.apache.commons.lang3.tuple.Pair;

import javax.annotation.Nullable;

import java.util.List;
import java.util.concurrent.ExecutorService;

Expand All @@ -49,7 +47,7 @@ List<AmoroSnapshotsOfTable> getSnapshots(

/** Get the snapshot detail information of the {@link AmoroTable}. */
List<PartitionFileBaseInfo> getSnapshotDetail(
AmoroTable<?> amoroTable, String snapshotId, @Nullable String ref);
AmoroTable<?> amoroTable, String snapshotId, String ref);

/** Get the DDL information of the {@link AmoroTable}. */
List<DDLInfo> getTableOperations(AmoroTable<?> amoroTable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@
import org.apache.paimon.utils.SnapshotManager;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nullable;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -225,16 +223,17 @@ public List<AmoroSnapshotsOfTable> getSnapshots(

@Override
public List<PartitionFileBaseInfo> getSnapshotDetail(
AmoroTable<?> amoroTable, String snapshotId, @Nullable String ref) {
AmoroTable<?> amoroTable, String snapshotId, String ref) {
FileStoreTable table = getTable(amoroTable);
List<PartitionFileBaseInfo> amsDataFileInfos = new ArrayList<>();
long commitId = Long.parseLong(snapshotId);
Snapshot snapshot;
if (ref != null) {
if (BranchManager.isMainBranch(ref) || table.branchManager().branchExists(ref)) {
snapshot = table.snapshotManager().copyWithBranch(ref).snapshot(commitId);
} else {
snapshot = table.snapshotManager().snapshot(commitId);
snapshot = table.tagManager().tag(ref);
}

FileStore<?> store = table.store();
FileStorePathFactory fileStorePathFactory = store.pathFactory();
ManifestList manifestList = store.manifestListFactory().create();
Expand Down Expand Up @@ -528,10 +527,8 @@ public List<TagOrBranchInfo> getTableTags(AmoroTable<?> amoroTable) {
public List<TagOrBranchInfo> getTableBranches(AmoroTable<?> amoroTable) {
FileStoreTable table = getTable(amoroTable);
List<String> branches = table.branchManager().branches();

List<TagOrBranchInfo> branchInfos =
branches.stream()
.filter(name -> !BranchManager.isMainBranch(name))
.map(name -> new TagOrBranchInfo(name, -1, -1, 0L, 0L, TagOrBranchInfo.BRANCH))
.collect(Collectors.toList());
branchInfos.add(TagOrBranchInfo.MAIN_BRANCH);
Expand Down

0 comments on commit dc78c5b

Please sign in to comment.