You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2023/01/04 16:47:47 UTC

[GitHub] [doris] github-actions[bot] commented on a diff in pull request #15633: [enhancement](compaction) Optimize calculating level size of input rowset in SizeBasedCumulativeCompactionPolicy

github-actions[bot] commented on code in PR #15633:
URL: https://github.com/apache/doris/pull/15633#discussion_r1061684457


##########
be/src/olap/cumulative_compaction_policy.cpp:
##########
@@ -335,13 +327,12 @@
     return transient_size;
 }
 
-int SizeBasedCumulativeCompactionPolicy::_level_size(const int64_t size) {
-    for (auto& i : _levels) {
-        if (size >= i) {
-            return i;
-        }
-    }
-    return 0;
+int64_t SizeBasedCumulativeCompactionPolicy::_level_size(const int64_t size) {
+    if (size < 1024) return 0;
+    int64_t max_level = (int64_t)1
+                        << (sizeof(_promotion_size) * 8 - 1 - __builtin_clzl(_promotion_size / 2));
+    if (size >= max_level) return max_level;

Review Comment:
   warning: statement should be inside braces [readability-braces-around-statements]
   
   ```suggestion
       if (size >= max_level) { return max_level;
   }
   ```
   



##########
be/src/olap/cumulative_compaction_policy.cpp:
##########
@@ -335,13 +327,12 @@ int SizeBasedCumulativeCompactionPolicy::pick_input_rowsets(
     return transient_size;
 }
 
-int SizeBasedCumulativeCompactionPolicy::_level_size(const int64_t size) {
-    for (auto& i : _levels) {
-        if (size >= i) {
-            return i;
-        }
-    }
-    return 0;
+int64_t SizeBasedCumulativeCompactionPolicy::_level_size(const int64_t size) {
+    if (size < 1024) return 0;

Review Comment:
   warning: statement should be inside braces [readability-braces-around-statements]
   
   ```suggestion
       if (size < 1024) { return 0;
   }
   ```
   



-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org