Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit 04afc73

Browse files
Update Kuzu from branch (#55)
Co-authored-by: mewim <14037726+mewim@users.noreply.github.com>
1 parent 73c56b7 commit 04afc73

179 files changed

Lines changed: 4987 additions & 4227 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Package.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ let package = Package(
385385
"kuzu/src/function/pattern/start_end_node_function.cpp",
386386
"kuzu/src/function/scalar_macro_function.cpp",
387387
"kuzu/src/function/sequence/sequence_functions.cpp",
388+
"kuzu/src/function/string/concat_ws.cpp",
388389
"kuzu/src/function/string/init_cap_function.cpp",
389390
"kuzu/src/function/string/levenshtein_function.cpp",
390391
"kuzu/src/function/string/regex_full_match_function.cpp",
@@ -773,6 +774,7 @@ let package = Package(
773774
"kuzu/src/storage/local_storage/local_node_table.cpp",
774775
"kuzu/src/storage/local_storage/local_rel_table.cpp",
775776
"kuzu/src/storage/local_storage/local_storage.cpp",
777+
"kuzu/src/storage/optimistic_allocator.cpp",
776778
"kuzu/src/storage/overflow_file.cpp",
777779
"kuzu/src/storage/page_manager.cpp",
778780
"kuzu/src/storage/predicate/column_predicate.cpp",
@@ -1122,7 +1124,7 @@ let package = Package(
11221124
.headerSearchPath("kuzu/third_party/zstd/include"),
11231125
.define("ANTLR4CPP_STATIC"),
11241126
.define("BM_MALLOC"),
1125-
.define("KUZU_CMAKE_VERSION", to: "\"0.10.0.5\""),
1127+
.define("KUZU_CMAKE_VERSION", to: "\"0.10.0.6\""),
11261128
.define("KUZU_EXPORTS"),
11271129
.define("KUZU_EXTENSION_VERSION", to: "\"0.10.0\""),
11281130
.define("KUZU_ROOT_DIRECTORY", to: "\"kuzu\""),

Sources/cxx-kuzu/include/kuzu.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,11 @@ KUZU_C_API void kuzu_prepared_statement_destroy(kuzu_prepared_statement* prepare
428428
*/
429429
KUZU_C_API bool kuzu_prepared_statement_is_success(kuzu_prepared_statement* prepared_statement);
430430
/**
431+
* @brief Returns the error message if the prepared statement is not prepared successfully.
432+
* The caller is responsible for freeing the returned string with `kuzu_destroy_string`.
431433
* @param prepared_statement The prepared statement instance.
432-
* @return the error message if the statement is not prepared successfully.
434+
* @return the error message if the statement is not prepared successfully or null
435+
* if the statement is prepared successfully.
433436
*/
434437
KUZU_C_API char* kuzu_prepared_statement_get_error_message(
435438
kuzu_prepared_statement* prepared_statement);
@@ -629,8 +632,9 @@ KUZU_C_API void kuzu_query_result_destroy(kuzu_query_result* query_result);
629632
KUZU_C_API bool kuzu_query_result_is_success(kuzu_query_result* query_result);
630633
/**
631634
* @brief Returns the error message if the query is failed.
635+
* The caller is responsible for freeing the returned string with `kuzu_destroy_string`.
632636
* @param query_result The query result instance to check and return error message.
633-
* @return The error message if the query has failed.
637+
* @return The error message if the query has failed, or null if the query is successful.
634638
*/
635639
KUZU_C_API char* kuzu_query_result_get_error_message(kuzu_query_result* query_result);
636640
/**

Sources/cxx-kuzu/kuzu/extension/algo/test/prepare_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "main_test_helper/main_test_helper.h"
1+
#include "api_test/api_test.h"
22

33
using namespace kuzu::common;
44

Sources/cxx-kuzu/kuzu/extension/duckdb/src/include/storage/duckdb_storage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class DuckDBStorageExtension final : public storage::StorageExtension {
1818

1919
static constexpr bool SKIP_UNSUPPORTED_TABLE_DEFAULT_VAL = false;
2020

21-
explicit DuckDBStorageExtension(transaction::Transaction* transaction, main::Database& db);
21+
DuckDBStorageExtension(transaction::Transaction* transaction, main::Database& db);
2222

2323
bool canHandleDB(std::string dbType_) const override;
2424
};

Sources/cxx-kuzu/kuzu/extension/fts/src/function/create_fts_index.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,20 +305,23 @@ static offset_t tableFunc(const TableFuncInput& input, TableFuncOutput&) {
305305
auto onDiskIndex = std::make_unique<FTSIndex>(std::move(indexInfo), std::move(storageInfo),
306306
std::move(ftsConfig), context.clientContext);
307307
if (!context.clientContext->isInMemory()) {
308+
// We currently can't support FSM reclaiming when rolling back checkpoint
309+
// so we don't use the optimistic allocator here
310+
auto& pageAllocator = *storageManager->getDataFH()->getPageManager();
308311
// Checkpoint internal tables.
309312
onDiskIndex->getInternalTableInfo().docTable->checkpoint(context.clientContext,
310-
docTableEntry);
313+
docTableEntry, pageAllocator);
311314
auto termsTableName = FTSUtils::getTermsTableName(bindData.tableID, bindData.indexName);
312315
auto termsTableEntry =
313316
context.clientContext->getCatalog()->getTableCatalogEntry(transaction, termsTableName);
314317
onDiskIndex->getInternalTableInfo().termsTable->checkpoint(context.clientContext,
315-
termsTableEntry);
318+
termsTableEntry, pageAllocator);
316319
auto appearsInTableName =
317320
FTSUtils::getAppearsInTableName(bindData.tableID, bindData.indexName);
318321
auto appearsInTableEntry = context.clientContext->getCatalog()->getTableCatalogEntry(
319322
transaction, appearsInTableName);
320323
onDiskIndex->getInternalTableInfo().appearsInfoTable->checkpoint(context.clientContext,
321-
appearsInTableEntry);
324+
appearsInTableEntry, pageAllocator);
322325
}
323326
nodeTable->addIndex(std::move(onDiskIndex));
324327
transaction->setForceCheckpoint();

Sources/cxx-kuzu/kuzu/extension/fts/src/function/query_fts_bind_data.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include "function/query_fts_bind_data.h"
22

3+
#include "binder/binder.h"
34
#include "binder/expression/expression_util.h"
45
#include "catalog/fts_index_catalog_entry.h"
56
#include "common/exception/binder.h"
67
#include "common/string_utils.h"
7-
#include "function/stem.h"
88
#include "libstemmer.h"
99
#include "re2.h"
1010
#include "storage/storage_manager.h"
@@ -18,17 +18,29 @@ using namespace kuzu::common;
1818
using namespace kuzu::binder;
1919
using namespace kuzu::storage;
2020

21-
QueryFTSOptionalParams::QueryFTSOptionalParams(const binder::expression_vector& optionalParams) {
21+
static std::shared_ptr<Expression> applyImplicitCastingIfNecessary(main::ClientContext* context,
22+
std::shared_ptr<Expression> expr, LogicalType targetType) {
23+
if (expr->getDataType() != targetType) {
24+
Binder binder{context};
25+
expr = binder.getExpressionBinder()->implicitCastIfNecessary(expr, targetType);
26+
expr = binder.getExpressionBinder()->foldExpression(expr);
27+
}
28+
return expr;
29+
}
30+
31+
QueryFTSOptionalParams::QueryFTSOptionalParams(main::ClientContext* context,
32+
const binder::expression_vector& optionalParams) {
2233
for (auto& optionalParam : optionalParams) {
2334
auto paramName = StringUtils::getLower(optionalParam->getAlias());
2435
if (paramName == K::NAME) {
25-
k = optionalParam;
36+
k = applyImplicitCastingIfNecessary(context, optionalParam, LogicalType{K::TYPE});
2637
} else if (paramName == B::NAME) {
27-
b = optionalParam;
38+
b = applyImplicitCastingIfNecessary(context, optionalParam, LogicalType{B::TYPE});
2839
} else if (paramName == Conjunctive::NAME) {
29-
conjunctive = optionalParam;
40+
conjunctive = applyImplicitCastingIfNecessary(context, optionalParam,
41+
LogicalType{Conjunctive::TYPE});
3042
} else if (paramName == TopK::NAME) {
31-
topK = optionalParam;
43+
topK = applyImplicitCastingIfNecessary(context, optionalParam, LogicalType{TopK::TYPE});
3244
} else {
3345
throw common::BinderException{"Unknown optional parameter: " + paramName};
3446
}

Sources/cxx-kuzu/kuzu/extension/fts/src/function/query_fts_index.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,10 @@ static std::unique_ptr<TableFuncBindData> bindFunc(main::ClientContext* context,
409409
KU_ASSERT(index.has_value());
410410
auto& ftsIndex = index.value()->cast<FTSIndex>();
411411
auto& ftsStorageInfo = ftsIndex.getStorageInfo().constCast<FTSStorageInfo>();
412-
auto bindData =
413-
std::make_unique<QueryFTSBindData>(std::move(columns), std::move(graphEntry), nodeOutput,
414-
std::move(query), *ftsIndexEntry, QueryFTSOptionalParams{input->optionalParamsLegacy},
415-
ftsStorageInfo.numDocs, ftsStorageInfo.avgDocLen);
412+
auto bindData = std::make_unique<QueryFTSBindData>(std::move(columns), std::move(graphEntry),
413+
nodeOutput, std::move(query), *ftsIndexEntry,
414+
QueryFTSOptionalParams{context, input->optionalParamsLegacy}, ftsStorageInfo.numDocs,
415+
ftsStorageInfo.avgDocLen);
416416
context->setUseInternalCatalogEntry(false /* useInternalCatalogEntry */);
417417
return bindData;
418418
}

Sources/cxx-kuzu/kuzu/extension/fts/src/include/function/query_fts_bind_data.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ struct QueryFTSOptionalParams {
1414
std::shared_ptr<binder::Expression> conjunctive;
1515
std::shared_ptr<binder::Expression> topK;
1616

17-
explicit QueryFTSOptionalParams(const binder::expression_vector& optionalParams);
17+
QueryFTSOptionalParams(main::ClientContext* context,
18+
const binder::expression_vector& optionalParams);
1819

1920
QueryFTSConfig getConfig() const;
2021
};

Sources/cxx-kuzu/kuzu/extension/fts/src/include/index/fts_index.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ class FTSIndex final : public storage::Index {
3434
storage::StorageManager* storageManager, storage::IndexInfo indexInfo,
3535
std::span<uint8_t> storageInfoBuffer);
3636

37-
std::unique_ptr<InsertState> initInsertState(transaction::Transaction* transaction,
38-
storage::MemoryManager* mm, storage::visible_func isVisible) override;
37+
std::unique_ptr<InsertState> initInsertState(main::ClientContext*,
38+
storage::visible_func isVisible) override;
3939

4040
void insert(transaction::Transaction* transaction, const common::ValueVector& nodeIDVector,
4141
const std::vector<common::ValueVector*>& indexVectors, InsertState& insertState) override;
@@ -45,15 +45,9 @@ class FTSIndex final : public storage::Index {
4545

4646
void delete_(transaction::Transaction* transaction, const common::ValueVector& nodeIDVector,
4747
DeleteState& deleteState) override;
48-
void commitInsert(transaction::Transaction*, const common::ValueVector&,
49-
const std::vector<common::ValueVector*>&, InsertState&) override {
50-
// DO NOTHING.
51-
// For FTS index, insertions are handled when the new tuples are inserted into the base
52-
// table being indexed.
53-
}
5448

55-
void checkpoint(main::ClientContext*, bool forceCheckpointAll) override;
5649
void finalize(main::ClientContext* context) override;
50+
void checkpoint(main::ClientContext*, storage::PageAllocator& pageAllocator) override;
5751

5852
static storage::IndexType getIndexType() {
5953
static const storage::IndexType FTS_INDEX_TYPE{"FTS",

Sources/cxx-kuzu/kuzu/extension/fts/src/include/index/fts_update_state.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ struct FTSInsertState final : storage::Index::InsertState {
3636
storage::NodeTableInsertState termsTableInsertState;
3737
storage::RelTableInsertState appearsInTableInsertState;
3838

39-
FTSInsertState(storage::MemoryManager* mm, transaction::Transaction* transaction,
40-
FTSInternalTableInfo& tableInfo);
39+
FTSInsertState(main::ClientContext* context, FTSInternalTableInfo& tableInfo);
4140
};
4241

4342
struct IndexTableState {

0 commit comments

Comments
 (0)