ivanzlenko commented on code in PR #7687:
URL: https://github.com/apache/ignite-3/pull/7687#discussion_r2870523869


##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/PersistentPageMemoryDataRegion.java:
##########
@@ -481,47 +500,76 @@ void addTableMetrics(StorageTableDescriptor 
tableDescriptor, StorageEngineTables
 
         metricSource.addMetric(new LongGauge(
                 "TotalAllocatedSize",
-                "Total size of all pages allocated by '" + ENGINE_NAME + "' 
storage engine for a given table, in bytes.",
-                () -> {
-                    long totalPages = tableStorage.mvPartitionStorages.stream()
-                            
.mapToLong(PersistentPageMemoryMvPartitionStorage::pageCount)
-                            .sum();
-
-                    return pageSize * totalPages;
-                }
+                String.format("Total size of all pages allocated by \"%s\" 
storage engine for a given table, in bytes.", ENGINE_NAME),
+                () -> tableAllocatedPagesCount(tableStorage) * pageSize
         ));
     }
 
-    private long totalAllocatedPagesSizeOnDiskInBytes() {
-        long pageCount = 0;
+    private long totalAllocatedPagesCount() {
+        return tableStorages.values().stream()
+                
.mapToLong(PersistentPageMemoryDataRegion::tableAllocatedPagesCount)
+                .sum();
+    }
 
-        for (PersistentPageMemoryTableStorage tableStorage : 
tableStorages.values()) {
-            for (PersistentPageMemoryMvPartitionStorage partitionStorage : 
tableStorage.mvPartitionStorages.getAll()) {
-                pageCount += 
allocatedPageCountOnDisk(tableStorage.getTableId(), 
partitionStorage.partitionId());
-            }
-        }
+    private static long 
tableAllocatedPagesCount(PersistentPageMemoryTableStorage tableStorage) {
+        return tableStorage.mvPartitionStorages.getAll().stream()
+                .mapToLong(PersistentPageMemoryMvPartitionStorage::pageCount)
+                .sum();
+    }
 
-        return pageCount * pageSize;
+    private long totalNonEmptyAllocatedPagesCount() {
+        return allPartitions()
+                .mapToLong(partitionStorage -> partitionStorage.pageCount() - 
partitionStorage.emptyDataPageCountInFreeList())
+                .sum();
     }
 
-    private long totalNonEmptyAllocatedPagesSizeOnDiskInBytes() {
-        long pageCount = 0;
+    private long emptyPagesCount() {
+        return allPartitions()
+                
.mapToLong(PersistentPageMemoryMvPartitionStorage::emptyDataPageCountInFreeList)
+                .sum();
+    }
 
-        for (PersistentPageMemoryTableStorage tableStorage : 
tableStorages.values()) {
-            for (PersistentPageMemoryMvPartitionStorage partitionStorage : 
tableStorage.mvPartitionStorages.getAll()) {
-                pageCount += 
allocatedPageCountOnDisk(tableStorage.getTableId(), 
partitionStorage.partitionId());
+    private long nonEmptySpaceBytes() {
+        return allPartitions()
+                .mapToLong(partitionStorage -> {
+                    int pagesCount = partitionStorage.pageCount();

Review Comment:
   Can we move this lambda to a separate method? 
   



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/PersistentPageMemoryDataRegion.java:
##########
@@ -481,47 +500,76 @@ void addTableMetrics(StorageTableDescriptor 
tableDescriptor, StorageEngineTables
 
         metricSource.addMetric(new LongGauge(
                 "TotalAllocatedSize",
-                "Total size of all pages allocated by '" + ENGINE_NAME + "' 
storage engine for a given table, in bytes.",
-                () -> {
-                    long totalPages = tableStorage.mvPartitionStorages.stream()
-                            
.mapToLong(PersistentPageMemoryMvPartitionStorage::pageCount)
-                            .sum();
-
-                    return pageSize * totalPages;
-                }
+                String.format("Total size of all pages allocated by \"%s\" 
storage engine for a given table, in bytes.", ENGINE_NAME),

Review Comment:
   Why only this metric for a table? Will it make sense to include other 3? 



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