Lbug C++ API
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <string>
5#include <unordered_map>
6#include <unordered_set>
7#include <vector>
8
9#include "api.h"
10#include "cast.h"
11#include "copy_constructors.h"
12#include "interval_t.h"
13
14namespace lbug {
15namespace main {
16class ClientContext;
17}
18namespace processor {
19class ParquetReader;
20}
21namespace catalog {
22class NodeTableCatalogEntry;
23}
24namespace common {
25
26class Serializer;
27class Deserializer;
28struct FileInfo;
29
30using sel_t = uint64_t;
31constexpr sel_t INVALID_SEL = UINT64_MAX;
32using hash_t = uint64_t;
33using page_idx_t = uint32_t;
35using page_offset_t = uint32_t;
36constexpr page_idx_t INVALID_PAGE_IDX = UINT32_MAX;
37using file_idx_t = uint32_t;
38constexpr file_idx_t INVALID_FILE_IDX = UINT32_MAX;
39using page_group_idx_t = uint32_t;
41using column_id_t = uint32_t;
42using property_id_t = uint32_t;
43constexpr column_id_t INVALID_COLUMN_ID = UINT32_MAX;
45using idx_t = uint32_t;
46constexpr idx_t INVALID_IDX = UINT32_MAX;
47using block_idx_t = uint64_t;
48constexpr block_idx_t INVALID_BLOCK_IDX = UINT64_MAX;
49using struct_field_idx_t = uint16_t;
52using row_idx_t = uint64_t;
53constexpr row_idx_t INVALID_ROW_IDX = UINT64_MAX;
54constexpr uint32_t UNDEFINED_CAST_COST = UINT32_MAX;
55using node_group_idx_t = uint64_t;
57using partition_idx_t = uint64_t;
59using length_t = uint64_t;
60constexpr length_t INVALID_LENGTH = UINT64_MAX;
61using list_size_t = uint32_t;
62using sequence_id_t = uint64_t;
63using oid_t = uint64_t;
64constexpr oid_t INVALID_OID = UINT64_MAX;
65
66using transaction_t = uint64_t;
67constexpr transaction_t INVALID_TRANSACTION = UINT64_MAX;
68using executor_id_t = uint64_t;
69using executor_info = std::unordered_map<executor_id_t, uint64_t>;
70
71// table id type alias
73using table_id_vector_t = std::vector<table_id_t>;
74using table_id_set_t = std::unordered_set<table_id_t>;
75template<typename T>
76using table_id_map_t = std::unordered_map<table_id_t, T>;
78// offset type alias
79using offset_t = uint64_t;
80constexpr offset_t INVALID_OFFSET = UINT64_MAX;
81// internal id type alias
82struct internalID_t;
85
86using cardinality_t = uint64_t;
87constexpr offset_t INVALID_LIMIT = UINT64_MAX;
88using offset_vec_t = std::vector<offset_t>;
89// System representation for internalID.
93
96
97 // comparison operators
98 bool operator==(const internalID_t& rhs) const;
99 bool operator!=(const internalID_t& rhs) const;
100 bool operator>(const internalID_t& rhs) const;
101 bool operator>=(const internalID_t& rhs) const;
102 bool operator<(const internalID_t& rhs) const;
103 bool operator<=(const internalID_t& rhs) const;
104};
105
106// System representation for a variable-sized overflow value.
108 // the size of the overflow buffer can be calculated as:
109 // numElements * sizeof(Element) + nullMap(4 bytes alignment)
110 uint64_t numElements = 0;
111 uint8_t* value = nullptr;
112};
113
121
123 int64_t pos;
124};
125
129
133
134struct int128_t;
135struct uint128_t;
136struct ku_string_t;
137
138template<typename T>
140 std::is_same_v<T, int8_t> || std::is_same_v<T, int16_t> || std::is_same_v<T, int32_t> ||
141 std::is_same_v<T, int64_t> || std::is_same_v<T, int128_t>;
142
143template<typename T>
145 std::is_same_v<T, uint8_t> || std::is_same_v<T, uint16_t> || std::is_same_v<T, uint32_t> ||
146 std::is_same_v<T, uint64_t> || std::is_same_v<T, uint128_t>;
147
148template<typename T>
150
151template<typename T>
152concept FloatingPointTypes = std::is_same_v<T, float> || std::is_same_v<T, double>;
153
154template<typename T>
155concept NumericTypes = IntegerTypes<T> || std::floating_point<T>;
156
157template<typename T>
158concept ComparableTypes = NumericTypes<T> || std::is_same_v<T, ku_string_t> ||
159 std::is_same_v<T, interval_t> || std::is_same_v<T, bool>;
160
161template<typename T>
163 ((std::integral<T> && !std::is_same_v<T, bool>) || std::floating_point<T> ||
164 std::is_same_v<T, int128_t> || std::is_same_v<T, uint128_t>);
165template<typename T>
166concept IndexHashable = ((std::integral<T> && !std::is_same_v<T, bool>) || std::floating_point<T> ||
167 std::is_same_v<T, int128_t> || std::is_same_v<T, uint128_t> ||
168 std::is_same_v<T, ku_string_t> || std::is_same_v<T, std::string_view> ||
169 std::same_as<T, std::string>);
170
171template<typename T>
173 (std::integral<T> || std::floating_point<T> || std::is_same_v<T, int128_t> ||
174 std::is_same_v<T, uint128_t> || std::is_same_v<T, internalID_t> ||
175 std::is_same_v<T, interval_t> || std::is_same_v<T, ku_string_t>);
176
177template<typename T>
179 (std::is_same_v<T, list_entry_t> || std::is_same_v<T, struct_entry_t>);
180
181template<typename T>
183
184enum class LogicalTypeID : uint8_t {
185 ANY = 0,
186 NODE = 10,
187 REL = 11,
189 // SERIAL is a special data type that is used to represent a sequence of INT64 values that are
190 // incremented by 1 starting from 0.
191 SERIAL = 13,
192
193 BOOL = 22,
194 INT64 = 23,
195 INT32 = 24,
196 INT16 = 25,
197 INT8 = 26,
198 UINT64 = 27,
199 UINT32 = 28,
200 UINT16 = 29,
201 UINT8 = 30,
202 INT128 = 31,
203 DOUBLE = 32,
204 FLOAT = 33,
205 DATE = 34,
215
216 STRING = 50,
217 BLOB = 51,
218
219 LIST = 52,
220 ARRAY = 53,
221 STRUCT = 54,
222 MAP = 55,
223 UNION = 56,
225
226 UUID = 59,
227
228};
229
230enum class PhysicalTypeID : uint8_t {
231 // Fixed size types.
232 ANY = 0,
233 BOOL = 1,
234 INT64 = 2,
235 INT32 = 3,
236 INT16 = 4,
237 INT8 = 5,
241 UINT8 = 9,
242 INT128 = 10,
243 DOUBLE = 11,
244 FLOAT = 12,
250
251 // Variable size types.
252 STRING = 20,
253 LIST = 22,
254 ARRAY = 23,
255 STRUCT = 24,
257};
258
259class ExtraTypeInfo;
260class StructField;
261class StructTypeInfo;
262
263enum class TypeCategory : uint8_t { INTERNAL = 0, UDT = 1 };
264
265class LogicalType {
266 friend struct LogicalTypeUtils;
267 friend struct DecimalType;
268 friend struct StructType;
269 friend struct ListType;
270 friend struct ArrayType;
271
272 LBUG_API LogicalType(const LogicalType& other);
273
274public:
275 LogicalType() : typeID{LogicalTypeID::ANY}, extraTypeInfo{nullptr} {
276 physicalType = getPhysicalType(this->typeID);
277 };
280
281 LBUG_API bool operator==(const LogicalType& other) const;
282 LBUG_API bool operator!=(const LogicalType& other) const;
283
284 LBUG_API std::string toString() const;
285 static bool isBuiltInType(const std::string& str);
286 static LogicalType convertFromString(const std::string& str, main::ClientContext* context);
287
288 LogicalTypeID getLogicalTypeID() const { return typeID; }
289 bool containsAny() const;
290 bool isInternalType() const { return category == TypeCategory::INTERNAL; }
291
292 PhysicalTypeID getPhysicalType() const { return physicalType; }
294 const std::unique_ptr<ExtraTypeInfo>& extraTypeInfo = nullptr);
295
296 void setExtraTypeInfo(std::unique_ptr<ExtraTypeInfo> typeInfo) {
297 extraTypeInfo = std::move(typeInfo);
298 }
299
300 const ExtraTypeInfo* getExtraTypeInfo() const { return extraTypeInfo.get(); }
301
302 void serialize(Serializer& serializer) const;
303
304 static LogicalType deserialize(Deserializer& deserializer);
305
306 LBUG_API static std::vector<LogicalType> copy(const std::vector<LogicalType>& types);
307 LBUG_API static std::vector<LogicalType> copy(const std::vector<LogicalType*>& types);
308
309 static LogicalType ANY() { return LogicalType(LogicalTypeID::ANY); }
310
311 // NOTE: avoid using this if possible, this is a temporary hack for passing internal types
312 // TODO(Royi) remove this when float compression no longer relies on this or ColumnChunkData
313 // takes physical types instead of logical types
314 static LogicalType ANY(PhysicalTypeID physicalType) {
316 ret.physicalType = physicalType;
317 return ret;
318 }
319
320 static LogicalType BOOL() { return LogicalType(LogicalTypeID::BOOL); }
321 static LogicalType HASH() { return LogicalType(LogicalTypeID::UINT64); }
322 static LogicalType INT64() { return LogicalType(LogicalTypeID::INT64); }
323 static LogicalType INT32() { return LogicalType(LogicalTypeID::INT32); }
324 static LogicalType INT16() { return LogicalType(LogicalTypeID::INT16); }
325 static LogicalType INT8() { return LogicalType(LogicalTypeID::INT8); }
326 static LogicalType UINT64() { return LogicalType(LogicalTypeID::UINT64); }
327 static LogicalType UINT32() { return LogicalType(LogicalTypeID::UINT32); }
328 static LogicalType UINT16() { return LogicalType(LogicalTypeID::UINT16); }
329 static LogicalType UINT8() { return LogicalType(LogicalTypeID::UINT8); }
330 static LogicalType INT128() { return LogicalType(LogicalTypeID::INT128); }
331 static LogicalType DOUBLE() { return LogicalType(LogicalTypeID::DOUBLE); }
332 static LogicalType FLOAT() { return LogicalType(LogicalTypeID::FLOAT); }
333 static LogicalType DATE() { return LogicalType(LogicalTypeID::DATE); }
334 static LogicalType TIMESTAMP_NS() { return LogicalType(LogicalTypeID::TIMESTAMP_NS); }
335 static LogicalType TIMESTAMP_MS() { return LogicalType(LogicalTypeID::TIMESTAMP_MS); }
337 static LogicalType TIMESTAMP_TZ() { return LogicalType(LogicalTypeID::TIMESTAMP_TZ); }
338 static LogicalType TIMESTAMP() { return LogicalType(LogicalTypeID::TIMESTAMP); }
339 static LogicalType INTERVAL() { return LogicalType(LogicalTypeID::INTERVAL); }
340 static LBUG_API LogicalType DECIMAL(uint32_t precision, uint32_t scale);
341 static LogicalType INTERNAL_ID() { return LogicalType(LogicalTypeID::INTERNAL_ID); }
342 static LogicalType UINT128() { return LogicalType(LogicalTypeID::UINT128); };
343 static LogicalType SERIAL() { return LogicalType(LogicalTypeID::SERIAL); }
344 static LogicalType STRING() { return LogicalType(LogicalTypeID::STRING); }
345 static LogicalType BLOB() { return LogicalType(LogicalTypeID::BLOB); }
346 static LogicalType UUID() { return LogicalType(LogicalTypeID::UUID); }
347 static LogicalType POINTER() { return LogicalType(LogicalTypeID::POINTER); }
348 static LBUG_API LogicalType STRUCT(std::vector<StructField>&& fields);
349
350 static LBUG_API LogicalType RECURSIVE_REL(std::vector<StructField>&& fields);
351
352 static LBUG_API LogicalType NODE(std::vector<StructField>&& fields);
353
354 static LBUG_API LogicalType REL(std::vector<StructField>&& fields);
355
356 static LBUG_API LogicalType UNION(std::vector<StructField>&& fields);
357
358 static LBUG_API LogicalType LIST(LogicalType childType);
359 template<class T>
360 static inline LogicalType LIST(T&& childType) {
361 return LogicalType::LIST(LogicalType(std::forward<T>(childType)));
362 }
363
364 static LBUG_API LogicalType MAP(LogicalType keyType, LogicalType valueType);
365 template<class T>
366 static LogicalType MAP(T&& keyType, T&& valueType) {
367 return LogicalType::MAP(LogicalType(std::forward<T>(keyType)),
368 LogicalType(std::forward<T>(valueType)));
369 }
370
371 static LBUG_API LogicalType ARRAY(LogicalType childType, uint64_t numElements);
372 template<class T>
373 static LogicalType ARRAY(T&& childType, uint64_t numElements) {
374 return LogicalType::ARRAY(LogicalType(std::forward<T>(childType)), numElements);
375 }
376
377private:
378 friend struct CAPIHelper;
379 friend struct JavaAPIHelper;
381 explicit LogicalType(LogicalTypeID typeID, std::unique_ptr<ExtraTypeInfo> extraTypeInfo);
382
383private:
384 LogicalTypeID typeID;
385 PhysicalTypeID physicalType;
386 std::unique_ptr<ExtraTypeInfo> extraTypeInfo;
388};
389
391public:
392 virtual ~ExtraTypeInfo() = default;
393
394 void serialize(Serializer& serializer) const { serializeInternal(serializer); }
395
396 virtual bool containsAny() const = 0;
397
398 virtual bool operator==(const ExtraTypeInfo& other) const = 0;
399
400 virtual std::unique_ptr<ExtraTypeInfo> copy() const = 0;
401
402 template<class TARGET>
403 const TARGET* constPtrCast() const {
405 }
406
407protected:
408 virtual void serializeInternal(Serializer& serializer) const = 0;
409};
410
412public:
413 explicit UDTTypeInfo(std::string typeName) : typeName{std::move(typeName)} {}
414
415 std::string getTypeName() const { return typeName; }
416
417 bool containsAny() const override { return false; }
418
419 bool operator==(const ExtraTypeInfo& other) const override;
420
421 std::unique_ptr<ExtraTypeInfo> copy() const override;
422
423 static std::unique_ptr<ExtraTypeInfo> deserialize(Deserializer& deserializer);
424
425private:
426 void serializeInternal(Serializer& serializer) const override;
427
428private:
429 std::string typeName;
430};
431
432class DecimalTypeInfo final : public ExtraTypeInfo {
433public:
434 explicit DecimalTypeInfo(uint32_t precision = 18, uint32_t scale = 3)
436
437 uint32_t getPrecision() const { return precision; }
438 uint32_t getScale() const { return scale; }
439
440 bool containsAny() const override { return false; }
441
442 bool operator==(const ExtraTypeInfo& other) const override;
443
444 std::unique_ptr<ExtraTypeInfo> copy() const override;
445
446 static std::unique_ptr<ExtraTypeInfo> deserialize(Deserializer& deserializer);
447
448protected:
449 void serializeInternal(Serializer& serializer) const override;
450
451 uint32_t precision, scale;
452};
453
455public:
456 ListTypeInfo() = default;
458
459 const LogicalType& getChildType() const { return childType; }
460
461 bool containsAny() const override;
462
463 bool operator==(const ExtraTypeInfo& other) const override;
464
465 std::unique_ptr<ExtraTypeInfo> copy() const override;
466
467 static std::unique_ptr<ExtraTypeInfo> deserialize(Deserializer& deserializer);
468
469protected:
470 void serializeInternal(Serializer& serializer) const override;
471
472protected:
474};
475
476class LBUG_API ArrayTypeInfo final : public ListTypeInfo {
477public:
478 ArrayTypeInfo() : numElements{0} {};
479 explicit ArrayTypeInfo(LogicalType childType, uint64_t numElements)
480 : ListTypeInfo{std::move(childType)}, numElements{numElements} {}
481
482 uint64_t getNumElements() const { return numElements; }
483
484 bool operator==(const ExtraTypeInfo& other) const override;
485
486 static std::unique_ptr<ExtraTypeInfo> deserialize(Deserializer& deserializer);
487
488 std::unique_ptr<ExtraTypeInfo> copy() const override;
489
490private:
491 void serializeInternal(Serializer& serializer) const override;
492
493private:
494 uint64_t numElements;
495};
496
498public:
500 StructField(std::string name, LogicalType type)
501 : name{std::move(name)}, type{std::move(type)} {};
502
504
505 std::string getName() const { return name; }
506
507 const LogicalType& getType() const { return type; }
508
509 bool containsAny() const;
510
511 bool operator==(const StructField& other) const;
512 bool operator!=(const StructField& other) const { return !(*this == other); }
513
514 void serialize(Serializer& serializer) const;
515
516 static StructField deserialize(Deserializer& deserializer);
517
519
520private:
521 std::string name;
522 LogicalType type;
523};
524
525class StructTypeInfo final : public ExtraTypeInfo {
526public:
527 StructTypeInfo() = default;
528 explicit StructTypeInfo(std::vector<StructField>&& fields);
529 StructTypeInfo(const std::vector<std::string>& fieldNames,
530 const std::vector<LogicalType>& fieldTypes);
531
532 bool hasField(const std::string& fieldName) const;
533 struct_field_idx_t getStructFieldIdx(std::string fieldName) const;
535 const StructField& getStructField(const std::string& fieldName) const;
536 const std::vector<StructField>& getStructFields() const;
537
539 std::vector<const LogicalType*> getChildrenTypes() const;
540 // can't be a vector of refs since that can't be for-each looped through
541 std::vector<std::string> getChildrenNames() const;
542
543 bool containsAny() const override;
544
545 bool operator==(const ExtraTypeInfo& other) const override;
546
547 static std::unique_ptr<ExtraTypeInfo> deserialize(Deserializer& deserializer);
548 std::unique_ptr<ExtraTypeInfo> copy() const override;
549
550private:
551 void serializeInternal(Serializer& serializer) const override;
552
553private:
554 std::vector<StructField> fields;
555 std::unordered_map<std::string, struct_field_idx_t> fieldNameToIdxMap;
556};
557
558using logical_type_vec_t = std::vector<LogicalType>;
559
561 static uint32_t getPrecision(const LogicalType& type);
562 static uint32_t getScale(const LogicalType& type);
563 static std::string insertDecimalPoint(const std::string& value, uint32_t posFromEnd);
564};
565
567 static const LogicalType& getChildType(const LogicalType& type);
568};
569
571 static const LogicalType& getChildType(const LogicalType& type);
572 static uint64_t getNumElements(const LogicalType& type);
573};
574
576 static std::vector<const LogicalType*> getFieldTypes(const LogicalType& type);
577 // since the field types isn't stored as a vector of LogicalTypes, we can't return vector<>&
578
580
581 static const LogicalType& getFieldType(const LogicalType& type, const std::string& key);
582
583 static std::vector<std::string> getFieldNames(const LogicalType& type);
584
585 static uint64_t getNumFields(const LogicalType& type);
586
587 static const std::vector<StructField>& getFields(const LogicalType& type);
588
589 static bool hasField(const LogicalType& type, const std::string& key);
590
591 static const StructField& getField(const LogicalType& type, struct_field_idx_t idx);
592
593 static const StructField& getField(const LogicalType& type, const std::string& key);
594
595 static struct_field_idx_t getFieldIdx(const LogicalType& type, const std::string& key);
596};
597
599 static const LogicalType& getKeyType(const LogicalType& type);
600
601 static const LogicalType& getValueType(const LogicalType& type);
602};
603
605 static constexpr union_field_idx_t TAG_FIELD_IDX = 0;
606
607 static constexpr auto TAG_FIELD_TYPE = LogicalTypeID::UINT16;
608
609 static constexpr char TAG_FIELD_NAME[] = "tag";
610
612
613 static std::string getFieldName(const LogicalType& type, union_field_idx_t idx);
614
615 static const LogicalType& getFieldType(const LogicalType& type, union_field_idx_t idx);
616
617 static const LogicalType& getFieldType(const LogicalType& type, const std::string& key);
618
619 static uint64_t getNumFields(const LogicalType& type);
620
621 static bool hasField(const LogicalType& type, const std::string& key);
622
623 static union_field_idx_t getFieldIdx(const LogicalType& type, const std::string& key);
624};
625
627 static std::string toString(PhysicalTypeID physicalType);
628 static uint32_t getFixedTypeSize(PhysicalTypeID physicalType);
629};
630
632 static std::string toString(LogicalTypeID dataTypeID);
633 static std::string toString(const std::vector<LogicalType>& dataTypes);
634 static std::string toString(const std::vector<LogicalTypeID>& dataTypeIDs);
635 static uint32_t getRowLayoutSize(const LogicalType& logicalType);
636 static bool isDate(const LogicalType& dataType);
637 static bool isDate(const LogicalTypeID& dataType);
638 static bool isTimestamp(const LogicalType& dataType);
639 static bool isTimestamp(const LogicalTypeID& dataType);
640 static bool isUnsigned(const LogicalType& dataType);
641 static bool isUnsigned(const LogicalTypeID& dataType);
642 static bool isIntegral(const LogicalType& dataType);
643 static bool isIntegral(const LogicalTypeID& dataType);
644 static bool isNumerical(const LogicalType& dataType);
645 static bool isNumerical(const LogicalTypeID& dataType);
646 static bool isFloatingPoint(const LogicalTypeID& dataType);
647 static bool isNested(const LogicalType& dataType);
648 static bool isNested(LogicalTypeID logicalTypeID);
649 static std::vector<LogicalTypeID> getAllValidComparableLogicalTypes();
650 static std::vector<LogicalTypeID> getNumericalLogicalTypeIDs();
651 static std::vector<LogicalTypeID> getIntegerTypeIDs();
652 static std::vector<LogicalTypeID> getFloatingPointTypeIDs();
653 static std::vector<LogicalTypeID> getAllValidLogicTypeIDs();
654 static std::vector<LogicalType> getAllValidLogicTypes();
655 static bool tryGetMaxLogicalType(const LogicalType& left, const LogicalType& right,
656 LogicalType& result);
657 static bool tryGetMaxLogicalType(const std::vector<LogicalType>& types, LogicalType& result);
658
659 // Differs from tryGetMaxLogicalType because it treats string as a maximal type, instead of a
660 // minimal type. as such, it will always succeed.
661 // Also combines structs by the union of their fields. As such, currently, it is not guaranteed
662 // for casting to work from input types to resulting types. Ideally this changes
663 static LogicalType combineTypes(const LogicalType& left, const LogicalType& right);
664 static LogicalType combineTypes(const std::vector<LogicalType>& types);
665
666 // makes a copy of the type with any occurences of ANY replaced with replacement
667 static LogicalType purgeAny(const LogicalType& type, const LogicalType& replacement);
668
669private:
670 static bool tryGetMaxLogicalTypeID(const LogicalTypeID& left, const LogicalTypeID& right,
671 LogicalTypeID& result);
672};
673
674enum class FileVersionType : uint8_t { ORIGINAL = 0, WAL_VERSION = 1 };
675
676} // namespace common
677} // namespace lbug
#define LBUG_API
Definition api.h:25
std::unique_ptr< ExtraTypeInfo > copy() const override
bool operator==(const ExtraTypeInfo &other) const override
ArrayTypeInfo(LogicalType childType, uint64_t numElements)
Definition types.h:479
static std::unique_ptr< ExtraTypeInfo > deserialize(Deserializer &deserializer)
ArrayTypeInfo()
Definition types.h:478
uint64_t getNumElements() const
Definition types.h:482
std::unique_ptr< ExtraTypeInfo > copy() const override
static std::unique_ptr< ExtraTypeInfo > deserialize(Deserializer &deserializer)
bool containsAny() const override
Definition types.h:440
uint32_t scale
Definition types.h:451
bool operator==(const ExtraTypeInfo &other) const override
uint32_t precision
Definition types.h:451
DecimalTypeInfo(uint32_t precision=18, uint32_t scale=3)
Definition types.h:434
void serializeInternal(Serializer &serializer) const override
uint32_t getPrecision() const
Definition types.h:437
uint32_t getScale() const
Definition types.h:438
Definition types.h:390
virtual ~ExtraTypeInfo()=default
virtual std::unique_ptr< ExtraTypeInfo > copy() const =0
virtual bool operator==(const ExtraTypeInfo &other) const =0
void serialize(Serializer &serializer) const
Definition types.h:394
const TARGET * constPtrCast() const
Definition types.h:403
virtual bool containsAny() const =0
virtual void serializeInternal(Serializer &serializer) const =0
std::unique_ptr< ExtraTypeInfo > copy() const override
void serializeInternal(Serializer &serializer) const override
const LogicalType & getChildType() const
Definition types.h:459
bool containsAny() const override
static std::unique_ptr< ExtraTypeInfo > deserialize(Deserializer &deserializer)
LogicalType childType
Definition types.h:473
bool operator==(const ExtraTypeInfo &other) const override
ListTypeInfo(LogicalType childType)
Definition types.h:457
Definition types.h:265
static LogicalType BLOB()
Definition types.h:345
LBUG_API bool operator==(const LogicalType &other) const
static LogicalType TIMESTAMP_MS()
Definition types.h:335
static LogicalType LIST(T &&childType)
Definition types.h:360
static LogicalType BOOL()
Definition types.h:320
static LogicalType INT16()
Definition types.h:324
static LBUG_API LogicalType LIST(LogicalType childType)
static LogicalType TIMESTAMP_TZ()
Definition types.h:337
friend struct DecimalType
Definition types.h:267
static LBUG_API LogicalType UNION(std::vector< StructField > &&fields)
static LogicalType UUID()
Definition types.h:346
static LogicalType ARRAY(T &&childType, uint64_t numElements)
Definition types.h:373
static LogicalType UINT8()
Definition types.h:329
static LogicalType TIMESTAMP_NS()
Definition types.h:334
static LogicalType TIMESTAMP_SEC()
Definition types.h:336
static LogicalType ANY(PhysicalTypeID physicalType)
Definition types.h:314
static LBUG_API LogicalType DECIMAL(uint32_t precision, uint32_t scale)
static LogicalType deserialize(Deserializer &deserializer)
static LBUG_API PhysicalTypeID getPhysicalType(LogicalTypeID logicalType, const std::unique_ptr< ExtraTypeInfo > &extraTypeInfo=nullptr)
bool isInternalType() const
Definition types.h:290
void serialize(Serializer &serializer) const
static LogicalType POINTER()
Definition types.h:347
static LBUG_API std::vector< LogicalType > copy(const std::vector< LogicalType > &types)
static LogicalType HASH()
Definition types.h:321
static LogicalType UINT32()
Definition types.h:327
static LogicalType UINT16()
Definition types.h:328
friend struct LogicalTypeUtils
Definition types.h:266
static LogicalType STRING()
Definition types.h:344
static LogicalType convertFromString(const std::string &str, main::ClientContext *context)
LogicalType()
Definition types.h:275
static bool isBuiltInType(const std::string &str)
static LBUG_API std::vector< LogicalType > copy(const std::vector< LogicalType * > &types)
static LogicalType MAP(T &&keyType, T &&valueType)
Definition types.h:366
static LogicalType DOUBLE()
Definition types.h:331
static LBUG_API LogicalType REL(std::vector< StructField > &&fields)
LBUG_API bool operator!=(const LogicalType &other) const
static LogicalType UINT64()
Definition types.h:326
void setExtraTypeInfo(std::unique_ptr< ExtraTypeInfo > typeInfo)
Definition types.h:296
friend struct StructType
Definition types.h:268
static LogicalType INTERNAL_ID()
Definition types.h:341
static LBUG_API LogicalType MAP(LogicalType keyType, LogicalType valueType)
const ExtraTypeInfo * getExtraTypeInfo() const
Definition types.h:300
static LogicalType INT128()
Definition types.h:330
static LBUG_API LogicalType STRUCT(std::vector< StructField > &&fields)
static LogicalType INTERVAL()
Definition types.h:339
static LogicalType DATE()
Definition types.h:333
friend struct CAPIHelper
Definition types.h:378
LBUG_API std::string toString() const
static LBUG_API LogicalType RECURSIVE_REL(std::vector< StructField > &&fields)
static LogicalType INT64()
Definition types.h:322
EXPLICIT_COPY_DEFAULT_MOVE(LogicalType)
LBUG_API LogicalType(LogicalTypeID typeID, TypeCategory info=TypeCategory::INTERNAL)
static LogicalType FLOAT()
Definition types.h:332
friend struct JavaAPIHelper
Definition types.h:379
static LogicalType UINT128()
Definition types.h:342
PhysicalTypeID getPhysicalType() const
Definition types.h:292
static LogicalType ANY()
Definition types.h:309
friend struct ArrayType
Definition types.h:270
static LogicalType INT8()
Definition types.h:325
static LBUG_API LogicalType NODE(std::vector< StructField > &&fields)
static LogicalType INT32()
Definition types.h:323
LogicalTypeID getLogicalTypeID() const
Definition types.h:288
friend struct ListType
Definition types.h:269
static LBUG_API LogicalType ARRAY(LogicalType childType, uint64_t numElements)
static LogicalType TIMESTAMP()
Definition types.h:338
friend class lbug::processor::ParquetReader
Definition types.h:380
static LogicalType SERIAL()
Definition types.h:343
Definition types.h:497
StructField copy() const
StructField()
Definition types.h:499
bool operator==(const StructField &other) const
bool operator!=(const StructField &other) const
Definition types.h:512
const LogicalType & getType() const
Definition types.h:507
StructField(std::string name, LogicalType type)
Definition types.h:500
static StructField deserialize(Deserializer &deserializer)
std::string getName() const
Definition types.h:505
void serialize(Serializer &serializer) const
DELETE_COPY_DEFAULT_MOVE(StructField)
static std::unique_ptr< ExtraTypeInfo > deserialize(Deserializer &deserializer)
std::unique_ptr< ExtraTypeInfo > copy() const override
const StructField & getStructField(const std::string &fieldName) const
StructTypeInfo(const std::vector< std::string > &fieldNames, const std::vector< LogicalType > &fieldTypes)
std::vector< const LogicalType * > getChildrenTypes() const
const std::vector< StructField > & getStructFields() const
bool hasField(const std::string &fieldName) const
bool containsAny() const override
const StructField & getStructField(struct_field_idx_t idx) const
const LogicalType & getChildType(struct_field_idx_t idx) const
StructTypeInfo(std::vector< StructField > &&fields)
bool operator==(const ExtraTypeInfo &other) const override
std::vector< std::string > getChildrenNames() const
struct_field_idx_t getStructFieldIdx(std::string fieldName) const
std::string getTypeName() const
Definition types.h:415
static std::unique_ptr< ExtraTypeInfo > deserialize(Deserializer &deserializer)
bool operator==(const ExtraTypeInfo &other) const override
std::unique_ptr< ExtraTypeInfo > copy() const override
UDTTypeInfo(std::string typeName)
Definition types.h:413
bool containsAny() const override
Definition types.h:417
Contain client side configuration. We make profiler associated per query, so the profiler is not main...
Definition client_context.h:72
Definition types.h:158
Definition types.h:152
Definition types.h:178
Definition types.h:162
Definition types.h:182
Definition types.h:166
Definition types.h:149
Definition types.h:155
Definition types.h:139
Definition client_context.h:25
Definition array_utils.h:7
page_group_idx_t frame_group_idx_t
Definition types.h:40
constexpr offset_t INVALID_LIMIT
Definition types.h:87
constexpr block_idx_t INVALID_BLOCK_IDX
Definition types.h:48
TO ku_dynamic_cast(FROM *old)
Definition cast.h:11
uint32_t list_size_t
Definition types.h:61
uint32_t page_idx_t
Definition types.h:33
uint64_t node_group_idx_t
Definition types.h:55
uint64_t block_idx_t
Definition types.h:47
uint32_t idx_t
Definition types.h:45
uint64_t cardinality_t
Definition types.h:86
constexpr sel_t INVALID_SEL
Definition types.h:31
uint64_t row_idx_t
Definition types.h:52
uint64_t sel_t
Definition types.h:30
uint64_t executor_id_t
Definition types.h:68
struct_field_idx_t union_field_idx_t
Definition types.h:50
uint16_t struct_field_idx_t
Definition types.h:49
std::vector< table_id_t > table_id_vector_t
Definition types.h:73
constexpr idx_t INVALID_IDX
Definition types.h:46
constexpr column_id_t INVALID_COLUMN_ID
Definition types.h:43
constexpr column_id_t ROW_IDX_COLUMN_ID
Definition types.h:44
internalID_t relID_t
Definition types.h:84
constexpr file_idx_t INVALID_FILE_IDX
Definition types.h:38
constexpr offset_t INVALID_OFFSET
Definition types.h:80
internalID_t nodeID_t
Definition types.h:83
uint64_t transaction_t
Definition types.h:66
std::unordered_map< executor_id_t, uint64_t > executor_info
Definition types.h:69
uint32_t column_id_t
Definition types.h:41
uint64_t hash_t
Definition types.h:32
page_idx_t frame_idx_t
Definition types.h:34
uint32_t file_idx_t
Definition types.h:37
std::vector< offset_t > offset_vec_t
Definition types.h:88
uint64_t oid_t
Definition types.h:63
constexpr partition_idx_t INVALID_PARTITION_IDX
Definition types.h:58
constexpr uint32_t UNDEFINED_CAST_COST
Definition types.h:54
constexpr transaction_t INVALID_TRANSACTION
Definition types.h:67
PhysicalTypeID
Definition types.h:230
@ ALP_EXCEPTION_DOUBLE
Definition types.h:248
@ ALP_EXCEPTION_FLOAT
Definition types.h:247
uint64_t sequence_id_t
Definition types.h:62
LogicalTypeID
Definition types.h:184
@ NODE
Definition types.h:186
@ DECIMAL
Definition types.h:212
@ BLOB
Definition types.h:217
@ UINT32
Definition types.h:199
@ INTERVAL
Definition types.h:211
@ LIST
Definition types.h:219
@ RECURSIVE_REL
Definition types.h:188
@ TIMESTAMP_NS
Definition types.h:209
@ UINT16
Definition types.h:200
@ INT64
Definition types.h:194
@ UUID
Definition types.h:226
@ MAP
Definition types.h:222
@ INT16
Definition types.h:196
@ DATE
Definition types.h:205
@ STRING
Definition types.h:216
@ INT32
Definition types.h:195
@ UINT64
Definition types.h:198
@ SERIAL
Definition types.h:191
@ TIMESTAMP
Definition types.h:206
@ ANY
Definition types.h:185
@ INTERNAL_ID
Definition types.h:213
@ POINTER
Definition types.h:224
@ BOOL
Definition types.h:193
@ STRUCT
Definition types.h:221
@ TIMESTAMP_TZ
Definition types.h:210
@ INT128
Definition types.h:202
@ ARRAY
Definition types.h:220
@ UINT128
Definition types.h:214
@ TIMESTAMP_MS
Definition types.h:208
@ TIMESTAMP_SEC
Definition types.h:207
@ FLOAT
Definition types.h:204
@ REL
Definition types.h:187
@ UNION
Definition types.h:223
@ UINT8
Definition types.h:201
@ INT8
Definition types.h:197
@ DOUBLE
Definition types.h:203
std::unordered_map< table_id_t, T > table_id_map_t
Definition types.h:76
oid_t table_id_t
Definition types.h:72
uint32_t property_id_t
Definition types.h:42
constexpr page_idx_t INVALID_PAGE_IDX
Definition types.h:36
uint64_t offset_t
Definition types.h:79
constexpr node_group_idx_t INVALID_NODE_GROUP_IDX
Definition types.h:56
constexpr struct_field_idx_t INVALID_STRUCT_FIELD_IDX
Definition types.h:51
constexpr row_idx_t INVALID_ROW_IDX
Definition types.h:53
constexpr table_id_t INVALID_TABLE_ID
Definition types.h:77
FileVersionType
Definition types.h:674
@ WAL_VERSION
Definition types.h:674
@ ORIGINAL
Definition types.h:674
TypeCategory
Definition types.h:263
@ INTERNAL
Definition types.h:263
@ UDT
Definition types.h:263
uint64_t length_t
Definition types.h:59
constexpr oid_t INVALID_OID
Definition types.h:64
std::unordered_set< table_id_t > table_id_set_t
Definition types.h:74
uint32_t page_offset_t
Definition types.h:35
std::vector< LogicalType > logical_type_vec_t
Definition types.h:558
constexpr length_t INVALID_LENGTH
Definition types.h:60
uint32_t page_group_idx_t
Definition types.h:39
uint64_t partition_idx_t
Definition types.h:57
Definition bind_input.h:16
Definition client_context.h:41
Definition array_utils.h:7
Definition types.h:570
static uint64_t getNumElements(const LogicalType &type)
static const LogicalType & getChildType(const LogicalType &type)
Definition types.h:560
static uint32_t getPrecision(const LogicalType &type)
static std::string insertDecimalPoint(const std::string &value, uint32_t posFromEnd)
static uint32_t getScale(const LogicalType &type)
Definition types.h:566
static const LogicalType & getChildType(const LogicalType &type)
Definition types.h:631
static bool isUnsigned(const LogicalType &dataType)
static std::vector< LogicalType > getAllValidLogicTypes()
static std::string toString(LogicalTypeID dataTypeID)
static bool isNested(LogicalTypeID logicalTypeID)
static bool isUnsigned(const LogicalTypeID &dataType)
static bool isDate(const LogicalType &dataType)
static std::vector< LogicalTypeID > getAllValidComparableLogicalTypes()
static LogicalType purgeAny(const LogicalType &type, const LogicalType &replacement)
static bool isFloatingPoint(const LogicalTypeID &dataType)
static bool isIntegral(const LogicalTypeID &dataType)
static LogicalType combineTypes(const std::vector< LogicalType > &types)
static std::vector< LogicalTypeID > getIntegerTypeIDs()
static bool isNumerical(const LogicalType &dataType)
static std::string toString(const std::vector< LogicalType > &dataTypes)
static bool isTimestamp(const LogicalTypeID &dataType)
static bool isNested(const LogicalType &dataType)
static LogicalType combineTypes(const LogicalType &left, const LogicalType &right)
static bool isTimestamp(const LogicalType &dataType)
static uint32_t getRowLayoutSize(const LogicalType &logicalType)
static std::string toString(const std::vector< LogicalTypeID > &dataTypeIDs)
static std::vector< LogicalTypeID > getAllValidLogicTypeIDs()
static std::vector< LogicalTypeID > getFloatingPointTypeIDs()
static bool tryGetMaxLogicalType(const LogicalType &left, const LogicalType &right, LogicalType &result)
static bool isIntegral(const LogicalType &dataType)
static std::vector< LogicalTypeID > getNumericalLogicalTypeIDs()
static bool isDate(const LogicalTypeID &dataType)
static bool isNumerical(const LogicalTypeID &dataType)
static bool tryGetMaxLogicalType(const std::vector< LogicalType > &types, LogicalType &result)
Definition types.h:598
static const LogicalType & getKeyType(const LogicalType &type)
static const LogicalType & getValueType(const LogicalType &type)
Definition types.h:626
static std::string toString(PhysicalTypeID physicalType)
static uint32_t getFixedTypeSize(PhysicalTypeID physicalType)
Definition types.h:575
static struct_field_idx_t getFieldIdx(const LogicalType &type, const std::string &key)
static const LogicalType & getFieldType(const LogicalType &type, const std::string &key)
static std::vector< const LogicalType * > getFieldTypes(const LogicalType &type)
static std::vector< std::string > getFieldNames(const LogicalType &type)
static const LogicalType & getFieldType(const LogicalType &type, struct_field_idx_t idx)
static uint64_t getNumFields(const LogicalType &type)
static bool hasField(const LogicalType &type, const std::string &key)
static const StructField & getField(const LogicalType &type, struct_field_idx_t idx)
static const std::vector< StructField > & getFields(const LogicalType &type)
static const StructField & getField(const LogicalType &type, const std::string &key)
Definition uuid.h:20
Definition types.h:604
static constexpr char TAG_FIELD_NAME[]
Definition types.h:609
static std::string getFieldName(const LogicalType &type, union_field_idx_t idx)
static const LogicalType & getFieldType(const LogicalType &type, union_field_idx_t idx)
static union_field_idx_t getFieldIdx(const LogicalType &type, const std::string &key)
static constexpr auto TAG_FIELD_TYPE
Definition types.h:607
static constexpr union_field_idx_t TAG_FIELD_IDX
Definition types.h:605
static bool hasField(const LogicalType &type, const std::string &key)
static const LogicalType & getFieldType(const LogicalType &type, const std::string &key)
static uint64_t getNumFields(const LogicalType &type)
static union_field_idx_t getInternalFieldIdx(union_field_idx_t idx)
Definition int128_t.h:21
Definition types.h:90
internalID_t(offset_t offset, table_id_t tableID)
bool operator<(const internalID_t &rhs) const
offset_t offset
Definition types.h:91
bool operator>(const internalID_t &rhs) const
table_id_t tableID
Definition types.h:92
bool operator!=(const internalID_t &rhs) const
bool operator<=(const internalID_t &rhs) const
bool operator==(const internalID_t &rhs) const
bool operator>=(const internalID_t &rhs) const
Definition ku_string.h:12
Definition types.h:114
constexpr list_entry_t(offset_t offset, list_size_t size)
Definition types.h:119
offset_t offset
Definition types.h:115
list_size_t size
Definition types.h:116
constexpr list_entry_t()
Definition types.h:118
Definition types.h:126
list_entry_t entry
Definition types.h:127
Definition types.h:107
uint8_t * value
Definition types.h:111
uint64_t numElements
Definition types.h:110
Definition types.h:122
int64_t pos
Definition types.h:123
Definition uint128_t.h:15
Definition types.h:130
struct_entry_t entry
Definition types.h:131