AMashenkov commented on code in PR #6649:
URL: https://github.com/apache/ignite-3/pull/6649#discussion_r2391435679
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/statistic/SqlStatisticManagerImpl.java:
##########
@@ -88,44 +102,53 @@ public SqlStatisticManagerImpl(TableManager tableManager,
CatalogService catalog
*/
@Override
public long tableSize(int tableId) {
- updateTableSizeStatistics(tableId, false);
-
- return tableSizeMap.getOrDefault(tableId, DEFAULT_VALUE).getSize();
+ return tableSizeMap.computeIfAbsent(tableId, k ->
DEFAULT_VALUE).getSize();
}
- /** Update table size statistic in the background if it required. */
- private void updateTableSizeStatistics(int tableId, boolean force) {
- TableViewInternal tableView = tableManager.cachedTable(tableId);
- if (tableView == null) {
- LOG.debug("There is no table to update statistics [id={}].",
tableId);
- return;
- }
+ @Override
+ public void start() {
+ catalogService.listen(CatalogEvent.TABLE_CREATE,
createTableEventListener);
+ catalogService.listen(CatalogEvent.TABLE_DROP, dropTableEventListener);
+ lowWatermark.listen(LowWatermarkEvent.LOW_WATERMARK_CHANGED,
lwmListener);
- ActualSize tableSize = tableSizeMap.get(tableId);
- if (tableSize == null) {
- // has been concurrently cleaned up, no need more update statistic
for the table.
- return;
+ // Need to have all known tables for all available history of catalog.
+ int earliestVersion = catalogService.earliestCatalogVersion();
+ int latestVersion = catalogService.latestCatalogVersion();
+ for (int version = earliestVersion; version <= latestVersion;
version++) {
+ Collection<CatalogTableDescriptor> tables =
catalogService.catalog(version).tables();
+ for (CatalogTableDescriptor table : tables) {
+ tableSizeMap.putIfAbsent(table.id(), DEFAULT_VALUE);
+ }
Review Comment:
Should we add `DestoryTableEvent` to queue and add `table.id()` to
`droppedTables` for those ones, which descriptor were not found in the catalog
of the latest version?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]