kuzu 0.10.1.dev41__tar.gz → 0.10.1.dev43__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. sdist/PKG-INFO +1 -1
  2. sdist/kuzu-source/CMakeLists.txt +1 -1
  3. sdist/kuzu-source/scripts/antlr4/Cypher.g4 +6 -2
  4. sdist/kuzu-source/scripts/antlr4/hash.md5 +1 -1
  5. sdist/kuzu-source/scripts/export-dbs.py +129 -0
  6. sdist/kuzu-source/src/antlr4/Cypher.g4 +6 -2
  7. sdist/kuzu-source/src/binder/bind/bind_ddl.cpp +8 -13
  8. sdist/kuzu-source/src/catalog/catalog_entry/rel_group_catalog_entry.cpp +14 -2
  9. sdist/kuzu-source/src/catalog/catalog_entry/table_catalog_entry.cpp +10 -5
  10. sdist/kuzu-source/src/catalog/catalog_set.cpp +2 -1
  11. sdist/kuzu-source/src/common/data_chunk/data_chunk_collection.cpp +2 -13
  12. sdist/kuzu-source/src/common/data_chunk/data_chunk_state.cpp +0 -13
  13. sdist/kuzu-source/src/common/data_chunk/sel_vector.cpp +2 -2
  14. sdist/kuzu-source/src/common/serializer/metadata_writer.cpp +16 -6
  15. sdist/kuzu-source/src/common/utils.cpp +0 -40
  16. sdist/kuzu-source/src/common/vector/value_vector.cpp +1 -1
  17. sdist/kuzu-source/src/function/cast_from_string_functions.cpp +12 -8
  18. sdist/kuzu-source/src/function/gds/gds.cpp +1 -0
  19. sdist/kuzu-source/src/function/list/list_slice_function.cpp +10 -12
  20. sdist/kuzu-source/src/function/vector_hash_functions.cpp +22 -22
  21. sdist/kuzu-source/src/include/binder/binder.h +1 -1
  22. sdist/kuzu-source/src/include/binder/ddl/bound_alter_info.h +6 -6
  23. sdist/kuzu-source/src/include/catalog/catalog_entry/rel_group_catalog_entry.h +1 -0
  24. sdist/kuzu-source/src/include/common/constants.h +1 -0
  25. sdist/kuzu-source/src/include/common/data_chunk/data_chunk_collection.h +7 -13
  26. sdist/kuzu-source/src/include/common/data_chunk/data_chunk_state.h +0 -2
  27. sdist/kuzu-source/src/include/common/data_chunk/sel_vector.h +1 -3
  28. sdist/kuzu-source/src/include/common/enums/alter_type.h +2 -0
  29. sdist/kuzu-source/src/include/common/finally_wrapper.h +14 -0
  30. sdist/kuzu-source/src/include/common/serializer/metadata_writer.h +6 -0
  31. sdist/kuzu-source/src/include/common/utils.h +0 -3
  32. sdist/kuzu-source/src/include/function/hash/vector_hash_functions.h +10 -10
  33. sdist/kuzu-source/src/include/function/table/scan_file_function.h +4 -3
  34. sdist/kuzu-source/src/include/main/database.h +4 -1
  35. sdist/kuzu-source/src/include/parser/expression/parsed_function_expression.h +3 -0
  36. sdist/kuzu-source/src/include/parser/transformer.h +2 -0
  37. sdist/kuzu-source/src/include/processor/operator/aggregate/base_aggregate.h +1 -1
  38. sdist/kuzu-source/src/include/processor/operator/ddl/alter.h +1 -1
  39. sdist/kuzu-source/src/include/processor/operator/persistent/reader/csv/base_csv_reader.h +4 -3
  40. sdist/kuzu-source/src/include/processor/operator/persistent/reader/csv/parallel_csv_reader.h +1 -1
  41. sdist/kuzu-source/src/include/processor/operator/persistent/reader/parquet/parquet_reader.h +1 -1
  42. sdist/kuzu-source/src/include/processor/operator/persistent/rel_batch_insert.h +4 -0
  43. sdist/kuzu-source/src/include/processor/operator/physical_operator.h +0 -2
  44. sdist/kuzu-source/src/include/processor/operator/scan/scan_node_table.h +1 -1
  45. sdist/kuzu-source/src/include/processor/result/base_hash_table.h +1 -2
  46. sdist/kuzu-source/src/include/storage/buffer_manager/buffer_manager.h +2 -0
  47. sdist/kuzu-source/src/include/storage/buffer_manager/page_state.h +9 -0
  48. sdist/kuzu-source/src/include/storage/buffer_manager/spiller.h +1 -1
  49. sdist/kuzu-source/src/include/storage/checkpointer.h +5 -2
  50. sdist/kuzu-source/src/include/storage/free_space_manager.h +5 -0
  51. sdist/kuzu-source/src/include/storage/index/hash_index.h +9 -0
  52. sdist/kuzu-source/src/include/storage/local_storage/local_hash_index.h +2 -0
  53. sdist/kuzu-source/src/include/storage/overflow_file.h +2 -4
  54. sdist/kuzu-source/src/include/storage/page_manager.h +4 -0
  55. sdist/kuzu-source/src/include/storage/storage_utils.h +0 -2
  56. sdist/kuzu-source/src/include/storage/table/column.h +27 -54
  57. sdist/kuzu-source/src/include/storage/table/column_reader_writer.h +11 -14
  58. sdist/kuzu-source/src/include/storage/table/dictionary_column.h +10 -14
  59. sdist/kuzu-source/src/include/storage/table/in_memory_exception_chunk.h +2 -2
  60. sdist/kuzu-source/src/include/storage/table/list_column.h +19 -25
  61. sdist/kuzu-source/src/include/storage/table/node_group.h +2 -2
  62. sdist/kuzu-source/src/include/storage/table/node_group_collection.h +1 -1
  63. sdist/kuzu-source/src/include/storage/table/node_table.h +2 -0
  64. sdist/kuzu-source/src/include/storage/table/string_column.h +15 -17
  65. sdist/kuzu-source/src/include/storage/table/struct_column.h +9 -11
  66. sdist/kuzu-source/src/include/storage/table/table.h +1 -1
  67. sdist/kuzu-source/src/include/transaction/transaction.h +2 -1
  68. sdist/kuzu-source/src/main/database.cpp +4 -2
  69. sdist/kuzu-source/src/main/db_config.cpp +2 -2
  70. sdist/kuzu-source/src/parser/expression/parsed_function_expression.cpp +6 -1
  71. sdist/kuzu-source/src/parser/transform/transform_ddl.cpp +42 -17
  72. sdist/kuzu-source/src/parser/transform/transform_expression.cpp +4 -4
  73. sdist/kuzu-source/src/processor/operator/aggregate/aggregate_hash_table.cpp +3 -3
  74. sdist/kuzu-source/src/processor/operator/aggregate/base_aggregate.cpp +0 -11
  75. sdist/kuzu-source/src/processor/operator/aggregate/hash_aggregate.cpp +1 -1
  76. sdist/kuzu-source/src/processor/operator/aggregate/simple_aggregate.cpp +3 -3
  77. sdist/kuzu-source/src/processor/operator/ddl/alter.cpp +86 -46
  78. sdist/kuzu-source/src/processor/operator/persistent/node_batch_insert.cpp +15 -6
  79. sdist/kuzu-source/src/processor/operator/persistent/reader/csv/base_csv_reader.cpp +1 -1
  80. sdist/kuzu-source/src/processor/operator/persistent/reader/csv/serial_csv_reader.cpp +2 -0
  81. sdist/kuzu-source/src/processor/operator/persistent/reader/parquet/parquet_reader.cpp +1 -1
  82. sdist/kuzu-source/src/processor/operator/persistent/rel_batch_insert.cpp +1 -1
  83. sdist/kuzu-source/src/processor/operator/physical_operator.cpp +1 -7
  84. sdist/kuzu-source/src/processor/result/base_hash_table.cpp +1 -2
  85. sdist/kuzu-source/src/storage/buffer_manager/buffer_manager.cpp +14 -4
  86. sdist/kuzu-source/src/storage/buffer_manager/spiller.cpp +6 -5
  87. sdist/kuzu-source/src/storage/checkpointer.cpp +67 -42
  88. sdist/kuzu-source/src/storage/file_handle.cpp +2 -2
  89. sdist/kuzu-source/src/storage/free_space_manager.cpp +64 -14
  90. sdist/kuzu-source/src/storage/overflow_file.cpp +2 -5
  91. sdist/kuzu-source/src/storage/page_manager.cpp +4 -0
  92. sdist/kuzu-source/src/storage/storage_manager.cpp +15 -9
  93. sdist/kuzu-source/src/storage/storage_utils.cpp +0 -20
  94. sdist/kuzu-source/src/storage/table/column.cpp +38 -44
  95. sdist/kuzu-source/src/storage/table/column_chunk.cpp +5 -5
  96. sdist/kuzu-source/src/storage/table/column_reader_writer.cpp +52 -60
  97. sdist/kuzu-source/src/storage/table/csr_chunked_node_group.cpp +2 -4
  98. sdist/kuzu-source/src/storage/table/csr_node_group.cpp +1 -1
  99. sdist/kuzu-source/src/storage/table/dictionary_column.cpp +18 -20
  100. sdist/kuzu-source/src/storage/table/in_memory_exception_chunk.cpp +3 -4
  101. sdist/kuzu-source/src/storage/table/list_column.cpp +58 -69
  102. sdist/kuzu-source/src/storage/table/node_group.cpp +4 -4
  103. sdist/kuzu-source/src/storage/table/node_table.cpp +25 -3
  104. sdist/kuzu-source/src/storage/table/string_column.cpp +29 -32
  105. sdist/kuzu-source/src/storage/table/struct_column.cpp +18 -20
  106. sdist/kuzu-source/src/storage/wal/wal_record.cpp +14 -5
  107. sdist/kuzu-source/src/storage/wal/wal_replayer.cpp +38 -15
  108. sdist/kuzu-source/third_party/antlr4_cypher/cypher_parser.cpp +3226 -3117
  109. sdist/kuzu-source/third_party/antlr4_cypher/include/cypher_parser.h +65 -46
  110. sdist/kuzu-source/tools/java_api/src/jni/kuzu_java.cpp +54 -15
  111. sdist/kuzu-source/tools/java_api/src/test/java/com/kuzudb/ValueTest.java +41 -2
  112. sdist/kuzu-source/tools/python_api/src_cpp/py_connection.cpp +43 -0
  113. sdist/kuzu.egg-info/PKG-INFO +1 -1
  114. sdist/pyproject.toml +1 -1
