mchades commented on code in PR #7850: URL: https://github.com/apache/gravitino/pull/7850#discussion_r2268450306
########## core/src/main/java/org/apache/gravitino/stats/storage/PartitionStatisticStorageFactory.java: ########## @@ -0,0 +1,36 @@ +/* + * 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.gravitino.stats.storage; + +import java.util.Map; + +/** + * Factory interface for creating instances of {@link + * org.apache.gravitino.stats.storage.PartitionStatisticStorage}. + */ +public interface PartitionStatisticStorageFactory { + + /** + * Creates an instance of {@link org.apache.gravitino.stats.storage.PartitionStatisticStorage}. + * + * @param properties additional properties for the storage configuration + * @return an instance of {@link org.apache.gravitino.stats.storage.PartitionStatisticStorage} + */ + PartitionStatisticStorage open(Map<String, String> properties); Review Comment: In factory class, `create` is usually used as the method name ########## core/src/main/java/org/apache/gravitino/stats/storage/PartitionStatisticStorage.java: ########## @@ -0,0 +1,112 @@ +/* + * 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.gravitino.stats.storage; + +import com.google.common.collect.Lists; +import java.io.Closeable; +import java.util.List; +import java.util.stream.Collectors; +import org.apache.gravitino.MetadataObject; +import org.apache.gravitino.stats.PartitionRange; +import org.apache.gravitino.stats.PartitionStatisticsDrop; + +/** Interface for managing partition statistics in a storage system. */ +public interface PartitionStatisticStorage extends Closeable { + + /** + * Lists statistics for a given metadata object within a specified range of partition names. The + * implementation should guarantee the thread safe. + * + * @param metalake the name of the metalake + * @param metadataObject the metadata object for which statistics are being listed + * @param partitionRange the range of partition names for which statistics are being listed + * @return a list of {@link PersistedPartitionStatistics} objects, each containing the partition + * name + */ + List<PersistedPartitionStatistics> listStatistics( + String metalake, MetadataObject metadataObject, PartitionRange partitionRange); Review Comment: Should we use `Entity` instead of `MetadataObject`, as discussed in https://github.com/apache/gravitino/pull/7690#discussion_r2262665448? ########## core/src/main/java/org/apache/gravitino/stats/storage/PartitionStatisticStorage.java: ########## @@ -0,0 +1,112 @@ +/* + * 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.gravitino.stats.storage; + +import com.google.common.collect.Lists; +import java.io.Closeable; +import java.util.List; +import java.util.stream.Collectors; +import org.apache.gravitino.MetadataObject; +import org.apache.gravitino.stats.PartitionRange; +import org.apache.gravitino.stats.PartitionStatisticsDrop; + +/** Interface for managing partition statistics in a storage system. */ +public interface PartitionStatisticStorage extends Closeable { + + /** + * Lists statistics for a given metadata object within a specified range of partition names. The + * implementation should guarantee the thread safe. + * + * @param metalake the name of the metalake + * @param metadataObject the metadata object for which statistics are being listed + * @param partitionRange the range of partition names for which statistics are being listed + * @return a list of {@link PersistedPartitionStatistics} objects, each containing the partition + * name + */ + List<PersistedPartitionStatistics> listStatistics( + String metalake, MetadataObject metadataObject, PartitionRange partitionRange); + + /** + * Lists statistics for a given metadata object and specific partition names. This interface may + * be used in the future. The upper logic layer won't call this method now. The implementation + * should guarantee the thread safe. + * + * @param metalake the name of the metalake + * @param metadataObject the metadata object for which statistics are being listed + * @param partitionNames a list of partition names for which statistics are being listed + * @return a list of {@link PersistedPartitionStatistics} objects, each containing the partition + * name + */ + default List<PersistedPartitionStatistics> listStatistics( + String metalake, MetadataObject metadataObject, List<String> partitionNames) { + throw new UnsupportedOperationException( + "Don't support listStatistics with partition names yet."); + } + + /** + * Appends statistics to the storage for a given metadata object. The implementation should + * guarantee the thread safe. + * + * @param metalake the name of the metalake + * @param statisticsToAppend a list of {@link MetadataObjectStatisticsUpdate} objects, each + * containing the metadata object and its associated statistics updates. + */ + void appendStatistics(String metalake, List<MetadataObjectStatisticsUpdate> statisticsToAppend); Review Comment: What's the difference from `updateStatistics`? -- 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]
