• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 OHOS_DISTRIBUTED_DATA_NATIVE_GDB_GRAPH_CONNECTION_H
17 #define OHOS_DISTRIBUTED_DATA_NATIVE_GDB_GRAPH_CONNECTION_H
18 
19 #include <memory>
20 #include <mutex>
21 #include <vector>
22 
23 #include "connection.h"
24 #include "gdb_store_config.h"
25 #include "grd_adapter.h"
26 
27 namespace OHOS::DistributedDataAip {
28 class GraphConnection : public Connection {
29 public:
30     static std::pair<int32_t, std::shared_ptr<Connection>> Create(const StoreConfig &config, bool isWriter);
31     GraphConnection(const StoreConfig &config, bool isWriter);
32     ~GraphConnection() override;
33     std::pair<int32_t, Stmt> CreateStatement(const std::string &gql, std::shared_ptr<Connection> conn) override;
34     DBType GetDBType() const override;
35     bool IsWriter() const override;
36 
37 private:
38     static constexpr uint32_t NO_ITER = 0;
39     static constexpr uint32_t ITER_V1 = 5000;
40     static constexpr uint32_t ITERS[] = { NO_ITER, ITER_V1 };
41     static constexpr uint32_t ITERS_COUNT = sizeof(ITERS) / sizeof(ITERS[0]);
42 
43     static const int32_t regCreator_;
44 
45     int InnerOpen(const StoreConfig &config);
46     int32_t ResetKey(const StoreConfig &config);
47     bool IsEncryptInvalidChanged(const StoreConfig &config);
48     GRD_DB *dbHandle_ = nullptr;
49     const StoreConfig config_;
50     bool isWriter_ = false;
51 };
52 
53 } // namespace OHOS::DistributedDataAip
54 
55 #endif // OHOS_DISTRIBUTED_DATA_NATIVE_GDB_GRAPH_CONNECTION_H
56