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