Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AMORO-2842] Support list all paimon branch #3093

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nullable;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -337,7 +339,7 @@ private void collectSnapshots(

@Override
public List<PartitionFileBaseInfo> getSnapshotDetail(
AmoroTable<?> amoroTable, String snapshotId) {
AmoroTable<?> amoroTable, String snapshotId, @Nullable String ref) {
MixedTable mixedTable = getTable(amoroTable);
List<PartitionFileBaseInfo> result = new ArrayList<>();
long commitId = Long.parseLong(snapshotId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ public List<AmoroSnapshotsOfTable> getSnapshots(
}

public List<PartitionFileBaseInfo> getSnapshotDetail(
TableIdentifier tableIdentifier, String snapshotId) {
TableIdentifier tableIdentifier, String snapshotId, String ref) {
AmoroTable<?> amoroTable = loadTable(tableIdentifier);
FormatTableDescriptor formatTableDescriptor = formatDescriptorMap.get(amoroTable.format());
return formatTableDescriptor.getSnapshotDetail(amoroTable, snapshotId);
return formatTableDescriptor.getSnapshotDetail(amoroTable, snapshotId, ref);
}

public List<DDLInfo> getTableOperations(TableIdentifier tableIdentifier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,13 @@ public void getSnapshotDetail(Context ctx) {
String snapshotId = ctx.pathParam("snapshotId");
Integer page = ctx.queryParamAsClass("page", Integer.class).getOrDefault(1);
Integer pageSize = ctx.queryParamAsClass("pageSize", Integer.class).getOrDefault(20);
String ref = ctx.queryParamAsClass("ref", String.class).getOrDefault(null);

List<PartitionFileBaseInfo> result =
tableDescriptor.getSnapshotDetail(
TableIdentifier.of(catalog, database, tableName).buildTableIdentifier(), snapshotId);
TableIdentifier.of(catalog, database, tableName).buildTableIdentifier(),
snapshotId,
ref);
int offset = (page - 1) * pageSize;
PageResult<PartitionFileBaseInfo> amsPageResult = PageResult.of(result, offset, pageSize);
ctx.json(OkResponse.of(amsPageResult));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ List<AmoroSnapshotsOfTable> getSnapshots(
AmoroTable<?> amoroTable, String ref, OperationType operationType);

/** Get the snapshot detail information of the {@link AmoroTable}. */
List<PartitionFileBaseInfo> getSnapshotDetail(AmoroTable<?> amoroTable, String snapshotId);
List<PartitionFileBaseInfo> getSnapshotDetail(
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 @@ -74,6 +74,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nullable;

import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
Expand Down Expand Up @@ -244,7 +246,7 @@ public List<AmoroSnapshotsOfTable> getSnapshots(

@Override
public List<PartitionFileBaseInfo> getSnapshotDetail(
AmoroTable<?> amoroTable, String snapshotId) {
AmoroTable<?> amoroTable, String snapshotId, @Nullable String ref) {
HoodieJavaTable hoodieTable = (HoodieJavaTable) amoroTable.originalTable();
SyncableFileSystemView fileSystemView = hoodieTable.getHoodieView();
Map<String, Stream<FileSlice>> ptFsMap =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.apache.amoro.TableFormat;
import org.apache.amoro.api.CommitMetaProducer;
import org.apache.amoro.process.ProcessStatus;
import org.apache.amoro.shade.guava32.com.google.common.collect.ImmutableList;
import org.apache.amoro.shade.guava32.com.google.common.collect.Lists;
import org.apache.amoro.shade.guava32.com.google.common.collect.Streams;
import org.apache.amoro.table.TableIdentifier;
Expand Down Expand Up @@ -59,7 +58,9 @@
import org.apache.paimon.manifest.ManifestList;
import org.apache.paimon.table.DataTable;
import org.apache.paimon.table.FileStoreTable;
import org.apache.paimon.utils.BranchManager;
import org.apache.paimon.utils.FileStorePathFactory;
import org.apache.paimon.utils.SnapshotManager;
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
Expand Down Expand Up @@ -179,9 +180,10 @@ public List<AmoroSnapshotsOfTable> getSnapshots(
FileStoreTable table = getTable(amoroTable);
List<AmoroSnapshotsOfTable> snapshotsOfTables = new ArrayList<>();
Iterator<Snapshot> snapshots;
if (PAIMON_MAIN_BRANCH_NAME.equals(ref)) {
if (table.branchManager().branchExists(ref) || BranchManager.isMainBranch(ref)) {
SnapshotManager snapshotManager = table.snapshotManager().copyWithBranch(ref);
try {
snapshots = table.snapshotManager().snapshots();
snapshots = snapshotManager.snapshots();
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -221,11 +223,17 @@ public List<AmoroSnapshotsOfTable> getSnapshots(

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

FileStore<?> store = table.store();
FileStorePathFactory fileStorePathFactory = store.pathFactory();
ManifestList manifestList = store.manifestListFactory().create();
Expand Down Expand Up @@ -517,7 +525,14 @@ public List<TagOrBranchInfo> getTableTags(AmoroTable<?> amoroTable) {

@Override
public List<TagOrBranchInfo> getTableBranches(AmoroTable<?> amoroTable) {
return ImmutableList.of(TagOrBranchInfo.MAIN_BRANCH);
FileStoreTable table = getTable(amoroTable);
List<String> branches = table.branchManager().branches();
List<TagOrBranchInfo> branchInfos =
branches.stream()
.map(name -> new TagOrBranchInfo(name, -1, -1, 0L, 0L, TagOrBranchInfo.BRANCH))
.collect(Collectors.toList());
branchInfos.add(TagOrBranchInfo.MAIN_BRANCH);
return branchInfos;
}

@Override
Expand Down
5 changes: 3 additions & 2 deletions amoro-web/src/services/table.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,15 @@ export function getDetailBySnapshotId(
catalog: string
db: string
table: string
ref: string
snapshotId: string
page: number
pageSize: number
token?: string
},
) {
const { catalog, db, table, snapshotId, page, pageSize, token } = params
return request.get(`ams/v1/tables/catalogs/${catalog}/dbs/${db}/tables/${table}/snapshots/${snapshotId}/detail`, { params: { page, pageSize, token } })
const { catalog, db, table, snapshotId, page, pageSize, ref, token } = params
return request.get(`ams/v1/tables/catalogs/${catalog}/dbs/${db}/tables/${table}/snapshots/${snapshotId}/detail`, { params: { page, pageSize, ref, token } })
}
// get operations
export function getOperations(
Expand Down
1 change: 1 addition & 0 deletions amoro-web/src/views/tables/components/Snapshots.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ async function getBreadcrumbTable() {
const params = {
...sourceData,
snapshotId: snapshotId.value,
ref: tblRef.value,
page: breadcrumbPagination.current,
pageSize: breadcrumbPagination.pageSize,
}
Expand Down
Loading