qidaye commented on code in PR #25256: URL: https://github.com/apache/doris/pull/25256#discussion_r1354147234
########## fe/fe-core/src/main/java/org/apache/doris/planner/SingleTabletLoadRecorderMgr.java: ########## @@ -0,0 +1,119 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.planner; + +import org.apache.doris.catalog.Env; +import org.apache.doris.catalog.MaterializedIndex; +import org.apache.doris.catalog.OlapTable; +import org.apache.doris.catalog.TableIf; +import org.apache.doris.common.UserException; +import org.apache.doris.common.util.MasterDaemon; + +import lombok.Getter; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.concurrent.ConcurrentHashMap; + +public class SingleTabletLoadRecorderMgr extends MasterDaemon { + private static final Logger LOG = LogManager.getLogger(SingleTabletLoadRecorderMgr.class); + private static final long EXPIRY_TIME_INTERVAL_MS = 604800000; // 7 * 24 * 60 * 60 * 1000, 7 days + + // <db_id -> <table_id -> <partition_id -> load_tablet_record>>> + // 0 =< load_tablet_index < number_buckets + private final ConcurrentHashMap<Long, ConcurrentHashMap<Long, ConcurrentHashMap<Long, TabletUpdateRecord>>> + loadTabletRecordMap = new ConcurrentHashMap<>(); + + public SingleTabletLoadRecorderMgr() { + super("single_tablet_load_recorder", EXPIRY_TIME_INTERVAL_MS); + } + + @Override + protected void runAfterCatalogReady() { + long expiryTime = System.currentTimeMillis() - EXPIRY_TIME_INTERVAL_MS; + loadTabletRecordMap.forEach((dbId, dbTableMap) -> { + dbTableMap.forEach((tableId, partitionMap) -> { + partitionMap.entrySet().removeIf(entry -> entry.getValue().getUpdateTimestamp() < expiryTime); + if (partitionMap.isEmpty()) { + dbTableMap.remove(tableId); + } + }); + if (dbTableMap.isEmpty()) { + loadTabletRecordMap.remove(dbId); + } + }); + LOG.info("Remove expired load tablet record successfully."); + } + + public int getCurrentLoadTabletIndex(long dbId, long tableId, long partitionId) throws UserException { + TabletUpdateRecord record = loadTabletRecordMap.computeIfAbsent(dbId, k -> new ConcurrentHashMap<>()) + .computeIfAbsent(tableId, k -> new ConcurrentHashMap<>()) + .get(partitionId); + int numBuckets = -1; + if (record == null) { + numBuckets = getNumBuckets(dbId, tableId, partitionId); + } + return createOrUpdateLoadTabletRecord(dbId, tableId, partitionId, numBuckets); + } + + private int getNumBuckets(long dbId, long tableId, long partitionId) throws UserException { + OlapTable olapTable = (OlapTable) Env.getCurrentInternalCatalog().getDb(dbId) Review Comment: No such method. -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org