This is an automated email from the ASF dual-hosted git repository.

twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new b5207f30 Initialize the data structure of KQIR (#2183)
b5207f30 is described below

commit b5207f307a7c61814a4806667be6a3f9d4b85243
Author: Twice <[email protected]>
AuthorDate: Wed Mar 20 15:01:45 2024 +0900

    Initialize the data structure of KQIR (#2183)
---
 src/search/ir.h | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 106 insertions(+)

diff --git a/src/search/ir.h b/src/search/ir.h
new file mode 100644
index 00000000..d431d1be
--- /dev/null
+++ b/src/search/ir.h
@@ -0,0 +1,106 @@
+/*
+ * 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 <limits>
+#include <memory>
+#include <string>
+#include <variant>
+#include <vector>
+
+// kqir stands for Kvorcks Query Intermediate Representation
+namespace kqir {
+
+struct FieldRef {
+  std::string name;
+};
+
+struct StringLiteral {
+  std::string val;
+};
+
+struct TagContainExpr {
+  FieldRef field;
+  StringLiteral tag;
+};
+
+struct NumericLiteral {
+  double val;
+};
+
+struct NumericCompareExpr {
+  enum { EQ, NE, LT, LET, GT, GET } op;
+  FieldRef field;
+  NumericLiteral num;
+};
+
+struct BoolLiteral {
+  bool val;
+};
+
+struct BooleanExpr {
+  std::variant<TagContainExpr, NumericCompareExpr, BoolLiteral> expr;
+};
+
+struct QueryExpr;
+
+struct LogicalUnaryExpr {
+  enum { NOT } op;
+  std::unique_ptr<QueryExpr> inner;
+};
+
+struct LogicalBinaryExpr {
+  enum { AND, OR } op;
+  std::unique_ptr<QueryExpr> lhs;
+  std::unique_ptr<QueryExpr> rhs;
+};
+
+struct QueryExpr {
+  std::variant<LogicalUnaryExpr, LogicalBinaryExpr, BooleanExpr> expr;
+};
+
+struct Limit {
+  size_t offset = 0;
+  size_t count = std::numeric_limits<size_t>::max();
+};
+
+struct SortBy {
+  enum { ASC, DESC } order;
+  FieldRef field;
+};
+
+struct SelectExpr {
+  std::vector<FieldRef> fields;
+};
+
+struct IndexRef {
+  std::string name;
+};
+
+struct SearchStmt {
+  IndexRef index_ref;
+  QueryExpr query_expr;
+  Limit limit;
+  SortBy sort_by;
+  SelectExpr select_expr;
+};
+
+}  // namespace kqir

Reply via email to