taco-db  0.1.0
Type.h
Go to the documentation of this file.
1 
7 #ifndef CATALOG_SYSTABLES_Type_H
8 #define CATALOG_SYSTABLES_Type_H
9 
10 namespace taco {
11 
17 public:
18 
22  constexpr Oid
23  typid() const {
24  return m_typid;
25  }
26 
30  constexpr int16_t
31  typlen() const {
32  return m_typlen;
33  }
34 
38  constexpr bool
39  typisvarlen() const {
40  return m_typisvarlen;
41  }
42 
46  constexpr bool
47  typbyref() const {
48  return m_typbyref;
49  }
50 
54  constexpr uint8_t
55  typalign() const {
56  return m_typalign;
57  }
58 
62  constexpr const std::string&
63  typname() const {
64  return m_typname;
65  }
66 
70  constexpr Oid
71  typinfunc() const {
72  return m_typinfunc;
73  }
74 
78  constexpr Oid
79  typoutfunc() const {
80  return m_typoutfunc;
81  }
82 
86  constexpr Oid
87  typlenfunc() const {
88  return m_typlenfunc;
89  }
90 
91 
92 
93 private:
95  Oid typid,
96  int16_t typlen,
97  bool typisvarlen,
98  bool typbyref,
99  uint8_t typalign,
100  std::string typname,
101  Oid typinfunc,
102  Oid typoutfunc,
104 
105  ):
106  m_typid((typid)),
107  m_typlen((typlen)),
109  m_typbyref((typbyref)),
110  m_typalign((typalign)),
111  m_typname(std::move(typname)),
115 {}
116 
118  int16_t m_typlen;
121  uint8_t m_typalign;
122  std::string m_typname;
126 
133  std::vector<Datum> GetDatumVector() const;
134 
140  static SysTable_Type *Create(const std::vector<Datum>&);
141 
142  SysTable_Type(const SysTable_Type&) = default;
144 
145  friend class BootstrapCatCache;
147 
148 public:
149  // The following are constants of the field ids in the systables.
150  // These are mostly used by the catalog cache impl. to prevent accidental
151  // misspelling of column names.
152 
153  inline static constexpr FieldId
155  return 0;
156  }
157 
158  inline static constexpr FieldId
160  return 1;
161  }
162 
163  inline static constexpr FieldId
165  return 2;
166  }
167 
168  inline static constexpr FieldId
170  return 3;
171  }
172 
173  inline static constexpr FieldId
175  return 4;
176  }
177 
178  inline static constexpr FieldId
180  return 5;
181  }
182 
183  inline static constexpr FieldId
185  return 6;
186  }
187 
188  inline static constexpr FieldId
190  return 7;
191  }
192 
193  inline static constexpr FieldId
195  return 8;
196  }
197 
198 
199 };
200 
201 } // namespace taco
202 
203 #endif // CATALOG_SYSTABLES_Type_H
204 
BootstrapCatCache stores hard-coded data needed to bootstrap the entire database catalog.
Definition: BootstrapCatCache.h:21
Some internal functions of catalog cache implementations.
Definition: CatCacheBase.h:38
SysTable_Type is an in-memory cached record in the system catalog SysTable_Type.
Definition: Type.h:16
constexpr const std::string & typname() const
Returns the type name.
Definition: Type.h:63
static constexpr FieldId typbyref_colid()
Definition: Type.h:169
static constexpr FieldId typlen_colid()
Definition: Type.h:159
std::string m_typname
Definition: Type.h:122
constexpr Oid typoutfunc() const
Returns the output function of this type.
Definition: Type.h:79
constexpr Oid typid() const
Returns the type ID.
Definition: Type.h:23
SysTable_Type(const SysTable_Type &)=default
constexpr uint8_t typalign() const
Returns the alignment requirement of the type.
Definition: Type.h:55
static constexpr FieldId typisvarlen_colid()
Definition: Type.h:164
Oid m_typid
Definition: Type.h:117
constexpr bool typisvarlen() const
Returns whether it is variable-length.
Definition: Type.h:39
static constexpr FieldId typoutfunc_colid()
Definition: Type.h:189
int16_t m_typlen
Definition: Type.h:118
bool m_typisvarlen
Definition: Type.h:119
bool m_typbyref
Definition: Type.h:120
static constexpr FieldId typname_colid()
Definition: Type.h:179
static constexpr FieldId typalign_colid()
Definition: Type.h:174
static constexpr FieldId typinfunc_colid()
Definition: Type.h:184
static constexpr FieldId typid_colid()
Definition: Type.h:154
SysTable_Type & operator=(const SysTable_Type &)=default
uint8_t m_typalign
Definition: Type.h:121
Oid m_typoutfunc
Definition: Type.h:124
constexpr int16_t typlen() const
Returns the length of a type if it is fixed-length, or -1 if it is a variable-length field.
Definition: Type.h:31
constexpr Oid typlenfunc() const
Returns the function for calculating the type length for a fixed-length type that has a type paramete...
Definition: Type.h:87
SysTable_Type(Oid typid, int16_t typlen, bool typisvarlen, bool typbyref, uint8_t typalign, std::string typname, Oid typinfunc, Oid typoutfunc, Oid typlenfunc)
Definition: Type.h:94
static constexpr FieldId typlenfunc_colid()
Definition: Type.h:194
static SysTable_Type * Create(const std::vector< Datum > &)
Creates a new SysTable_Type with a data vector read from some record payload.
Definition: Type.cpp:17
Oid m_typlenfunc
Definition: Type.h:125
constexpr Oid typinfunc() const
Returns the input function of this type.
Definition: Type.h:71
constexpr bool typbyref() const
Returns whether the value should be passed by reference in memory.
Definition: Type.h:47
std::vector< Datum > GetDatumVector() const
Returns all the fields as a datum vector.
Definition: Type.cpp:43
Oid m_typinfunc
Definition: Type.h:123
Definition: Record.h:148
Definition: datum.h:28
uint32_t Oid
Definition: tdb_base.h:217
int16_t FieldId
Definition: tdb_base.h:219