1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef PROJECTION_TREE_H 16 #define PROJECTION_TREE_H 17 18 #include <iostream> 19 #include <unordered_map> 20 #include <vector> 21 22 #include "doc_errno.h" 23 #include "json_common.h" 24 #include "rd_log_print.h" 25 26 namespace DocumentDB { 27 struct ProjectionNode { 28 std::unordered_map<std::string, ProjectionNode *> sonNode; 29 bool isDeepest; 30 int Deep; ProjectionNodeProjectionNode31 ProjectionNode() 32 { 33 Deep = 0; 34 isDeepest = true; 35 } 36 int DeleteProjectionNode(); ~ProjectionNodeProjectionNode37 ~ProjectionNode() 38 { 39 DeleteProjectionNode(); 40 } 41 }; 42 class ProjectionTree { 43 public: 44 int ParseTree(std::vector<std::vector<std::string>> &path); 45 bool SearchTree(std::vector<std::string> &singlePath, size_t &index); 46 47 private: 48 ProjectionNode node_; 49 }; 50 } // namespace DocumentDB 51 #endif // PROJECTION_TREE_H