lnbest0707-uber commented on code in PR #14686: URL: https://github.com/apache/pinot/pull/14686#discussion_r1980055105
########## pinot-server/src/main/java/org/apache/pinot/server/predownload/PredownloadTableInfo.java: ########## @@ -0,0 +1,109 @@ +/** + * 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.pinot.server.predownload; + +import java.io.File; +import javax.annotation.Nullable; +import org.apache.pinot.segment.local.segment.index.loader.IndexLoadingConfig; +import org.apache.pinot.segment.spi.store.SegmentDirectory; +import org.apache.pinot.spi.config.instance.InstanceDataManagerConfig; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.data.Schema; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class PredownloadTableInfo { + private static final Logger LOGGER = LoggerFactory.getLogger(PredownloadTableInfo.class); + private final String _tableNameWithType; + private final InstanceDataManagerConfig _instanceDataManagerConfig; + private final TableConfig _tableConfig; + @Nullable + private final Schema _schema; + + public PredownloadTableInfo(String tableNameWithType, TableConfig tableConfig, @Nullable Schema schema, + InstanceDataManagerConfig instanceDataManagerConfig) { + _tableNameWithType = tableNameWithType; + _tableConfig = tableConfig; + _schema = schema; + _instanceDataManagerConfig = instanceDataManagerConfig; + } + + private static void closeSegmentDirectoryQuietly(@Nullable SegmentDirectory segmentDirectory) { + if (segmentDirectory != null) { + try { + segmentDirectory.close(); + } catch (Exception e) { + LOGGER.warn("Failed to close SegmentDirectory due to error: {}", e.getMessage()); + } + } + } + + public TableConfig getTableConfig() { + return _tableConfig; + } + + public InstanceDataManagerConfig getInstanceDataManagerConfig() { + return _instanceDataManagerConfig; + } + + /** + * After loading segment metadata from ZK, try to load from local and check if we are able to skip + * the downloading + * + * @param predownloadSegmentInfo SegmentInfo of segment to be loaded + * @param instanceDataManagerConfig InstanceDataManagerConfig loaded from scheduler + * @return true if already presents, false if needs to be downloaded + */ + public boolean loadSegmentFromLocal(PredownloadSegmentInfo predownloadSegmentInfo, + InstanceDataManagerConfig instanceDataManagerConfig) { Review Comment: Good catch, removed. -- 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...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org