761417898 commented on code in PR #192:
URL: https://github.com/apache/tsfile/pull/192#discussion_r1712904278


##########
cpp/src/common/tsfile_common.cc:
##########
@@ -48,6 +50,56 @@ int TimeseriesIndex::add_chunk_meta(ChunkMeta *chunk_meta,
 
 /* ================ TSMIterator ================ */
 int TSMIterator::init() {
+    // sort chunk_group_meta_list_ : {[measurementA, offsetA1], [measurementB,
+    // offsetB1], [measurementA, offsetA2], [measurementB, offsetB2]} ->
+    // {[measurementA, offsetA1], [measurementA, offsetA2], [measurementB,
+    // offsetB1], [measurementB, offsetB2]}
+    for (auto chunk_group_meta_iter = chunk_group_meta_list_.begin();
+         chunk_group_meta_iter != chunk_group_meta_list_.end();
+         chunk_group_meta_iter++) {
+        auto chunk_meta_list = chunk_group_meta_iter.get()->chunk_meta_list_;
+        std::vector<ChunkMeta *> vec;
+        for (auto it = chunk_meta_list.begin(); it != chunk_meta_list.end();
+             it++) {
+            vec.push_back(it.get());
+        }
+
+        std::vector<std::vector<ChunkMeta *>> groups;
+        for (auto *chunk_meta : vec) {
+            bool added_to_group = false;
+            for (auto &group : groups) {
+                if (group[0]->measurement_name_.equal_to(
+                        chunk_meta->measurement_name_)) {
+                    group.push_back(chunk_meta);
+                    added_to_group = true;
+                    break;
+                }
+            }
+            if (!added_to_group) {
+                groups.push_back({chunk_meta});
+            }
+        }

Review Comment:
   Okay, change it to `map<std::string, std::vector<ChunkMeta *>>`.



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