sdist/PKG-INFO CHANGED
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kuzu
3
- Version: 0.10.1.dev41
3
+ Version: 0.10.1.dev43
4
4
  Summary: Highly scalable, extremely fast, easy-to-use embeddable graph database
5
5
  Home-page: https://github.com/kuzudb/kuzu
6
6
  License: MIT License
@@ -1,6 +1,6 @@
1
1
  cmake_minimum_required(VERSION 3.15)
2
2
 
3
- project(Kuzu VERSION 0.10.1.41 LANGUAGES CXX C)
3
+ project(Kuzu VERSION 0.10.1.43 LANGUAGES CXX C)
4
4
 
5
5
  option(SINGLE_THREADED "Single-threaded mode" FALSE)
6
6
  if(SINGLE_THREADED)
@@ -385,7 +385,8 @@ kU_AlterOptions
385
385
  | kU_DropProperty
386
386
  | kU_RenameTable
387
387
  | kU_RenameProperty
388
- | kU_AddFromToConnection;
388
+ | kU_AddFromToConnection
389
+ | kU_DropFromToConnection;
389
390
 
390
391
  kU_AddProperty
391
392
  : ADD SP (kU_IfNotExists SP)? oC_PropertyKeyName SP kU_DataType ( SP kU_Default )? ;
