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 #include "result_set_common.h"
17 #include "grd_format_config.h"
18 #include "doc_errno.h"
19 #include "grd_base/grd_error.h"
20 
21 namespace DocumentDB {
22 class ValueObject;
InitResultSet(std::shared_ptr<QueryContext> & context,DocumentStore * store,ResultSet & resultSet,bool isCutBranch)23 int InitResultSet(std::shared_ptr<QueryContext> &context, DocumentStore *store, ResultSet &resultSet, bool isCutBranch)
24 {
25     if (isCutBranch) {
26         for (const auto &singlePath : context->projectionPath) {
27             if (singlePath[0] == KEY_ID && context->viewType == true) { // projection has Id and viewType is true
28                 context->ifShowId = true;
29                 break;
30             }
31         }
32         if (context->projectionTree.ParseTree(context->projectionPath) == -E_INVALID_ARGS) {
33             GLOGE("Parse ProjectionTree failed");
34             return -E_INVALID_ARGS;
35         }
36     }
37     return resultSet.Init(context, store, isCutBranch);
38 }
39 } // namespace DocumentDB
40