OmniSciDB  ca0c39ec8f
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TableDescriptor.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 TABLE_DESCRIPTOR_H
18 #define TABLE_DESCRIPTOR_H
19 
20 #include <cstdint>
21 #include <string>
22 
23 #include "DataMgr/MemoryLevel.h"
25 #include "Shared/sqldefs.h"
26 
31 struct StorageType {
32  static constexpr char const* FOREIGN_TABLE = "FOREIGN_TABLE";
33  static constexpr char const* LOCAL_TABLE = "LOCAL_TABLE";
34 };
35 
42 #define DEFAULT_MAX_ROLLBACK_EPOCHS 3
44  int32_t tableId;
45  int32_t shard;
46  std::string tableName;
47  int32_t userId;
48  int32_t nColumns;
49  bool isView;
50  std::string viewSQL;
51  std::string fragments; // placeholder for fragmentation information
53  fragType; // fragmentation type. Only INSERT_ORDER is supported now.
54  int32_t maxFragRows; // max number of rows per fragment
55  int64_t maxChunkSize; // max chunk size per fragment (in bytes)
56  int32_t fragPageSize; // page size
57  int64_t maxRows; // max number of rows in the table
58  std::string partitions; // distributed partition scheme
59  std::string
60  keyMetainfo; // meta-information about shard keys and shared dictionary, as JSON
61 
62  std::shared_ptr<Fragmenter_Namespace::AbstractFragmenter>
63  fragmenter; // point to fragmenter object for the table. it's instantiated upon
64  // first use.
65  int32_t
66  nShards; // # of shards, i.e. physical tables for this logical table (default: 0)
67  int shardedColumnId; // Id of the column to be sharded on
68  int sortedColumnId; // Id of the column to be sorted on
70  bool hasDeletedCol; // Does table has a delete col, Yes (VACUUM = DELAYED)
71  // No (VACUUM = IMMEDIATE)
72  // Spi means Sequential Positional Index which is equivalent to the input index in a
73  // RexInput node
74  std::vector<int> columnIdBySpi_; // spi = 1,2,3,...
75  std::string storageType; // foreign/local storage
76 
80 
81  // write mutex, only to be used inside catalog package
82  std::shared_ptr<std::mutex> mutex_;
83 
85  : tableId(-1)
86  , shard(-1)
87  , nShards(0)
88  , shardedColumnId(0)
89  , sortedColumnId(0)
90  , persistenceLevel(Data_Namespace::MemoryLevel::DISK_LEVEL)
95  , mutex_(std::make_shared<std::mutex>()) {}
96 
97  virtual ~TableDescriptor() = default;
98 
99  inline bool isForeignTable() const { return storageType == StorageType::FOREIGN_TABLE; }
100 
101  inline bool isTemporaryTable() const {
103  }
104 
105  std::vector<int> getTableChunkKey(const int getCurrentDBId) const {
106  std::vector<int> table_chunk_key_prefix;
107  if (fragmenter) {
108  table_chunk_key_prefix = fragmenter->getFragmentsForQuery().chunkKeyPrefix;
109  } else {
110  table_chunk_key_prefix.push_back(getCurrentDBId);
111  table_chunk_key_prefix.push_back(tableId);
112  }
113  return table_chunk_key_prefix;
114  }
115 };
116 
117 inline bool table_is_replicated(const TableDescriptor* td) {
118  return td->partitions == "REPLICATED";
119 }
120 
121 // compare for lowest id
122 inline bool compare_td_id(const TableDescriptor* first, const TableDescriptor* second) {
123  return (first->tableId < second->tableId);
124 }
125 
126 inline bool table_is_temporary(const TableDescriptor* const td) {
128 }
129 
132  int64_t max_rows;
133 
135  : max_rollback_epochs(td->maxRollbackEpochs), max_rows(td->maxRows) {}
136 
137  bool operator==(const TableDescriptor* td) {
139  return false;
140  }
141  if (max_rows != td->maxRows) {
142  return false;
143  }
144  // Add more tests for additional params as needed
145  return true;
146  }
147 };
148 
149 #endif // TABLE_DESCRIPTOR
int32_t maxRollbackEpochs
std::string partitions
bool compare_td_id(const TableDescriptor *first, const TableDescriptor *second)
std::string tableName
std::string storageType
std::string fragments
bool isForeignTable() const
std::vector< int > columnIdBySpi_
std::shared_ptr< std::mutex > mutex_
bool is_in_memory_system_table
#define DEFAULT_MAX_ROLLBACK_EPOCHS
specifies the content in-memory of a row in the table metadata table
bool g_enable_smem_group_by true
std::string keyMetainfo
std::shared_ptr< Fragmenter_Namespace::AbstractFragmenter > fragmenter
static constexpr char const * LOCAL_TABLE
bool isTemporaryTable() const
bool table_is_temporary(const TableDescriptor *const td)
bool table_is_replicated(const TableDescriptor *td)
TableDescriptorUpdateParams(const TableDescriptor *td)
Fragmenter_Namespace::FragmenterType fragType
Data_Namespace::MemoryLevel persistenceLevel
Encapsulates an enumeration of table storage type strings.
virtual ~TableDescriptor()=default
bool g_enable_watchdog false
Definition: Execute.cpp:79
std::string viewSQL
Common Enum definitions for SQL processing.
static constexpr char const * FOREIGN_TABLE
bool operator==(const TableDescriptor *td)
std::vector< int > getTableChunkKey(const int getCurrentDBId) const