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