OmniSciDB  a987f07e93
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
InsertDataLoader.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef INSERT_DATA_LOADER_H_
18 #define INSERT_DATA_LOADER_H_
19 
20 #include "../Catalog/Catalog.h"
21 #include "Fragmenter.h"
22 
23 namespace Fragmenter_Namespace {
24 
26  public:
28  public:
29  virtual size_t leafCount() = 0;
30  virtual void insertChunksToLeaf(
31  const Catalog_Namespace::SessionInfo& parent_session_info,
32  const size_t leaf_idx,
33  const Fragmenter_Namespace::InsertChunks& insert_chunks) = 0;
34  virtual void insertDataToLeaf(
35  const Catalog_Namespace::SessionInfo& parent_session_info,
36  const size_t leaf_idx,
37  Fragmenter_Namespace::InsertData& insert_data) = 0;
38  virtual void checkpoint(const Catalog_Namespace::SessionInfo& parent_session_info,
39  int tableId) = 0;
40  virtual void rollback(const Catalog_Namespace::SessionInfo& parent_session_info,
41  int tableId) = 0;
42 
43  virtual ~InsertConnector() = default;
44  };
45 
47  : leaf_count_(connector.leafCount())
49  , connector_(connector) {}
50 
51  void insertData(const Catalog_Namespace::SessionInfo& session_info,
52  InsertData& insert_data);
53 
54  void insertChunks(const Catalog_Namespace::SessionInfo& session_info,
55  const InsertChunks& insert_chunks);
56 
57  size_t getLeafCount() const { return leaf_count_; }
58 
59  private:
66  size_t moveToNextLeaf();
67 
68  size_t leaf_count_;
72 };
73 
75  public:
76  size_t leafCount() override { return 1; }
77  void insertChunksToLeaf(
78  const Catalog_Namespace::SessionInfo& parent_session_info,
79  const size_t leaf_idx,
80  const Fragmenter_Namespace::InsertChunks& insert_chunks) override;
81  void insertDataToLeaf(const Catalog_Namespace::SessionInfo& parent_session_info,
82  const size_t leaf_idx,
83  Fragmenter_Namespace::InsertData& insert_data) override;
84  void checkpoint(const Catalog_Namespace::SessionInfo& parent_session_info,
85  int tableId) override;
86  void rollback(const Catalog_Namespace::SessionInfo& parent_session_info,
87  int tableId) override;
88 };
89 
90 } // namespace Fragmenter_Namespace
91 
92 #endif
void insertChunks(const Catalog_Namespace::SessionInfo &session_info, const InsertChunks &insert_chunks)
virtual void insertDataToLeaf(const Catalog_Namespace::SessionInfo &parent_session_info, const size_t leaf_idx, Fragmenter_Namespace::InsertData &insert_data)=0
void insertData(const Catalog_Namespace::SessionInfo &session_info, InsertData &insert_data)
void checkpoint(const Catalog_Namespace::SessionInfo &parent_session_info, int tableId) override
void insertDataToLeaf(const Catalog_Namespace::SessionInfo &parent_session_info, const size_t leaf_idx, Fragmenter_Namespace::InsertData &insert_data) override
virtual void checkpoint(const Catalog_Namespace::SessionInfo &parent_session_info, int tableId)=0
void insertChunksToLeaf(const Catalog_Namespace::SessionInfo &parent_session_info, const size_t leaf_idx, const Fragmenter_Namespace::InsertChunks &insert_chunks) override
void rollback(const Catalog_Namespace::SessionInfo &parent_session_info, int tableId) override
The data to be inserted using the fragment manager.
Definition: Fragmenter.h:68
virtual void rollback(const Catalog_Namespace::SessionInfo &parent_session_info, int tableId)=0
std::shared_timed_mutex shared_mutex
InsertDataLoader(InsertConnector &connector)
virtual void insertChunksToLeaf(const Catalog_Namespace::SessionInfo &parent_session_info, const size_t leaf_idx, const Fragmenter_Namespace::InsertChunks &insert_chunks)=0