OmniSciDB  8a228a1076
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 
43  int32_t tableId;
44  int32_t shard;
45  std::string tableName;
46  int32_t userId;
47  int32_t nColumns;
48  bool isView;
49  std::string viewSQL;
50  std::string fragments; // placeholder for fragmentation information
52  fragType; // fragmentation type. Only INSERT_ORDER is supported now.
53  int32_t maxFragRows; // max number of rows per fragment
54  int64_t maxChunkSize; // max number of rows per fragment
55  int32_t fragPageSize; // page size
56  int64_t maxRows; // max number of rows in the table
57  std::string partitions; // distributed partition scheme
58  std::string
59  keyMetainfo; // meta-information about shard keys and shared dictionary, as JSON
60 
61  std::shared_ptr<Fragmenter_Namespace::AbstractFragmenter>
62  fragmenter; // point to fragmenter object for the table. it's instantiated upon
63  // first use.
64  int32_t
65  nShards; // # of shards, i.e. physical tables for this logical table (default: 0)
66  int shardedColumnId; // Id of the column to be sharded on
67  int sortedColumnId; // Id of the column to be sorted on
69  bool hasDeletedCol; // Does table has a delete col, Yes (VACUUM = DELAYED)
70  // No (VACUUM = IMMEDIATE)
71  // Spi means Sequential Positional Index which is equivalent to the input index in a
72  // RexInput node
73  std::vector<int> columnIdBySpi_; // spi = 1,2,3,...
74  std::string storageType; // foreign/local storage
75 
76  // write mutex, only to be used inside catalog package
77  std::shared_ptr<std::mutex> mutex_;
78 
80  : tableId(-1)
81  , shard(-1)
82  , nShards(0)
83  , shardedColumnId(0)
84  , sortedColumnId(0)
85  , persistenceLevel(Data_Namespace::MemoryLevel::DISK_LEVEL)
86  , hasDeletedCol(true)
87  , mutex_(std::make_shared<std::mutex>()) {}
88 
89  virtual ~TableDescriptor() = default;
90 };
91 
92 inline bool table_is_replicated(const TableDescriptor* td) {
93  return td->partitions == "REPLICATED";
94 }
95 
96 // compare for lowest id
97 inline bool compare_td_id(const TableDescriptor* first, const TableDescriptor* second) {
98  return (first->tableId < second->tableId);
99 }
100 
101 inline bool table_is_temporary(const TableDescriptor* const td) {
103 }
104 
105 #endif // TABLE_DESCRIPTOR
std::string partitions
bool compare_td_id(const TableDescriptor *first, const TableDescriptor *second)
std::string tableName
std::string storageType
std::string fragments
std::vector< int > columnIdBySpi_
std::shared_ptr< std::mutex > mutex_
std::string keyMetainfo
std::shared_ptr< Fragmenter_Namespace::AbstractFragmenter > fragmenter
static constexpr char const * LOCAL_TABLE
bool table_is_temporary(const TableDescriptor *const td)
bool table_is_replicated(const TableDescriptor *td)
Fragmenter_Namespace::FragmenterType fragType
Data_Namespace::MemoryLevel persistenceLevel
Encapsulates an enumeration of table storage type strings.
std::string viewSQL
Common Enum definitions for SQL processing.
specifies the content in-memory of a row in the table metadata table
static constexpr char const * FOREIGN_TABLE