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 16 #ifndef RESULTSET_H 17 #define RESULTSET_H 18 19 #include <sstream> 20 #include <string> 21 #include <vector> 22 23 #include "check_common.h" 24 #include "doc_errno.h" 25 #include "document_store.h" 26 #include "grd_base/grd_type_export.h" 27 #include "rd_json_object.h" 28 29 namespace DocumentDB { 30 class ResultSet { 31 public: 32 ResultSet(); 33 ~ResultSet(); 34 int Init(std::shared_ptr<QueryContext> &context, DocumentStore *store, bool isCutBranch); 35 int GetNext(bool isNeedTransaction = false, bool isNeedCheckTable = false); 36 int GetValue(char **value); 37 int GetValue(std::string &value); 38 int GetKey(std::string &key); 39 int EraseCollection(); 40 41 private: 42 int GetNextInner(bool isNeedCheckTable); 43 int GetValueFromDB(Key &key, JsonObject &filterObj, std::string &jsonKey, std::string &jsonData); 44 int CutJsonBranch(std::string &jsonKey, std::string &jsonData); 45 int CheckCutNode(JsonObject *node, std::vector<std::string> singleCutPath, 46 std::vector<std::vector<std::string>> &allCutPath); 47 int GetNextWithField(); 48 49 DocumentStore *store_ = nullptr; 50 bool isCutBranch_ = false; 51 size_t index_ = 0; 52 std::shared_ptr<QueryContext> context_; 53 std::pair<std::string, std::string> matchData_; 54 std::string lastKeyIndex_; 55 }; 56 } // namespace DocumentDB 57 #endif // RESULTSET_H