@@ -403,7 +404,10 @@ kU_RenameProperty
403
404
  : RENAME SP oC_PropertyKeyName SP TO SP oC_PropertyKeyName ;
404
405
 
405
406
  kU_AddFromToConnection
406
- : ADD SP kU_FromToConnection ;
407
+ : ADD SP (kU_IfNotExists SP)? kU_FromToConnection ;
408
+
409
+ kU_DropFromToConnection
410
+ : DROP SP (kU_IfExists SP)? kU_FromToConnection ;
407
411
 
408
412
  kU_ColumnDefinitions: kU_ColumnDefinition ( SP? ',' SP? kU_ColumnDefinition )* ;
409
413
 
@@ -1 +1 @@
1
- 567a0f306e010f245ff575499552caac
1
+ 8908fae875ccf47f64fa086eefd53a1a
@@ -0,0 +1,129 @@
1
+ import argparse
2
+ import os
3
+ import sys
4
+ import subprocess
5
+ import re
6
+
7
+
8
+ # Get version number like 0.10.0.5.
9
+ def getVersion(executablePath):
10
+ try:
11
+ result = subprocess.run(
12
+ [executablePath, "--version"],
13
+ capture_output=True, text=True, check=True)
14
+ output = result.stdout.strip()
15
+ match = re.search(r"\b(\d+\.\d+\.\d+\.\d+)\b", output)
16
+ if match:
17
+ return match.group(1)
18
+ else:
19
+ print("Version number not found in output.")
20
+ return None
21
+ except subprocess.CalledProcessError as e:
22
+ print(f"Error running executable: {e}")
23
+ return None
24
+
25
+
26
+ # Parse schema.cypher and copy.cypher files.
27
+ def createCypherQueries(filePath):
28
+ commands = []
29
+ try:
30
+ with open(filePath, "r") as f:
31
+ for line in f:
32
+ stripped = line.strip()
33
+ if not stripped:
34
+ continue
35
+ if not stripped.endswith(";"):
36
+ stripped += ";"
37
+ commands.append(stripped)
38
+ except Exception:
39
+ pass
40
+ return commands
41
+
42
+
43
+ # Find all datasets that have a schema.cypher and copy.cypher file.
44
+ def findValidDatasetDirs(datasetRoot):
45
+ validDirs = []
46
+
47
+ for root, dirs, files in os.walk(datasetRoot):
48
+ # This script creates a tmp directory with the exported dbs, we should
49
+ # skip it in our search.
50
+ if "tmp" in root.split(os.sep):
51
+ continue
52
+ fileSet = set(files)
53
+
54
+ if "schema.cypher" in fileSet:
55
+ validDirs.append(root)
56
+
57
+ return validDirs
58
+
59
+
60
+ # We must update all relative paths in copy.cypher to use full paths.
61
+ # This expands all matches of a relative path beginning with dataset to a
62
+ # full path.
63
+ def replaceDatasetPaths(command, datasetRoot):
64
+ def replace_match(match):
65
+ quote = match.group(1)
66
+ folder = match.group(2) # 'dataset' or 'extension'
67
+ relative_path = match.group(3)
68
+ full_path = os.path.join(datasetRoot, folder, relative_path)
69
+ return f'{quote}{full_path}{quote}'
70
+
71
+ return re.sub(r'(["\'])(dataset|extension)/([^"\']+)\1', replace_match, command)
72
+
73
+
74
+ # Example scripts/export-dbs.py build/debug/tools/shell/kuzu dataset.
75
+ def main():
76
+ parser = argparse.ArgumentParser(description="""Export DBS with
77
+ KUZU shell and dataset paths""")
78
+
79
+ parser.add_argument("executablePath", help="Path to the KUZU shell")
80
+ parser.add_argument("datasetPath", help="Path to the dataset directory")
81
+ args = parser.parse_args()
82
+
83
+ argExecutablePath = os.path.abspath(args.executablePath)
84
+ argDatasetPath = os.path.abspath(args.datasetPath)
85
+
86
+ if not os.path.isfile(argExecutablePath):
87
+ print(f"Error: Executable not found at {argExecutablePath}")
88
+ return 1
89
+ if not os.path.exists(argDatasetPath):
90
+ print(f"Error: Dataset path not found at {argDatasetPath}")
91
+ return 1
92
+
93
+ version = getVersion(argExecutablePath)
94
+ if not version:
95
+ print(f"Could not pull version number from {argExecutablePath}")
96
+ return 1
97
+
98
+ validDatasets = findValidDatasetDirs(argDatasetPath)
99
+ # This is done to construct a full path to replace the relative paths found
100
+ # in copy.cypher files.
101
+ scriptDir = os.path.dirname(os.path.realpath(__file__))
102
+ rootDir = os.path.abspath(os.path.join(scriptDir, ".."))
103
+ for datasetPath in validDatasets:
104
+ schemaCommands = createCypherQueries(os.path.join(datasetPath, "schema.cypher"))
105
+ copyCommands = createCypherQueries(os.path.join(datasetPath, "copy.cypher"))
106
+ rawCopyCommands = createCypherQueries(os.path.join(datasetPath, "copy.cypher"))
107
+ copyCommands = [replaceDatasetPaths(cmd, rootDir) for cmd in rawCopyCommands]
108
+ combinedCommands = schemaCommands + copyCommands
109
+ datasetName = os.path.relpath(datasetPath, argDatasetPath)
110
+ exportPath = os.path.join(argDatasetPath, "tmp", version, datasetName)
111
+ exportCommand = f"EXPORT DATABASE '{exportPath}' (format=\"csv\", header=true);"
112
+ combinedCommands.append(exportCommand)
113
+ print(f"Exporting {datasetPath} to {exportPath}")
114
+
115
+ process = subprocess.Popen(
116
+ [argExecutablePath],
117
+ stdin=subprocess.PIPE,
118
+ text=True
119
+ )
120
+
121
+ for cmd in combinedCommands:
122
+ process.stdin.write(cmd.strip() + "\n")
123
+ process.stdin.close()
124
+ process.wait()
125
+ return 0
126
+
127
+
128
+ if __name__ == '__main__':
129
+ sys.exit(main())
@@ -148,7 +148,8 @@ kU_AlterOptions
148
148
  | kU_DropProperty
