jerqi commented on code in PR #7850:
URL: https://github.com/apache/gravitino/pull/7850#discussion_r2269761106


##########
core/src/main/java/org/apache/gravitino/stats/storage/MemoryPartitionStatsStorageFactory.java:
##########
@@ -0,0 +1,226 @@
+/*
+ * 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 com.google.common.collect.Maps;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import org.apache.gravitino.MetadataObject;
+import org.apache.gravitino.stats.PartitionRange;
+import org.apache.gravitino.stats.PartitionStatisticsDrop;
+import org.apache.gravitino.stats.PartitionStatisticsUpdate;
+import org.apache.gravitino.stats.StatisticValue;
+
+public class MemoryPartitionStatsStorageFactory implements 
PartitionStatisticStorageFactory {
+
+  @Override
+  public PartitionStatisticStorage create(Map<String, String> properties) {
+    return new MemoryPartitionStatsStorage();
+  }
+
+  public static class MemoryPartitionStatsStorage implements 
PartitionStatisticStorage {
+    private static final Map<MetadataContainerKey, 
MetadataObjectStatisticsContainer>
+        totalStatistics = Maps.newConcurrentMap();
+
+    private MemoryPartitionStatsStorage() {}
+
+    @Override
+    public List<PersistedPartitionStatistics> listStatistics(
+        String metalake, MetadataObject metadataObject, PartitionRange range) {
+      MetadataObjectStatisticsContainer tableStats =
+          totalStatistics.get(new MetadataContainerKey(metalake, 
metadataObject));
+
+      if (tableStats == null) {
+        return Lists.newArrayList();
+      }
+
+      Map<String, Map<String, StatisticValue<?>>> resultStats = 
Maps.newHashMap();
+      for (PersistedPartitionStatistics partitionStat : 
tableStats.partitionStatistics().values()) {

Review Comment:
     /**
      * Updates statistics for a given metadata object. Locking guarantee: The 
upper layer will acquire
      * a write lock at the metadata object level. For example, if the metadata 
object is a table, the
      * write lock of the table level will be held.
      *
      * @param metalake the name of the metalake
      * @param statisticsToUpdate a list of {@link 
MetadataObjectStatisticsUpdate} objects, each
      *     containing the metadata object and its associated statistics 
updates.
      */
   We will acquire the write lock. So we don't accquire lock here.



-- 
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]

Reply via email to