Skip to content

Commit

Permalink
[chore](table) Add batch method to get visible version of the olap ta…
Browse files Browse the repository at this point in the history
…ble (#38949) (#39495)

Cherry-pick #38949
  • Loading branch information
w41ter authored Aug 17, 2024
1 parent b0da843 commit fd4d1f4
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.apache.doris.common.io.Text;
import org.apache.doris.common.util.PropertyAnalyzer;
import org.apache.doris.common.util.Util;
import org.apache.doris.datasource.InternalCatalog;
import org.apache.doris.mtmv.MTMVRelatedTableIf;
import org.apache.doris.mtmv.MTMVSnapshotIf;
import org.apache.doris.mtmv.MTMVVersionSnapshot;
Expand Down Expand Up @@ -2156,7 +2157,6 @@ public int getBaseSchemaVersion() {
return baseIndexMeta.getSchemaVersion();
}


public void setEnableSingleReplicaCompaction(boolean enableSingleReplicaCompaction) {
if (tableProperty == null) {
tableProperty = new TableProperty(new HashMap<>());
Expand Down Expand Up @@ -2773,6 +2773,37 @@ public long getVisibleVersion() {
return tableAttributes.getVisibleVersion();
}

// Get the table versions in batch.
public static List<Long> getVisibleVersionByTableIds(Collection<Long> tableIds) {
List<OlapTable> tables = new ArrayList<>();

InternalCatalog catalog = Env.getCurrentEnv().getInternalCatalog();
for (long tableId : tableIds) {
Table table = catalog.getTableByTableId(tableId);
if (table == null) {
throw new RuntimeException("get table visible version failed, no such table " + tableId + " exists");
}
if (table.getType() != TableType.OLAP) {
throw new RuntimeException(
"get table visible version failed, table " + tableId + " is not a OLAP table");
}
tables.add((OlapTable) table);
}

return getVisibleVersionInBatch(tables);
}

// Get the table versions in batch.
public static List<Long> getVisibleVersionInBatch(Collection<OlapTable> tables) {
if (tables.isEmpty()) {
return new ArrayList<>();
}

return tables.stream()
.map(table -> table.tableAttributes.getVisibleVersion())
.collect(Collectors.toList());
}

public long getVisibleVersionTime() {
return tableAttributes.getVisibleVersionTime();
}
Expand Down

0 comments on commit fd4d1f4

Please sign in to comment.