OmniSciDB  6686921089
 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 2017 MapD Technologies, 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 number of rows per fragment
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 
79 
80  // write mutex, only to be used inside catalog package
81  std::shared_ptr<std::mutex> mutex_;
82 
84  : tableId(-1)
85  , shard(-1)
86  , nShards(0)
87  , shardedColumnId(0)
88  , sortedColumnId(0)
89  , persistenceLevel(Data_Namespace::MemoryLevel::DISK_LEVEL)
93  , mutex_(std::make_shared<std::mutex>()) {}
94 
95  virtual ~TableDescriptor() = default;
96 
97  inline bool isForeignTable() const { return storageType == StorageType::FOREIGN_TABLE; }
98 
99  inline bool isTemporaryTable() const {
101  }
102 };
103 
104 inline bool table_is_replicated(const TableDescriptor* td) {
105  return td->partitions == "REPLICATED";
106 }
107 
108 // compare for lowest id
109 inline bool compare_td_id(const TableDescriptor* first, const TableDescriptor* second) {
110  return (first->tableId < second->tableId);
111 }
112 
113 inline bool table_is_temporary(const TableDescriptor* const td) {
115 }
116 
119  int64_t max_rows;
120 
122  : max_rollback_epochs(td->maxRollbackEpochs), max_rows(td->maxRows) {}
123 
124  bool operator==(const TableDescriptor* td) {
126  return false;
127  }
128  if (max_rows != td->maxRows) {
129  return false;
130  }
131  // Add more tests for additional params as needed
132  return true;
133  }
134 };
135 
136 #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_
#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:76
std::string viewSQL
Common Enum definitions for SQL processing.
static constexpr char const * FOREIGN_TABLE
bool operator==(const TableDescriptor *td)