149
149
  | kU_RenameTable
150
150
  | kU_RenameProperty
151
- | kU_AddFromToConnection;
151
+ | kU_AddFromToConnection
152
+ | kU_DropFromToConnection;
152
153
 
153
154
  kU_AddProperty
154
155
  : ADD SP (kU_IfNotExists SP)? oC_PropertyKeyName SP kU_DataType ( SP kU_Default )? ;
@@ -166,7 +167,10 @@ kU_RenameProperty
166
167
  : RENAME SP oC_PropertyKeyName SP TO SP oC_PropertyKeyName ;
167
168
 
168
169
  kU_AddFromToConnection
169
- : ADD SP kU_FromToConnection ;
170
+ : ADD SP (kU_IfNotExists SP)? kU_FromToConnection ;
171
+
172
+ kU_DropFromToConnection
173
+ : DROP SP (kU_IfExists SP)? kU_FromToConnection ;
170
174
 
171
175
  kU_ColumnDefinitions: kU_ColumnDefinition ( SP? ',' SP? kU_ColumnDefinition )* ;
172
176
 
@@ -8,7 +8,6 @@
8
8
  #include "catalog/catalog.h"
9
9
  #include "catalog/catalog_entry/index_catalog_entry.h"
10
10
  #include "catalog/catalog_entry/node_table_catalog_entry.h"
11
- #include "catalog/catalog_entry/rel_group_catalog_entry.h"
12
11
  #include "catalog/catalog_entry/sequence_catalog_entry.h"
