Kùzu C++ API
Loading...
Searching...
No Matches
constants.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <string_view>
5
6namespace kuzu {
7namespace common {
8
9extern const char* KUZU_VERSION;
10
11constexpr uint64_t DEFAULT_VECTOR_CAPACITY_LOG_2 = 11;
12constexpr uint64_t DEFAULT_VECTOR_CAPACITY = static_cast<uint64_t>(1)
14
15constexpr double DEFAULT_HT_LOAD_FACTOR = 1.5;
16
17// This is the default thread sleep time we use when a thread,
18// e.g., a worker thread is in TaskScheduler, needs to block.
20
21constexpr uint64_t DEFAULT_CHECKPOINT_WAIT_TIMEOUT_IN_MICROS = 5000000;
22
23// Note that some places use std::bit_ceil to calculate resizes,
24// which won't work for values other than 2. If this is changed, those will need to be updated
25constexpr uint64_t CHUNK_RESIZE_RATIO = 2;
26
28 static constexpr char ANONYMOUS[] = "";
29 static constexpr char ID[] = "_ID";
30 static constexpr char LABEL[] = "_LABEL";
31 static constexpr char SRC[] = "_SRC";
32 static constexpr char DST[] = "_DST";
33 static constexpr char DIRECTION[] = "_DIRECTION";
34 static constexpr char LENGTH[] = "_LENGTH";
35 static constexpr char NODES[] = "_NODES";
36 static constexpr char RELS[] = "_RELS";
37 static constexpr char STAR[] = "*";
38 static constexpr char PLACE_HOLDER[] = "_PLACE_HOLDER";
39 static constexpr char MAP_KEY[] = "KEY";
40 static constexpr char MAP_VALUE[] = "VALUE";
41
42 static constexpr std::string_view ROW_OFFSET = "_row_offset";
43 static constexpr std::string_view SRC_OFFSET = "_src_offset";
44 static constexpr std::string_view DST_OFFSET = "_dst_offset";
45};
46
47enum PageSizeClass : uint8_t {
50};
51
52// Currently the system supports files with 2 different pages size, which we refer to as
53// PAGE_4KB_SIZE and PAGE_256KB_SIZE. PAGE_4KB_SIZE is the default size of the page which is the
54// unit of read/write to the database files, such as to store columns or lists. For now, this value
55// cannot be changed. But technically it can change from 2^12 to 2^16. 2^12 lower bound is assuming
56// the OS page size is 4K. 2^16 is because currently we leave 11 fixed number of bits for
57// relOffInPage and the maximum number of bytes needed for an edge is 20 bytes so 11 + log_2(20)
58// = 15.xxx, so certainly over 2^16-size pages, we cannot utilize the page for storing adjacency
59// lists.
61 static constexpr uint64_t PAGE_4KB_SIZE_LOG2 = 12;
62 static constexpr uint64_t PAGE_4KB_SIZE = static_cast<uint64_t>(1) << PAGE_4KB_SIZE_LOG2;
63 // Page size for files with large pages, e.g., temporary files that are used by operators that
64 // may require large amounts of memory.
65 static constexpr uint64_t PAGE_256KB_SIZE_LOG2 = 18;
66 static constexpr uint64_t PAGE_256KB_SIZE = static_cast<uint64_t>(1) << PAGE_256KB_SIZE_LOG2;
67 // If a user does not specify a max size for BM, we by default set the max size of BM to
68 // maxPhyMemSize * DEFAULT_PHY_MEM_SIZE_RATIO_FOR_BM.
69 static constexpr double DEFAULT_PHY_MEM_SIZE_RATIO_FOR_BM = 0.8;
70 // For each PURGE_EVICTION_QUEUE_INTERVAL candidates added to the eviction queue, we will call
71 // `removeNonEvictableCandidates` to remove candidates that are not evictable. See
72 // `EvictionQueue::removeNonEvictableCandidates()` for more details.
73 static constexpr uint64_t EVICTION_QUEUE_PURGING_INTERVAL = 1024;
74// The default max size for a VMRegion.
75#ifdef __32BIT__
76 static constexpr uint64_t DEFAULT_VM_REGION_MAX_SIZE = (uint64_t)1 << 30; // (1GB)
77#else
78 static constexpr uint64_t DEFAULT_VM_REGION_MAX_SIZE = static_cast<uint64_t>(1) << 43; // (8TB)
79#endif
80
81 static constexpr uint64_t DEFAULT_BUFFER_POOL_SIZE_FOR_TESTING = 1ull << 26; // (64MB)
82};
83
85 static constexpr char OVERFLOW_FILE_SUFFIX[] = ".ovf";
86 static constexpr char WAL_FILE_SUFFIX[] = ".wal";
87 static constexpr char SHADOWING_SUFFIX[] = ".shadow";
88 static constexpr char INDEX_FILE_SUFFIX[] = ".hindex";
89 static constexpr char CATALOG_FILE_NAME[] = "catalog.kz";
90 static constexpr char CATALOG_FILE_NAME_FOR_WAL[] = "catalog.shadow";
91 static constexpr char DATA_FILE_NAME[] = "data.kz";
92 static constexpr char METADATA_FILE_NAME[] = "metadata.kz";
93 static constexpr char METADATA_FILE_NAME_FOR_WAL[] = "metadata.shadow";
94 static constexpr char LOCK_FILE_NAME[] = ".lock";
95
96 // The number of pages that we add at one time when we need to grow a file.
97 static constexpr uint64_t PAGE_GROUP_SIZE_LOG2 = 10;
98 static constexpr uint64_t PAGE_GROUP_SIZE = static_cast<uint64_t>(1) << PAGE_GROUP_SIZE_LOG2;
99 static constexpr uint64_t PAGE_IDX_IN_GROUP_MASK =
100 (static_cast<uint64_t>(1) << PAGE_GROUP_SIZE_LOG2) - 1;
101
102 static constexpr uint64_t NODE_GROUP_SIZE_LOG2 = 17; // 64 * 2048 nodes per group
103 static constexpr uint64_t NODE_GROUP_SIZE = static_cast<uint64_t>(1) << NODE_GROUP_SIZE_LOG2;
104 static constexpr uint64_t NUM_VECTORS_PER_NODE_GROUP =
106
107 static constexpr double PACKED_CSR_DENSITY = 0.8;
108 static constexpr double LEAF_LOW_CSR_DENSITY = 0.1;
109 static constexpr double LEAF_HIGH_CSR_DENSITY = 1.0;
110 // The number of CSR lists in a leaf region.
111 static constexpr uint64_t CSR_LEAF_REGION_SIZE_LOG2 = 10;
112 static constexpr uint64_t CSR_LEAF_REGION_SIZE = static_cast<uint64_t>(1)
114
115 static constexpr uint64_t MAX_NUM_ROWS_IN_TABLE = static_cast<uint64_t>(1) << 62;
116};
117
118// Hash Index Configurations
120 static constexpr uint16_t SLOT_CAPACITY_BYTES = 256;
121 static constexpr double MAX_LOAD_FACTOR = 0.8;
122};
123
125 // Initial size of buffer for CSV Reader.
126 static constexpr uint64_t INITIAL_BUFFER_SIZE = 16384;
127 // This means that we will usually read the entirety of the contents of the file we need for a
128 // block in one read request. It is also very small, which means we can parallelize small files
129 // efficiently.
130 static constexpr uint64_t PARALLEL_BLOCK_SIZE = INITIAL_BUFFER_SIZE / 2;
131
132 static constexpr const char* BOOL_CSV_PARSING_OPTIONS[] = {"HEADER", "PARALLEL"};
133 static constexpr bool DEFAULT_CSV_HAS_HEADER = false;
134 static constexpr bool DEFAULT_CSV_PARALLEL = true;
135
136 // Default configuration for csv file parsing
137 static constexpr const char* STRING_CSV_PARSING_OPTIONS[] = {"ESCAPE", "DELIM", "QUOTE"};
138 static constexpr char DEFAULT_CSV_ESCAPE_CHAR = '"';
139 static constexpr char DEFAULT_CSV_DELIMITER = ',';
140 static constexpr char DEFAULT_CSV_QUOTE_CHAR = '"';
141 static constexpr char DEFAULT_CSV_LIST_BEGIN_CHAR = '[';
142 static constexpr char DEFAULT_CSV_LIST_END_CHAR = ']';
143 static constexpr char DEFAULT_CSV_LINE_BREAK = '\n';
144 static constexpr const char* ROW_IDX_COLUMN_NAME = "ROW_IDX";
145 static constexpr uint64_t PANDAS_PARTITION_COUNT = 50 * DEFAULT_VECTOR_CAPACITY;
146
147 static constexpr const char* INT_CSV_PARSING_OPTIONS[] = {"SKIP"};
148 static constexpr uint64_t DEFAULT_CSV_SKIP_NUM = 0;
149};
150
152 static constexpr char IN_MEMORY_OPTION[] = "IN_MEMORY";
153 static constexpr char STRICT_OPTION[] = "STRICT";
154};
155
157 static constexpr double NON_EQUALITY_PREDICATE_SELECTIVITY = 0.1;
158 static constexpr double EQUALITY_PREDICATE_SELECTIVITY = 0.01;
159 static constexpr uint64_t BUILD_PENALTY = 2;
160 // Avoid doing probe to build SIP if we have to accumulate a probe side that is much bigger than
161 // build side. Also avoid doing build to probe SIP if probe side is not much bigger than build.
162 static constexpr uint64_t SIP_RATIO = 5;
163};
164
166 static constexpr uint64_t NUM_BYTES_FOR_PAYLOAD_IDX = 8;
168 static constexpr uint64_t MIN_LIMIT_RATIO_TO_REDUCE = 2;
169};
170
172 static constexpr uint64_t PARQUET_DEFINE_VALID = 65535;
173 static constexpr const char* PARQUET_MAGIC_WORDS = "PAR1";
174 // We limit the uncompressed page size to 100MB.
175 // The max size in Parquet is 2GB, but we choose a more conservative limit.
176 static constexpr uint64_t MAX_UNCOMPRESSED_PAGE_SIZE = 100000000;
177 // Dictionary pages must be below 2GB. Unlike data pages, there's only one dictionary page.
178 // For this reason we go with a much higher, but still a conservative upper bound of 1GB.
179 static constexpr uint64_t MAX_UNCOMPRESSED_DICT_PAGE_SIZE = 1e9;
180 // The maximum size a key entry in an RLE page takes.
181 static constexpr uint64_t MAX_DICTIONARY_KEY_SIZE = sizeof(uint32_t);
182 // The size of encoding the string length.
183 static constexpr uint64_t STRING_LENGTH_SIZE = sizeof(uint32_t);
184 static constexpr uint64_t MAX_STRING_STATISTICS_SIZE = 10000;
185 static constexpr uint64_t PARQUET_INTERVAL_SIZE = 12;
186 static constexpr uint64_t PARQUET_UUID_SIZE = 16;
187};
188
190 static constexpr const char* DEFAULT_CSV_NEWLINE = "\n";
191 static constexpr const char* DEFAULT_NULL_STR = "";
192 static constexpr bool DEFAULT_FORCE_QUOTE = false;
193 static constexpr uint64_t DEFAULT_CSV_FLUSH_SIZE = 4096 * 8;
194};
195
197 static constexpr char SCHEMA_NAME[] = "schema.cypher";
198 static constexpr char COPY_NAME[] = "copy.cypher";
199};
200
201static constexpr char ATTACHED_KUZU_DB_TYPE[] = "KUZU";
202
203static constexpr char LOCAL_DB_NAME[] = "local(kuzu)";
204
205constexpr auto DECIMAL_PRECISION_LIMIT = 38;
206
207static constexpr char SCAN_JSON_FUNC_NAME[] = "READ_JSON";
208
209} // namespace common
210} // namespace kuzu
constexpr auto DECIMAL_PRECISION_LIMIT
Definition constants.h:205
constexpr uint64_t DEFAULT_VECTOR_CAPACITY
Definition constants.h:12
constexpr uint64_t CHUNK_RESIZE_RATIO
Definition constants.h:25
constexpr double DEFAULT_HT_LOAD_FACTOR
Definition constants.h:15
constexpr uint64_t THREAD_SLEEP_TIME_WHEN_WAITING_IN_MICROS
Definition constants.h:19
const char * KUZU_VERSION
PageSizeClass
Definition constants.h:47
@ PAGE_4KB
Definition constants.h:48
@ PAGE_256KB
Definition constants.h:49
constexpr uint64_t DEFAULT_CHECKPOINT_WAIT_TIMEOUT_IN_MICROS
Definition constants.h:21
constexpr uint64_t DEFAULT_VECTOR_CAPACITY_LOG_2
Definition constants.h:11
Definition alter_type.h:5
Definition constants.h:60
static constexpr uint64_t PAGE_4KB_SIZE_LOG2
Definition constants.h:61
static constexpr uint64_t DEFAULT_VM_REGION_MAX_SIZE
Definition constants.h:78
static constexpr uint64_t DEFAULT_BUFFER_POOL_SIZE_FOR_TESTING
Definition constants.h:81
static constexpr double DEFAULT_PHY_MEM_SIZE_RATIO_FOR_BM
Definition constants.h:69
static constexpr uint64_t PAGE_256KB_SIZE
Definition constants.h:66
static constexpr uint64_t PAGE_256KB_SIZE_LOG2
Definition constants.h:65
static constexpr uint64_t EVICTION_QUEUE_PURGING_INTERVAL
Definition constants.h:73
static constexpr uint64_t PAGE_4KB_SIZE
Definition constants.h:62
Definition constants.h:124
static constexpr const char * STRING_CSV_PARSING_OPTIONS[]
Definition constants.h:137
static constexpr char DEFAULT_CSV_DELIMITER
Definition constants.h:139
static constexpr uint64_t DEFAULT_CSV_SKIP_NUM
Definition constants.h:148
static constexpr uint64_t PANDAS_PARTITION_COUNT
Definition constants.h:145
static constexpr const char * INT_CSV_PARSING_OPTIONS[]
Definition constants.h:147
static constexpr char DEFAULT_CSV_QUOTE_CHAR
Definition constants.h:140
static constexpr char DEFAULT_CSV_LIST_BEGIN_CHAR
Definition constants.h:141
static constexpr const char * BOOL_CSV_PARSING_OPTIONS[]
Definition constants.h:132
static constexpr uint64_t PARALLEL_BLOCK_SIZE
Definition constants.h:130
static constexpr const char * ROW_IDX_COLUMN_NAME
Definition constants.h:144
static constexpr bool DEFAULT_CSV_HAS_HEADER
Definition constants.h:133
static constexpr bool DEFAULT_CSV_PARALLEL
Definition constants.h:134
static constexpr char DEFAULT_CSV_LINE_BREAK
Definition constants.h:143
static constexpr char DEFAULT_CSV_LIST_END_CHAR
Definition constants.h:142
static constexpr uint64_t INITIAL_BUFFER_SIZE
Definition constants.h:126
static constexpr char DEFAULT_CSV_ESCAPE_CHAR
Definition constants.h:138
Definition constants.h:189
static constexpr const char * DEFAULT_CSV_NEWLINE
Definition constants.h:190
static constexpr uint64_t DEFAULT_CSV_FLUSH_SIZE
Definition constants.h:193
static constexpr const char * DEFAULT_NULL_STR
Definition constants.h:191
static constexpr bool DEFAULT_FORCE_QUOTE
Definition constants.h:192
Definition constants.h:119
static constexpr double MAX_LOAD_FACTOR
Definition constants.h:121
static constexpr uint16_t SLOT_CAPACITY_BYTES
Definition constants.h:120
Definition constants.h:196
static constexpr char COPY_NAME[]
Definition constants.h:198
static constexpr char SCHEMA_NAME[]
Definition constants.h:197
Definition constants.h:27
static constexpr char STAR[]
Definition constants.h:37
static constexpr char LENGTH[]
Definition constants.h:34
static constexpr char PLACE_HOLDER[]
Definition constants.h:38
static constexpr std::string_view DST_OFFSET
Definition constants.h:44
static constexpr char RELS[]
Definition constants.h:36
static constexpr char DIRECTION[]
Definition constants.h:33
static constexpr char ID[]
Definition constants.h:29
static constexpr std::string_view SRC_OFFSET
Definition constants.h:43
static constexpr char DST[]
Definition constants.h:32
static constexpr std::string_view ROW_OFFSET
Definition constants.h:42
static constexpr char MAP_KEY[]
Definition constants.h:39
static constexpr char MAP_VALUE[]
Definition constants.h:40
static constexpr char SRC[]
Definition constants.h:31
static constexpr char LABEL[]
Definition constants.h:30
static constexpr char NODES[]
Definition constants.h:35
static constexpr char ANONYMOUS[]
Definition constants.h:28
Definition constants.h:165
static constexpr uint64_t MIN_SIZE_TO_REDUCE
Definition constants.h:167
static constexpr uint64_t MIN_LIMIT_RATIO_TO_REDUCE
Definition constants.h:168
static constexpr uint64_t NUM_BYTES_FOR_PAYLOAD_IDX
Definition constants.h:166
Definition constants.h:171
static constexpr uint64_t PARQUET_DEFINE_VALID
Definition constants.h:172
static constexpr uint64_t PARQUET_UUID_SIZE
Definition constants.h:186
static constexpr uint64_t MAX_UNCOMPRESSED_PAGE_SIZE
Definition constants.h:176
static constexpr uint64_t STRING_LENGTH_SIZE
Definition constants.h:183
static constexpr uint64_t MAX_STRING_STATISTICS_SIZE
Definition constants.h:184
static constexpr uint64_t MAX_DICTIONARY_KEY_SIZE
Definition constants.h:181
static constexpr const char * PARQUET_MAGIC_WORDS
Definition constants.h:173
static constexpr uint64_t MAX_UNCOMPRESSED_DICT_PAGE_SIZE
Definition constants.h:179
static constexpr uint64_t PARQUET_INTERVAL_SIZE
Definition constants.h:185
Definition constants.h:156
static constexpr double NON_EQUALITY_PREDICATE_SELECTIVITY
Definition constants.h:157
static constexpr double EQUALITY_PREDICATE_SELECTIVITY
Definition constants.h:158
static constexpr uint64_t BUILD_PENALTY
Definition constants.h:159
static constexpr uint64_t SIP_RATIO
Definition constants.h:162
Definition constants.h:151
static constexpr char IN_MEMORY_OPTION[]
Definition constants.h:152
static constexpr char STRICT_OPTION[]
Definition constants.h:153
Definition constants.h:84
static constexpr char CATALOG_FILE_NAME_FOR_WAL[]
Definition constants.h:90
static constexpr char CATALOG_FILE_NAME[]
Definition constants.h:89
static constexpr char METADATA_FILE_NAME_FOR_WAL[]
Definition constants.h:93
static constexpr double LEAF_LOW_CSR_DENSITY
Definition constants.h:108
static constexpr char WAL_FILE_SUFFIX[]
Definition constants.h:86
static constexpr char LOCK_FILE_NAME[]
Definition constants.h:94
static constexpr uint64_t MAX_NUM_ROWS_IN_TABLE
Definition constants.h:115
static constexpr uint64_t CSR_LEAF_REGION_SIZE
Definition constants.h:112
static constexpr char METADATA_FILE_NAME[]
Definition constants.h:92
static constexpr uint64_t PAGE_IDX_IN_GROUP_MASK
Definition constants.h:99
static constexpr char OVERFLOW_FILE_SUFFIX[]
Definition constants.h:85
static constexpr uint64_t CSR_LEAF_REGION_SIZE_LOG2
Definition constants.h:111
static constexpr char SHADOWING_SUFFIX[]
Definition constants.h:87
static constexpr uint64_t PAGE_GROUP_SIZE
Definition constants.h:98
static constexpr char DATA_FILE_NAME[]
Definition constants.h:91
static constexpr uint64_t NODE_GROUP_SIZE_LOG2
Definition constants.h:102
static constexpr char INDEX_FILE_SUFFIX[]
Definition constants.h:88
static constexpr double PACKED_CSR_DENSITY
Definition constants.h:107
static constexpr uint64_t PAGE_GROUP_SIZE_LOG2
Definition constants.h:97
static constexpr uint64_t NUM_VECTORS_PER_NODE_GROUP
Definition constants.h:104
static constexpr uint64_t NODE_GROUP_SIZE
Definition constants.h:103
static constexpr double LEAF_HIGH_CSR_DENSITY
Definition constants.h:109