Skip to content

Commit

Permalink
[AMORO-3029] Fix table record calculating with empty table (#3030)
Browse files Browse the repository at this point in the history
Fix table record calculating with empty table
  • Loading branch information
zhoujinsong authored Jul 12, 2024
1 parent f68a140 commit 9b3318d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ public void handleException(Exception e, Context ctx) {
"/ams/v1/versionInfo",
"/ams/v1/login",
"/ams/v1/health/status",
"/ams/v1/login/current",
"/",
"/overview",
"/introduce",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,23 +176,29 @@ private String decorateTableFormat(AmoroTable table) {
}

private long getRecordsOfTable(MixedTable mixedTable) {
long totalRecords;
long totalRecords = 0L;
if (mixedTable.isKeyedTable()) {
Snapshot changeSnapshot =
SnapshotUtil.latestSnapshot(mixedTable.asKeyedTable().changeTable(), null);
Snapshot baseSnapshot =
SnapshotUtil.latestSnapshot(mixedTable.asKeyedTable().baseTable(), null);
totalRecords =
PropertyUtil.propertyAsLong(
changeSnapshot.summary(), SnapshotSummary.TOTAL_RECORDS_PROP, 0L)
+ PropertyUtil.propertyAsLong(
baseSnapshot.summary(), SnapshotSummary.TOTAL_RECORDS_PROP, 0L);
if (changeSnapshot != null) {
totalRecords +=
PropertyUtil.propertyAsLong(
changeSnapshot.summary(), SnapshotSummary.TOTAL_RECORDS_PROP, 0L);
}
if (baseSnapshot != null) {
totalRecords +=
PropertyUtil.propertyAsLong(
baseSnapshot.summary(), SnapshotSummary.TOTAL_RECORDS_PROP, 0L);
}
} else {
totalRecords =
PropertyUtil.propertyAsLong(
SnapshotUtil.latestSnapshot(mixedTable.asUnkeyedTable(), null).summary(),
SnapshotSummary.TOTAL_RECORDS_PROP,
0L);
Snapshot latestSnapshot = SnapshotUtil.latestSnapshot(mixedTable.asUnkeyedTable(), null);
if (latestSnapshot != null) {
totalRecords =
PropertyUtil.propertyAsLong(
latestSnapshot.summary(), SnapshotSummary.TOTAL_RECORDS_PROP, 0L);
}
}
return totalRecords;
}
Expand Down

0 comments on commit 9b3318d

Please sign in to comment.