13
12
  #include "common/enums/extend_direction_util.h"
14
13
  #include "common/exception/binder.h"
@@ -408,8 +407,9 @@ std::unique_ptr<BoundStatement> Binder::bindAlter(const Statement& statement) {
408
407
  case AlterType::COMMENT: {
409
408
  return bindCommentOn(statement);
410
409
  }
411
- case AlterType::ADD_FROM_TO_CONNECTION: {
412
- return bindAddFromToConnection(statement);
410
+ case AlterType::ADD_FROM_TO_CONNECTION:
411
+ case AlterType::DROP_FROM_TO_CONNECTION: {
412
+ return bindAlterFromToConnection(statement);
413
413
  }
414
414
  default: {
415
415
  KU_UNREACHABLE;
@@ -491,7 +491,8 @@ std::unique_ptr<BoundStatement> Binder::bindCommentOn(const Statement& statement
491
491
  return std::make_unique<BoundAlter>(std::move(boundInfo));
492
492
  }
493
493
 
494
- std::unique_ptr<BoundStatement> Binder::bindAddFromToConnection(const Statement& statement) const {
494
+ std::unique_ptr<BoundStatement> Binder::bindAlterFromToConnection(
495
+ const Statement& statement) const {
495
496
  auto& alter = statement.constCast<Alter>();
496
497
  auto info = alter.getInfo();
497
498
  auto extraInfo = info->extraInfo->constPtrCast<ExtraAddFromToConnection>();
@@ -500,15 +501,9 @@ std::unique_ptr<BoundStatement> Binder::bindAddFromToConnection(const Statement&
500
501
  auto dstTableEntry = bindNodeTableEntry(extraInfo->dstTableName);
501
502
  auto srcTableID = srcTableEntry->getTableID();
502
503
  auto dstTableID = dstTableEntry->getTableID();
503
- auto relGroupEntry = bindRelGroupEntries({tableName})[0]->constPtrCast<RelGroupCatalogEntry>();
504
- if (relGroupEntry->hasRelEntryInfo(srcTableID, dstTableID)) {
505
- throw BinderException{
506
- common::stringFormat("Node table pair: {}->{} already exists in the {} table.",
507
- srcTableEntry->getName(), dstTableEntry->getName(), tableName)};
508
- }
509
- auto boundExtraInfo = std::make_unique<BoundExtraAddFromToConnection>(srcTableID, dstTableID);
510
- auto boundInfo = BoundAlterInfo(AlterType::ADD_FROM_TO_CONNECTION, tableName,
511
- std::move(boundExtraInfo), info->onConflict);
504
+ auto boundExtraInfo = std::make_unique<BoundExtraAlterFromToConnection>(srcTableID, dstTableID);
505
+ auto boundInfo =
506
+ BoundAlterInfo(info->type, tableName, std::move(boundExtraInfo), info->onConflict);
512
507
  return std::make_unique<BoundAlter>(std::move(boundInfo));
513
508
  }
514
509
 
@@ -14,11 +14,23 @@ using namespace kuzu::main;
14
14
  namespace kuzu {
15
15
  namespace catalog {
16
16
 
17
- void RelGroupCatalogEntry::addFromToConnection(common::table_id_t srcTableID,
18
- common::table_id_t dstTableID, common::oid_t oid) {
17
+ void RelGroupCatalogEntry::addFromToConnection(table_id_t srcTableID, table_id_t dstTableID,
18
+ oid_t oid) {
19
19
  relTableInfos.emplace_back(NodeTableIDPair{srcTableID, dstTableID}, oid);
20
20
  }
21
21
 
22
+ void RelGroupCatalogEntry::dropFromToConnection(table_id_t srcTableID, table_id_t dstTableID) {
23
+ auto tmpInfos = relTableInfos;
24
+ relTableInfos.clear();
25
+ for (auto& tmpInfo : tmpInfos) {
26
+ if (tmpInfo.nodePair.srcTableID == srcTableID &&
27
+ tmpInfo.nodePair.dstTableID == dstTableID) {
28
+ continue;
29
+ }
30
+ relTableInfos.emplace_back(tmpInfo);
31
+ }
32
+ }
33
+
22
34
  void RelTableCatalogInfo::serialize(Serializer& ser) const {
23
35
  ser.writeDebuggingInfo("nodePair");
24
36
  ser.serializeValue(nodePair);
@@ -38,11 +38,16 @@ std::unique_ptr<TableCatalogEntry> TableCatalogEntry::alter(transaction_t timest
38
38
  newEntry->setComment(commentInfo.comment);
39
39
  } break;
40
40
  case AlterType::ADD_FROM_TO_CONNECTION: {
41
- auto& fromToConnectionInfo =
42
- *alterInfo.extraInfo->constPtrCast<BoundExtraAddFromToConnection>();
43
- newEntry->ptrCast<RelGroupCatalogEntry>()->addFromToConnection(
44
- fromToConnectionInfo.srcTableID, fromToConnectionInfo.dstTableID,
45
- tables->getNextOIDNoLock());
41
+ auto& connectionInfo =
42
+ *alterInfo.extraInfo->constPtrCast<BoundExtraAlterFromToConnection>();
43
+ newEntry->ptrCast<RelGroupCatalogEntry>()->addFromToConnection(connectionInfo.fromTableID,
44
+ connectionInfo.toTableID, tables->getNextOIDNoLock());
45
+ } break;
46
+ case AlterType::DROP_FROM_TO_CONNECTION: {
47
+ auto& connectionInfo =
48
+ *alterInfo.extraInfo->constPtrCast<BoundExtraAlterFromToConnection>();
49
+ newEntry->ptrCast<RelGroupCatalogEntry>()->dropFromToConnection(connectionInfo.fromTableID,
50
+ connectionInfo.toTableID);
46
51
  } break;
47
52
  default: {
48
53
  KU_UNREACHABLE;
@@ -194,7 +194,8 @@ void CatalogSet::alterTableEntry(Transaction* transaction,
194
194
  case AlterType::ADD_PROPERTY:
195
195
  case AlterType::DROP_PROPERTY:
196
196
  case AlterType::RENAME_PROPERTY:
197
- case AlterType::ADD_FROM_TO_CONNECTION: {
197
+ case AlterType::ADD_FROM_TO_CONNECTION:
198
+ case AlterType::DROP_FROM_TO_CONNECTION: {
198
199
  emplaceNoLock(std::move(newEntry));
199
200
  if (transaction->shouldAppendToUndoBuffer()) {
200
201
  transaction->pushAlterCatalogEntry(*this, *entry, alterInfo);
@@ -31,18 +31,7 @@ void DataChunkCollection::append(DataChunk& chunk) {
31
31
  }
32
32
  }
33
33
 
34
- void DataChunkCollection::merge(DataChunk chunk) {
35
- if (chunks.empty()) {
36
- initTypes(chunk);
37
- }
38
- KU_ASSERT(chunk.getNumValueVectors() == types.size());
39
- for (auto vectorIdx = 0u; vectorIdx < chunk.getNumValueVectors(); vectorIdx++) {
40
- KU_ASSERT(chunk.getValueVector(vectorIdx).dataType == types[vectorIdx]);
41
- }
42
- chunks.push_back(std::move(chunk));
43
- }
44
-
45
- void DataChunkCollection::initTypes(DataChunk& chunk) {
34
+ void DataChunkCollection::initTypes(const DataChunk& chunk) {
46
35
  types.clear();
47
36
  types.reserve(chunk.getNumValueVectors());
48
37
  for (auto vectorIdx = 0u; vectorIdx < chunk.getNumValueVectors(); vectorIdx++) {
@@ -50,7 +39,7 @@ void DataChunkCollection::initTypes(DataChunk& chunk) {
50
39
  }
51
40
  }
52
41
 
53
- void DataChunkCollection::allocateChunk(DataChunk& chunk) {
42
+ void DataChunkCollection::allocateChunk(const DataChunk& chunk) {
54
43
  if (chunks.empty()) {
55
44
  types.reserve(chunk.getNumValueVectors());
56
45
  for (auto vectorIdx = 0u; vectorIdx < chunk.getNumValueVectors(); vectorIdx++) {
@@ -1,8 +1,6 @@
1
1
  #include "common/data_chunk/data_chunk_state.h"
2
2
 
3
- #include "common/data_chunk/sel_vector.h"
4
3
  #include "common/system_config.h"
5
- #include "common/types/types.h"
6
4
 
7
5
  namespace kuzu {
8
6
  namespace common {
@@ -16,16 +14,5 @@ std::shared_ptr<DataChunkState> DataChunkState::getSingleValueDataChunkState() {
16
14
  return state;
17
15
  }
18
16
 
19
- void DataChunkState::slice(offset_t offset) {
20
- // NOTE: this operation has performance penalty. Ideally we should directly modify selVector
21
- // instead of creating a new one.
22
- auto slicedSelVector = std::make_shared<SelectionVector>(DEFAULT_VECTOR_CAPACITY);
23
- for (auto i = 0u; i < selVector->getSelSize() - offset; i++) {
24
- slicedSelVector->getMutableBuffer()[i] = selVector->operator[](i + offset);
25
- }
26
- slicedSelVector->setToFiltered(selVector->getSelSize() - offset);
27
- selVector = std::move(slicedSelVector);
28
- }
29
-
30
17
  } // namespace common
31
18
  } // namespace kuzu
@@ -18,8 +18,8 @@ static const std::array<sel_t, DEFAULT_VECTOR_CAPACITY> INCREMENTAL_SELECTED_POS
18
18
  return selectedPos;
19
19
  }();
20
20
 
21
- SelectionView::SelectionView(sel_t startPos, sel_t selectedSize)
22
- : selectedPositions{INCREMENTAL_SELECTED_POS.data() + startPos}, selectedSize{selectedSize},
21
+ SelectionView::SelectionView(sel_t selectedSize)
22
+ : selectedPositions{INCREMENTAL_SELECTED_POS.data()}, selectedSize{selectedSize},
23
23
  state{State::STATIC} {}
24
24
 
25
25
  SelectionVector::SelectionVector() : SelectionVector{DEFAULT_VECTOR_CAPACITY} {}
@@ -31,24 +31,34 @@ void MetaWriter::write(const uint8_t* data, uint64_t size) {
31
31
 
32
32
  storage::PageRange MetaWriter::flush(storage::FileHandle* fileHandle,
33
33
  storage::ShadowFile& shadowFile) const {
34
- auto numPagesToFlush = pages.size();
34
+ auto numPagesToFlush = getNumPagesToFlush();
35
35
  auto pageManager = fileHandle->getPageManager();
36
- auto numPages = fileHandle->getNumPages();
37
36
  auto pageRange = pageManager->allocatePageRange(numPagesToFlush);
38
- for (auto i = 0u; i < pageRange.numPages; i++) {
39
- auto pageIdx = pageRange.startPageIdx + i;
40
- auto insertingNewPage = pageIdx >= numPages;
37
+ flush(pageRange, fileHandle, shadowFile);
38
+ return pageRange;
39
+ }
40
+
41
+ void MetaWriter::flush(storage::PageRange allocatedPageRange, storage::FileHandle* fileHandle,
42
+ storage::ShadowFile& shadowFile) const {
43
+ KU_ASSERT(allocatedPageRange.numPages >= getNumPagesToFlush());
44
+ auto numPagesBeforeAllocate = allocatedPageRange.startPageIdx;
45
+ for (auto i = 0u; i < getNumPagesToFlush(); i++) {
46
+ auto pageIdx = allocatedPageRange.startPageIdx + i;
47
+ auto insertingNewPage = pageIdx >= numPagesBeforeAllocate;
41
48
  auto shadowPageAndFrame = storage::ShadowUtils::createShadowVersionIfNecessaryAndPinPage(
42
49
  pageIdx, insertingNewPage, *fileHandle, shadowFile);
43
50
  memcpy(shadowPageAndFrame.frame, pages[i]->getData(), KUZU_PAGE_SIZE);
44
51
  shadowFile.getShadowingFH().unpinPage(shadowPageAndFrame.shadowPage);
45
52
  }
46
- return pageRange;
47
53
  }
48
54
 
49
55
  bool MetaWriter::needNewBuffer(uint64_t size) const {
50
56
  return pages.empty() || pageOffset + size > KUZU_PAGE_SIZE;
51
57
  }
52
58
 
59
+ uint64_t MetaWriter::getPageSize() {
60
+ return KUZU_PAGE_SIZE;
61
+ }
62
+
53
63
  } // namespace common
54
64
  } // namespace kuzu
@@ -25,45 +25,5 @@ bool isLittleEndian() {
25
25
  return *(uint8_t*)&testNumber == 1;
26
26
  }
27
27
 
28
- template<>
29
- bool integerFitsIn<int64_t>(int64_t) {
30
- return true;
31
- }
32
-
33
- template<>
34
- bool integerFitsIn<int32_t>(int64_t val) {
35
- return val >= INT32_MIN && val <= INT32_MAX;
36
- }
37
-
38
- template<>
39
- bool integerFitsIn<int16_t>(int64_t val) {
40
- return val >= INT16_MIN && val <= INT16_MAX;
41
- }
42
-
43
- template<>
44
- bool integerFitsIn<int8_t>(int64_t val) {
45
- return val >= INT8_MIN && val <= INT8_MAX;
46
- }
47
-
48
- template<>
49
- bool integerFitsIn<uint64_t>(int64_t val) {
50
- return val >= 0;
51
- }
52
-
53
- template<>
54
- bool integerFitsIn<uint32_t>(int64_t val) {
55
- return val >= 0 && val <= UINT32_MAX;
56
- }
57
-
58
- template<>
59
- bool integerFitsIn<uint16_t>(int64_t val) {
60
- return val >= 0 && val <= UINT16_MAX;
61
- }
62
-
63
- template<>
64
- bool integerFitsIn<uint8_t>(int64_t val) {
65
- return val >= 0 && val <= UINT8_MAX;
66
- }
67
-
68
28
  } // namespace common
69
29
  } // namespace kuzu
@@ -397,7 +397,7 @@ std::unique_ptr<ValueVector> ValueVector::deSerialize(Deserializer& deSer,
397
397
  deSer.validateDebuggingInfo(key, "data_type");
398
398
  auto dataType = LogicalType::deserialize(deSer);
399
399
  auto result = std::make_unique<ValueVector>(std::move(dataType), mm);
400
- result->state = dataChunkState;
400
+ result->setState(dataChunkState);
401
401
  deSer.validateDebuggingInfo(key, "num_values");
402
402
  sel_t numValues = 0;
403
403
  deSer.deserializeValue<sel_t>(numValues);
@@ -296,7 +296,7 @@ template<typename T>
296
296
  static bool splitCStringList(const char* input, uint64_t len, T& state, const CSVOption* option) {
297
297
  auto end = input + len;
298
298
  uint64_t lvl = 1;
299
- bool seen_value = false;
299
+ bool seenValue = false;
300
300
 
301
301
  // locate [
302
302
  skipWhitespace(input, end);
@@ -305,33 +305,37 @@ static bool splitCStringList(const char* input, uint64_t len, T& state, const CS
305
305
  }
306
306
  skipWhitespace(++input, end);
307
307
 
308
- auto start_ptr = input;
308
+ bool justFinishedEntry = true; // true at start
309
+ auto startPtr = input;
309
310
  while (input < end) {
310
311
  auto ch = *input;
311
312
  if (ch == CopyConstants::DEFAULT_CSV_LIST_BEGIN_CHAR) {
312
313
  if (!skipToClose(input, end, ++lvl, CopyConstants::DEFAULT_CSV_LIST_END_CHAR, option)) {
313
314
  return false;
314
315
  }
315
- } else if (ch == '\'' || ch == '"') {
316
+ } else if ((ch == '\'' || ch == '"') && justFinishedEntry) {
317
+ const char* prevInput = input;
316
318
  if (!skipToCloseQuotes(input, end)) {
317
- return false;
319
+ input = prevInput;
318
320
  }
319
321
  } else if (ch == '{') {
320
322
  uint64_t struct_lvl = 0;
321
323
  skipToClose(input, end, struct_lvl, '}', option);
322
324
  } else if (ch == ',' || ch == CopyConstants::DEFAULT_CSV_LIST_END_CHAR) { // split
323
- if (ch != CopyConstants::DEFAULT_CSV_LIST_END_CHAR || start_ptr < input || seen_value) {
324
- state.handleValue(start_ptr, input, option);
325
- seen_value = true;
325
+ if (ch != CopyConstants::DEFAULT_CSV_LIST_END_CHAR || startPtr < input || seenValue) {
326
+ state.handleValue(startPtr, input, option);
327
+ seenValue = true;
326
328
  }
327
329
  if (ch == CopyConstants::DEFAULT_CSV_LIST_END_CHAR) { // last ]
328
330
  lvl--;
329
331
  break;
330
332
  }
331
333
  skipWhitespace(++input, end);
332
- start_ptr = input;
334
+ startPtr = input;
335
+ justFinishedEntry = true;
333
336
  continue;
334
337
  }
338
+ justFinishedEntry = false;
335
339
  input++;
336
340
  }
337
341
  skipWhitespace(++input, end);
@@ -2,6 +2,7 @@
2
2
 
3
3
  #include "binder/binder.h"
4
4
  #include "binder/query/reading_clause/bound_table_function_call.h"
5
+ #include "catalog/catalog.h"
5
6
  #include "catalog/catalog_entry/rel_group_catalog_entry.h"
6
7
  #include "common/exception/binder.h"
7
8
  #include "graph/graph_entry_set.h"
@@ -12,20 +12,18 @@ static void normalizeIndices(int64_t& startIdx, int64_t& endIdx, uint64_t size)
12
12
  if (startIdx < 0) {
13
13
  startIdx = size + startIdx + 1;
14
14
  }
15
- if (endIdx <= 0) {
16
- endIdx = size + endIdx + 1;
17
- }
18
-
19
15
  if (startIdx <= 0) {
20
16
  startIdx = 1;
21
17
  }
22
-
23
- if ((uint64_t)endIdx > size) {
24
- endIdx = size + 1;
18
+ if (endIdx < 0) {
19
+ endIdx = size + endIdx + 1;
25
20
  }
26
-
27
- if (startIdx > endIdx) {
28
- endIdx = startIdx;
21
+ if (endIdx > (int64_t)size) {
22
+ endIdx = size;
23
+ }
24
+ if (endIdx < startIdx) {
25
+ startIdx = 1;
26
+ endIdx = 0;
29
27
  }
30
28
  }
31
29
 
@@ -38,12 +36,12 @@ struct ListSlice {
38
36
  auto startIdx = begin;
39
37
  auto endIdx = end;
40
38
  normalizeIndices(startIdx, endIdx, listEntry.size);
41
- result = common::ListVector::addList(&resultVector, endIdx - startIdx);
39
+ result = common::ListVector::addList(&resultVector, endIdx - startIdx + 1);
42
40
  auto srcDataVector = common::ListVector::getDataVector(&listVector);
43
41
  auto srcPos = listEntry.offset + startIdx - 1;
44
42
  auto dstDataVector = common::ListVector::getDataVector(&resultVector);
45
43
  auto dstPos = result.offset;
46
- for (; startIdx < endIdx; startIdx++) {
44
+ for (; startIdx <= endIdx; startIdx++) {
47
45
  dstDataVector->copyFromVectorData(dstPos++, srcDataVector, srcPos++);
48
46
  }
49
47
  }