Lchangliang commented on code in PR #23561:
URL: https://github.com/apache/doris/pull/23561#discussion_r1314260194


##########
be/src/olap/segment_loader.cpp:
##########
@@ -68,28 +64,34 @@ Status SegmentLoader::load_segments(const 
BetaRowsetSharedPtr& rowset,
     if (cache_handle->is_inited()) {
         return Status::OK();
     }
-
-    SegmentCache::CacheKey cache_key(rowset->rowset_id());
-    if (_segment_cache->lookup(cache_key, cache_handle)) {
-        return Status::OK();
-    }
-
-    std::vector<segment_v2::SegmentSharedPtr> segments;
-    RETURN_IF_ERROR(rowset->load_segments(&segments));
-
-    if (use_cache) {
-        // memory of SegmentCache::CacheValue will be handled by SegmentCache
-        SegmentCache::CacheValue* cache_value = new SegmentCache::CacheValue();
-        cache_value->segments = std::move(segments);
-        _segment_cache->insert(cache_key, *cache_value, cache_handle);
-    } else {
-        cache_handle->init(std::move(segments));
+    for (int64_t i = 0; i < rowset->num_segments(); i++) {
+        SegmentCache::CacheKey cache_key(rowset->rowset_id(), i);
+        if (_segment_cache->lookup(cache_key, cache_handle)) {
+            continue;
+        }
+        segment_v2::SegmentSharedPtr segment;
+        RETURN_IF_ERROR(rowset->load_segment(i, &segment));
+        if (use_cache) {
+            // memory of SegmentCache::CacheValue will be handled by 
SegmentCache
+            SegmentCache::CacheValue* cache_value = new 
SegmentCache::CacheValue();
+            cache_value->segment = std::move(segment);
+            _segment_cache->insert(cache_key, *cache_value, cache_handle);

Review Comment:
   The segment is pushed in the method SegmentCache::insert.



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

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


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

Reply via email to