jt2594838 commented on code in PR #635:
URL: https://github.com/apache/tsfile/pull/635#discussion_r2538090951
##########
cpp/src/reader/device_meta_iterator.cc:
##########
@@ -74,9 +76,18 @@ int DeviceMetaIterator::load_leaf_device(MetaIndexNode*
meta_index_node) {
const auto& leaf_children = meta_index_node->children_;
for (size_t i = 0; i < leaf_children.size(); i++) {
std::shared_ptr<IMetaIndexEntry> child = leaf_children[i];
- // const auto& device_id = child->name_;
- if (id_filter_ != nullptr /*TODO: !id_filter_->satisfy(device_id)*/) {
- continue;
+ if (id_filter_ != nullptr) {
+ auto deviceid = child->get_device_id();
+ auto device_id_seg_ptr = deviceid->get_segments();
+ std::vector<std::string> device_id_seg;
+ std::transform(device_id_seg_ptr.begin(), device_id_seg_ptr.end(),
+ std::back_inserter(device_id_seg),
+ [](const std::string* ptr) -> std::string {
+ return ptr ? *ptr : std::string{};
+ });
+ if (!id_filter_->satisfyRow(0, device_id_seg)) {
+ continue;
+ }
Review Comment:
How about using std::vector\<std::string*\> to avoid copying?
##########
cpp/src/reader/filter/tag_filter.cc:
##########
@@ -0,0 +1,284 @@
+/*
+ * 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.
+ */
+
+#include "tag_filter.h"
+
+#include <algorithm>
+#include <utility>
+
+namespace storage {
+
+// TagFilter base class implementation
+TagFilter::TagFilter(int col_idx, std::string tag_value)
+ : col_idx_(col_idx), value_(std::move(tag_value)), value2_("") {}
+
+TagFilter::~TagFilter() = default;
+
+bool TagFilter::satisfyRow(int time, std::vector<std::string> segments) const {
+ if (time != 0) return false;
Review Comment:
Why add this?
##########
cpp/src/reader/filter/tag_filter.cc:
##########
@@ -0,0 +1,284 @@
+/*
+ * 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.
+ */
+
+#include "tag_filter.h"
+
+#include <algorithm>
+#include <utility>
+
+namespace storage {
+
+// TagFilter base class implementation
+TagFilter::TagFilter(int col_idx, std::string tag_value)
+ : col_idx_(col_idx), value_(std::move(tag_value)), value2_("") {}
+
+TagFilter::~TagFilter() = default;
+
+bool TagFilter::satisfyRow(int time, std::vector<std::string> segments) const {
+ if (time != 0) return false;
+ return satisfyRow(segments);
+}
+
+bool TagFilter::satisfyRow(std::vector<std::string> segments) const {
+ ASSERT(false);
+ return false;
+}
+
+// TagEq implementation
+TagEq::TagEq(int col_idx, std::string tag_value)
+ : TagFilter(col_idx, std::move(tag_value)) {}
+
+bool TagEq::satisfyRow(std::vector<std::string> segments) const {
+ if (col_idx_ >= segments.size()) return false;
+ return segments[col_idx_] == value_;
+}
+
+// TagNeq implementation
+TagNeq::TagNeq(int col_idx, std::string tag_value)
+ : TagFilter(col_idx, std::move(tag_value)) {}
+
+bool TagNeq::satisfyRow(std::vector<std::string> segments) const {
+ if (col_idx_ >= segments.size()) return false;
+ return segments[col_idx_] != value_;
+}
+
+// TagLt implementation
+TagLt::TagLt(int col_idx, std::string tag_value)
+ : TagFilter(col_idx, std::move(tag_value)) {}
+
+bool TagLt::satisfyRow(std::vector<std::string> segments) const {
+ if (col_idx_ >= segments.size()) return false;
+ return segments[col_idx_] < value_;
+}
+
+// TagLteq implementation
+TagLteq::TagLteq(int col_idx, std::string tag_value)
+ : TagFilter(col_idx, std::move(tag_value)) {}
+
+bool TagLteq::satisfyRow(std::vector<std::string> segments) const {
+ if (col_idx_ >= segments.size()) return false;
+ return segments[col_idx_] <= value_;
+}
+
+// TagGt implementation
+TagGt::TagGt(int col_idx, std::string tag_value)
+ : TagFilter(col_idx, std::move(tag_value)) {}
+
+bool TagGt::satisfyRow(std::vector<std::string> segments) const {
+ if (col_idx_ >= segments.size()) return false;
+ return segments[col_idx_] > value_;
+}
+
+// TagGteq implementation
+TagGteq::TagGteq(int col_idx, std::string tag_value)
+ : TagFilter(col_idx, std::move(tag_value)) {}
+
+bool TagGteq::satisfyRow(std::vector<std::string> segments) const {
+ if (col_idx_ >= segments.size()) return false;
+ return segments[col_idx_] >= value_;
+}
+
+// TagRegExp implementation
+TagRegExp::TagRegExp(int col_idx, std::string tag_value)
+ : TagFilter(col_idx, std::move(tag_value)) {}
+
+bool TagRegExp::satisfyRow(std::vector<std::string> segments) const {
+ if (col_idx_ >= segments.size()) return false;
+ try {
+ std::regex pattern(value_);
+ return std::regex_search(segments[col_idx_], pattern);
Review Comment:
Better to init the pattern during object construction.
--
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]