You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by "PragmaTwice (via GitHub)" <gi...@apache.org> on 2024/04/14 05:59:11 UTC
[PR] Add plan lowering pass for KQIR [kvrocks]
PragmaTwice opened a new pull request, #2247:
URL: https://github.com/apache/kvrocks/pull/2247
In this PR, we added a pass to lower original IR to planner IR.
There's no optimization and index selection in this pass, and these pass will be seperated to another following pass.
--
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: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add plan lowering pass for KQIR [kvrocks]
Posted by "PragmaTwice (via GitHub)" <gi...@apache.org>.
PragmaTwice commented on code in PR #2247:
URL: https://github.com/apache/kvrocks/pull/2247#discussion_r1564500914
##########
src/search/passes/lower_to_plan.h:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ *
+ */
+
+#pragma once
+
+#include <memory>
+
+#include "search/ir.h"
+#include "search/ir_pass.h"
+#include "search/ir_plan.h"
+
+namespace kqir {
+
+struct LowerToPlan : Visitor {
+ std::unique_ptr<Node> Visit(std::unique_ptr<SearchExpr> node) override {
+ auto scan = std::make_unique<FullIndexScan>(node->index->CloneAs<IndexRef>());
+ auto filter = std::make_unique<Filter>(std::move(scan), std::move(node->query_expr));
+
+ std::unique_ptr<PlanOperator> op = std::move(filter);
+
+ // order is important here, since limit(sort(op)) is different from sort(limit(op))
+ if (node->sort_by) {
+ op = std::make_unique<Sort>(std::move(op), std::move(node->sort_by));
Review Comment:
lowering is a term in compiler.
https://news.ycombinator.com/item?id=26928724
--
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: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add plan lowering pass for KQIR [kvrocks]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #2247:
URL: https://github.com/apache/kvrocks/pull/2247#issuecomment-2053940545
## [](https://sonarcloud.io/dashboard?id=apache_kvrocks&pullRequest=2247) **Quality Gate passed**
Issues
 [15 New issues](https://sonarcloud.io/project/issues?id=apache_kvrocks&pullRequest=2247&resolved=false&inNewCodePeriod=true)
 [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2247&metric=new_accepted_issues&view=list)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_kvrocks&pullRequest=2247&resolved=false&inNewCodePeriod=true)
 [60.3% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2247&metric=new_coverage&view=list)
 [2.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2247&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_kvrocks&pullRequest=2247)
--
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: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add plan lowering pass for KQIR [kvrocks]
Posted by "PragmaTwice (via GitHub)" <gi...@apache.org>.
PragmaTwice commented on code in PR #2247:
URL: https://github.com/apache/kvrocks/pull/2247#discussion_r1564504682
##########
src/search/passes/lower_to_plan.h:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ *
+ */
+
+#pragma once
+
+#include <memory>
+
+#include "search/ir.h"
+#include "search/ir_pass.h"
+#include "search/ir_plan.h"
+
+namespace kqir {
+
+struct LowerToPlan : Visitor {
+ std::unique_ptr<Node> Visit(std::unique_ptr<SearchExpr> node) override {
+ auto scan = std::make_unique<FullIndexScan>(node->index->CloneAs<IndexRef>());
+ auto filter = std::make_unique<Filter>(std::move(scan), std::move(node->query_expr));
+
+ std::unique_ptr<PlanOperator> op = std::move(filter);
+
+ // order is important here, since limit(sort(op)) is different from sort(limit(op))
+ if (node->sort_by) {
+ op = std::make_unique<Sort>(std::move(op), std::move(node->sort_by));
Review Comment:
If you want more detail:
here we lower the IR from a syntactically intuitive structure to the planning subset.
##########
src/search/passes/lower_to_plan.h:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ *
+ */
+
+#pragma once
+
+#include <memory>
+
+#include "search/ir.h"
+#include "search/ir_pass.h"
+#include "search/ir_plan.h"
+
+namespace kqir {
+
+struct LowerToPlan : Visitor {
+ std::unique_ptr<Node> Visit(std::unique_ptr<SearchExpr> node) override {
+ auto scan = std::make_unique<FullIndexScan>(node->index->CloneAs<IndexRef>());
+ auto filter = std::make_unique<Filter>(std::move(scan), std::move(node->query_expr));
+
+ std::unique_ptr<PlanOperator> op = std::move(filter);
+
+ // order is important here, since limit(sort(op)) is different from sort(limit(op))
+ if (node->sort_by) {
+ op = std::make_unique<Sort>(std::move(op), std::move(node->sort_by));
Review Comment:
If you want more detail:
here we lower the IR from a syntactically-intuitive structure to the planning subset.
--
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: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add plan lowering pass for KQIR [kvrocks]
Posted by "PragmaTwice (via GitHub)" <gi...@apache.org>.
PragmaTwice commented on code in PR #2247:
URL: https://github.com/apache/kvrocks/pull/2247#discussion_r1564500914
##########
src/search/passes/lower_to_plan.h:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ *
+ */
+
+#pragma once
+
+#include <memory>
+
+#include "search/ir.h"
+#include "search/ir_pass.h"
+#include "search/ir_plan.h"
+
+namespace kqir {
+
+struct LowerToPlan : Visitor {
+ std::unique_ptr<Node> Visit(std::unique_ptr<SearchExpr> node) override {
+ auto scan = std::make_unique<FullIndexScan>(node->index->CloneAs<IndexRef>());
+ auto filter = std::make_unique<Filter>(std::move(scan), std::move(node->query_expr));
+
+ std::unique_ptr<PlanOperator> op = std::move(filter);
+
+ // order is important here, since limit(sort(op)) is different from sort(limit(op))
+ if (node->sort_by) {
+ op = std::make_unique<Sort>(std::move(op), std::move(node->sort_by));
Review Comment:
lowering is a term in compiler. especially in IR optimization.
https://news.ycombinator.com/item?id=26928724
--
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: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add plan lowering pass for KQIR [kvrocks]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #2247:
URL: https://github.com/apache/kvrocks/pull/2247#discussion_r1564494288
##########
src/search/passes/lower_to_plan.h:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ *
+ */
+
+#pragma once
+
+#include <memory>
+
+#include "search/ir.h"
+#include "search/ir_pass.h"
+#include "search/ir_plan.h"
+
+namespace kqir {
+
+struct LowerToPlan : Visitor {
+ std::unique_ptr<Node> Visit(std::unique_ptr<SearchExpr> node) override {
+ auto scan = std::make_unique<FullIndexScan>(node->index->CloneAs<IndexRef>());
+ auto filter = std::make_unique<Filter>(std::move(scan), std::move(node->query_expr));
+
+ std::unique_ptr<PlanOperator> op = std::move(filter);
+
+ // order is important here, since limit(sort(op)) is different from sort(limit(op))
+ if (node->sort_by) {
+ op = std::make_unique<Sort>(std::move(op), std::move(node->sort_by));
Review Comment:
why does this called lower? Since it extract a Sort node, don't know what's the naming rule here
--
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: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add plan lowering pass for KQIR [kvrocks]
Posted by "PragmaTwice (via GitHub)" <gi...@apache.org>.
PragmaTwice merged PR #2247:
URL: https://github.com/apache/kvrocks/pull/2247
--
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: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org