From 0202b2b1d23b1076ff629038514cb69c76b6c05d Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Tue, 27 Feb 2024 17:54:01 +0800 Subject: [PATCH 1/9] x --- scripts/update-version-info.py | 46 +++++++++++++++++++++++++++ tools/python_api/src_py/__init__.py | 2 ++ tools/python_api/src_py/_version.py | 2 ++ tools/python_api/test/test_version.py | 6 ++++ 4 files changed, 56 insertions(+) create mode 100644 scripts/update-version-info.py create mode 100644 tools/python_api/src_py/_version.py create mode 100644 tools/python_api/test/test_version.py diff --git a/scripts/update-version-info.py b/scripts/update-version-info.py new file mode 100644 index 0000000000..821a2cee06 --- /dev/null +++ b/scripts/update-version-info.py @@ -0,0 +1,46 @@ +import os + + +def main(): + storage_info_path = os.path.join( + os.path.dirname(__file__), "..", "src", "include", "storage", "storage_info.h" + ) + version_info = eval( + open(storage_info_path) + .read() + .split("getStorageVersionInfo()")[1] + .split("static storage_version_t")[0] + .strip() + .replace("return", "") + .replace("{", "(") + .replace("}", ")") + .replace(";", "") + .strip() + ) + version_info_dict = {} + for ver, storage_ver in version_info: + version_info_dict[ver] = storage_ver + cmake_lists_path = os.path.abspath( + os.path.join(os.path.dirname(__file__), "..", "CMakeLists.txt") + ) + cmake_version = ( + open(cmake_lists_path) + .read() + .split("project(Kuzu VERSION ")[1] + .split(")")[0] + .strip() + .split(" ")[0] + .strip() + ) + if cmake_version in version_info_dict: + storage_version = version_info_dict[cmake_version] + else: + # If the version is not found, it means that the version is a dev version, + # so we default to the latest storage version + storage_version = max(version_info_dict.values()) + print("CMake version: %s" % cmake_version) + print("Storage version: %d" % storage_version) + + +if __name__ == "__main__": + main() diff --git a/tools/python_api/src_py/__init__.py b/tools/python_api/src_py/__init__.py index 6a71049e29..048a4fdd11 100644 --- a/tools/python_api/src_py/__init__.py +++ b/tools/python_api/src_py/__init__.py @@ -50,6 +50,8 @@ from .connection import * from .query_result import * from .types import * +from ._version import __version__ +from ._version import __storage_version__ # Restore the original dlopen flags if sys.platform == "linux": diff --git a/tools/python_api/src_py/_version.py b/tools/python_api/src_py/_version.py new file mode 100644 index 0000000000..3db90e30cd --- /dev/null +++ b/tools/python_api/src_py/_version.py @@ -0,0 +1,2 @@ +__version__ = "0.1.0" +__storage_version__ = 26 \ No newline at end of file diff --git a/tools/python_api/test/test_version.py b/tools/python_api/test/test_version.py new file mode 100644 index 0000000000..1c32d2b5ac --- /dev/null +++ b/tools/python_api/test/test_version.py @@ -0,0 +1,6 @@ +from kuzu import __version__ +from kuzu import __storage_version__ + +def test_version(): + assert __version__ != None + assert __storage_version__ > 0 \ No newline at end of file From 438917b7483c6bcc725a5a69a2e2bea7568c35da Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Tue, 27 Feb 2024 20:23:54 +0800 Subject: [PATCH 2/9] X --- src/c_api/CMakeLists.txt | 3 +- src/c_api/version.cpp | 12 ++++++ src/include/c_api/kuzu.h | 11 +++++ src/include/main/kuzu.h | 1 + src/include/main/version.h | 25 +++++++++++ test/c_api/CMakeLists.txt | 3 +- test/c_api/version_test.cpp | 41 +++++++++++++++++++ .../python_api/src_cpp/include/py_database.h | 4 ++ tools/python_api/src_cpp/py_database.cpp | 17 ++++++-- tools/python_api/src_py/__init__.py | 11 ++++- tools/python_api/src_py/_version.py | 2 - tools/python_api/src_py/database.py | 22 ++++++++++ tools/python_api/test/test_version.py | 8 ++-- 13 files changed, 146 insertions(+), 14 deletions(-) create mode 100644 src/c_api/version.cpp create mode 100644 src/include/main/version.h create mode 100644 test/c_api/version_test.cpp delete mode 100644 tools/python_api/src_py/_version.py diff --git a/src/c_api/CMakeLists.txt b/src/c_api/CMakeLists.txt index 597a328d35..c340744fa2 100644 --- a/src/c_api/CMakeLists.txt +++ b/src/c_api/CMakeLists.txt @@ -8,7 +8,8 @@ add_library(kuzu_c_api prepared_statement.cpp query_result.cpp query_summary.cpp - value.cpp) + value.cpp + version.cpp) set(ALL_OBJECT_FILES ${ALL_OBJECT_FILES} $ diff --git a/src/c_api/version.cpp b/src/c_api/version.cpp new file mode 100644 index 0000000000..3a27a1b727 --- /dev/null +++ b/src/c_api/version.cpp @@ -0,0 +1,12 @@ +#include "main/version.h" + +#include "c_api/helpers.h" +#include "c_api/kuzu.h" + +char* kuzu_get_version() { + return convertToOwnedCString(kuzu::main::Version::getVersion()); +} + +uint64_t kuzu_get_storage_version() { + return kuzu::main::Version::getStorageVersion(); +} \ No newline at end of file diff --git a/src/include/c_api/kuzu.h b/src/include/c_api/kuzu.h index 194e540422..03e78511ae 100644 --- a/src/include/c_api/kuzu.h +++ b/src/include/c_api/kuzu.h @@ -1269,4 +1269,15 @@ KUZU_C_API double kuzu_query_summary_get_compiling_time(kuzu_query_summary* quer KUZU_C_API double kuzu_query_summary_get_execution_time(kuzu_query_summary* query_summary); // TODO: Bind utility functions for kuzu_date_t, kuzu_timestamp_t, and kuzu_interval_t + +// Version +/** + * @brief Returns the version of the Kùzu library. + */ +KUZU_C_API char* kuzu_get_version(); + +/** + * @brief Returns the storage version of the Kùzu library. + */ +KUZU_C_API uint64_t kuzu_get_storage_version(); #undef KUZU_C_API diff --git a/src/include/main/kuzu.h b/src/include/main/kuzu.h index 673dc1009a..11fd568c6e 100644 --- a/src/include/main/kuzu.h +++ b/src/include/main/kuzu.h @@ -18,4 +18,5 @@ #include "main/query_result.h" // IWYU pragma: export #include "main/query_summary.h" // IWYU pragma: export #include "main/storage_driver.h" // IWYU pragma: export +#include "main/version.h" // IWYU pragma: export #include "processor/result/flat_tuple.h" // IWYU pragma: export diff --git a/src/include/main/version.h b/src/include/main/version.h new file mode 100644 index 0000000000..2088a662d4 --- /dev/null +++ b/src/include/main/version.h @@ -0,0 +1,25 @@ +#pragma once + +#include "common/api.h" +#include "storage/storage_info.h" +namespace kuzu { +namespace main { + +struct Version { +public: + /** + * @brief Get the version of the Kùzu library. + * @return const char* The version of the Kùzu library. + */ + KUZU_API inline static const char* getVersion() { return KUZU_CMAKE_VERSION; } + + /** + * @brief Get the storage version of the Kùzu library. + * @return uint64_t The storage version of the Kùzu library. + */ + KUZU_API inline static uint64_t getStorageVersion() { + return storage::StorageVersionInfo::getStorageVersion(); + } +}; +} // namespace main +} // namespace kuzu \ No newline at end of file diff --git a/test/c_api/CMakeLists.txt b/test/c_api/CMakeLists.txt index c19fa59742..3ae3b4779c 100644 --- a/test/c_api/CMakeLists.txt +++ b/test/c_api/CMakeLists.txt @@ -6,4 +6,5 @@ add_kuzu_api_test(c_api_test prepared_statement_test.cpp query_result_test.cpp rdf_variant_test.cpp - value_test.cpp) + value_test.cpp + version_test.cpp) diff --git a/test/c_api/version_test.cpp b/test/c_api/version_test.cpp new file mode 100644 index 0000000000..ff2fcbbe38 --- /dev/null +++ b/test/c_api/version_test.cpp @@ -0,0 +1,41 @@ + +#include +#include + +#include "c_api/kuzu.h" +#include "c_api_test/c_api_test.h" +#include "gtest/gtest.h" +#include "main/version.h" + +using namespace kuzu::main; +using namespace kuzu::testing; +using namespace kuzu::common; + +class CApiVersionTest : public CApiTest { +public: + std::string getInputDir() override { + return TestHelper::appendKuzuRootPath("dataset/tinysnb/"); + } +}; + +TEST_F(CApiVersionTest, GetVersion) { + auto version = kuzu_get_version(); + ASSERT_NE(version, nullptr); + ASSERT_STREQ(version, KUZU_CMAKE_VERSION); + kuzu_destroy_string(version); +} + +TEST_F(CApiVersionTest, GetStorageVersion) { + auto storageVersion = kuzu_get_storage_version(); + auto catalog = std::filesystem::path(databasePath) / "catalog.kz"; + std::ifstream catalogFile; + catalogFile.open(catalog, std::ios::binary); + char magic[5]; + catalogFile.read(magic, 4); + magic[4] = '\0'; + ASSERT_STREQ(magic, "KUZU"); + uint64_t actualVersion; + catalogFile.read(reinterpret_cast(&actualVersion), sizeof(actualVersion)); + catalogFile.close(); + ASSERT_EQ(storageVersion, actualVersion); +} \ No newline at end of file diff --git a/tools/python_api/src_cpp/include/py_database.h b/tools/python_api/src_cpp/include/py_database.h index 1979119a5b..88199775d1 100644 --- a/tools/python_api/src_cpp/include/py_database.h +++ b/tools/python_api/src_cpp/include/py_database.h @@ -16,6 +16,10 @@ class PyDatabase { static void initialize(py::handle& m); + static py::str getVersion(); + + static uint64_t getStorageVersion(); + explicit PyDatabase(const std::string& databasePath, uint64_t bufferPoolSize, uint64_t maxNumThreads, bool compression, bool readOnly, uint64_t maxDBSize); diff --git a/tools/python_api/src_cpp/py_database.cpp b/tools/python_api/src_cpp/py_database.cpp index fbb9783fb7..e8f95afacf 100644 --- a/tools/python_api/src_cpp/py_database.cpp +++ b/tools/python_api/src_cpp/py_database.cpp @@ -1,10 +1,11 @@ #include "include/py_database.h" +#include + #include "include/cached_import/py_cached_import.h" +#include "main/version.h" #include "pandas/pandas_scan.h" -#include - using namespace kuzu::common; void PyDatabase::initialize(py::handle& m) { @@ -28,7 +29,17 @@ void PyDatabase::initialize(py::handle& m) { .def("scan_node_table_as_float", &PyDatabase::scanNodeTable, py::arg("table_name"), py::arg("prop_name"), py::arg("indices"), py::arg("np_array"), py::arg("num_threads")) .def("scan_node_table_as_bool", &PyDatabase::scanNodeTable, py::arg("table_name"), - py::arg("prop_name"), py::arg("indices"), py::arg("np_array"), py::arg("num_threads")); + py::arg("prop_name"), py::arg("indices"), py::arg("np_array"), py::arg("num_threads")) + .def_static("get_version", &PyDatabase::getVersion) + .def_static("get_storage_version", &PyDatabase::getStorageVersion); +} + +py::str PyDatabase::getVersion() { + return py::str(Version::getVersion()); +} + +uint64_t PyDatabase::getStorageVersion() { + return Version::getStorageVersion(); } PyDatabase::PyDatabase(const std::string& databasePath, uint64_t bufferPoolSize, diff --git a/tools/python_api/src_py/__init__.py b/tools/python_api/src_py/__init__.py index 048a4fdd11..899bc394bc 100644 --- a/tools/python_api/src_py/__init__.py +++ b/tools/python_api/src_py/__init__.py @@ -50,8 +50,15 @@ from .connection import * from .query_result import * from .types import * -from ._version import __version__ -from ._version import __storage_version__ + +def __getattr__(name): + if name == "version": + return Database.get_version() + elif name == "storage_version": + return Database.get_storage_version() + else: + raise AttributeError(f"module {__name__!r} has no attribute {name!r}") + # Restore the original dlopen flags if sys.platform == "linux": diff --git a/tools/python_api/src_py/_version.py b/tools/python_api/src_py/_version.py deleted file mode 100644 index 3db90e30cd..0000000000 --- a/tools/python_api/src_py/_version.py +++ /dev/null @@ -1,2 +0,0 @@ -__version__ = "0.1.0" -__storage_version__ = 26 \ No newline at end of file diff --git a/tools/python_api/src_py/database.py b/tools/python_api/src_py/database.py index f12882dc7e..2b0b4470f2 100644 --- a/tools/python_api/src_py/database.py +++ b/tools/python_api/src_py/database.py @@ -50,6 +50,28 @@ def __init__(self, database_path, buffer_pool_size=0, max_num_threads=0, compres self._database = None if not lazy_init: self.init_database() + + def get_version(): + """ + Get the version of the database. + + Returns + ------- + str + The version of the database. + """ + return _kuzu.Database.get_version() + + def get_storage_version(): + """ + Get the storage version of the database. + + Returns + ------- + int + The storage version of the database. + """ + return _kuzu.Database.get_storage_version() def __getstate__(self): state = { diff --git a/tools/python_api/test/test_version.py b/tools/python_api/test/test_version.py index 1c32d2b5ac..f5ed761d02 100644 --- a/tools/python_api/test/test_version.py +++ b/tools/python_api/test/test_version.py @@ -1,6 +1,4 @@ -from kuzu import __version__ -from kuzu import __storage_version__ - def test_version(): - assert __version__ != None - assert __storage_version__ > 0 \ No newline at end of file + import kuzu + assert kuzu.version != "" + assert kuzu.storage_version > 0 From d09bc768b8ce4d17dc36207c2e65022574653e79 Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Tue, 27 Feb 2024 20:42:40 +0800 Subject: [PATCH 3/9] X --- .../nodejs_api/src_cpp/include/node_database.h | 2 ++ tools/nodejs_api/src_cpp/node_database.cpp | 14 ++++++++++++++ tools/nodejs_api/src_js/database.js | 18 +++++++++++++++++- tools/nodejs_api/src_js/index.js | 6 ++++++ tools/nodejs_api/test/test.js | 1 + tools/nodejs_api/test/test_version.js | 13 +++++++++++++ 6 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tools/nodejs_api/test/test_version.js diff --git a/tools/nodejs_api/src_cpp/include/node_database.h b/tools/nodejs_api/src_cpp/include/node_database.h index 2f161d9097..8bbb4ca79a 100644 --- a/tools/nodejs_api/src_cpp/include/node_database.h +++ b/tools/nodejs_api/src_cpp/include/node_database.h @@ -20,6 +20,8 @@ class NodeDatabase : public Napi::ObjectWrap { Napi::Value InitAsync(const Napi::CallbackInfo& info); void InitCppDatabase(); void setLoggingLevel(const Napi::CallbackInfo& info); + static Napi::Value GetVersion(const Napi::CallbackInfo& info); + static Napi::Value GetStorageVersion(const Napi::CallbackInfo& info); private: std::string databasePath; diff --git a/tools/nodejs_api/src_cpp/node_database.cpp b/tools/nodejs_api/src_cpp/node_database.cpp index a6e83aa667..4faf1dea69 100644 --- a/tools/nodejs_api/src_cpp/node_database.cpp +++ b/tools/nodejs_api/src_cpp/node_database.cpp @@ -7,6 +7,8 @@ Napi::Object NodeDatabase::Init(Napi::Env env, Napi::Object exports) { { InstanceMethod("initAsync", &NodeDatabase::InitAsync), InstanceMethod("setLoggingLevel", &NodeDatabase::setLoggingLevel), + StaticMethod("getVersion", &NodeDatabase::GetVersion), + StaticMethod("getStorageVersion", &NodeDatabase::GetStorageVersion), }); exports.Set("NodeDatabase", t); @@ -52,3 +54,15 @@ void NodeDatabase::setLoggingLevel(const Napi::CallbackInfo& info) { auto loggingLevel = info[0].As().Utf8Value(); database->setLoggingLevel(std::move(loggingLevel)); } + +Napi::Value NodeDatabase::GetVersion(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + return Napi::String::New(env, Version::getVersion()); +} + +Napi::Value NodeDatabase::GetStorageVersion(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + return Napi::Number::New(env, Version::getStorageVersion()); +} diff --git a/tools/nodejs_api/src_js/database.js b/tools/nodejs_api/src_js/database.js index cf5b351ba3..344955533c 100644 --- a/tools/nodejs_api/src_js/database.js +++ b/tools/nodejs_api/src_js/database.js @@ -32,12 +32,28 @@ class Database { databasePath, bufferManagerSize, enableCompression, - readOnly, + readOnly ); this._isInitialized = false; this._initPromise = null; } + /** + * Get the version of the library. + * @returns {String} the version of the library. + */ + static getVersion() { + return KuzuNative.NodeDatabase.getVersion(); + } + + /** + * Get the storage version of the library. + * @returns {Number} the storage version of the library. + */ + static getStorageVersion() { + return KuzuNative.NodeDatabase.getStorageVersion(); + } + /** * Initialize the database. Calling this function is optional, as the * database is initialized automatically when the first query is executed. diff --git a/tools/nodejs_api/src_js/index.js b/tools/nodejs_api/src_js/index.js index 3743da07b8..84648ff6f7 100644 --- a/tools/nodejs_api/src_js/index.js +++ b/tools/nodejs_api/src_js/index.js @@ -12,4 +12,10 @@ module.exports = { LoggingLevel, PreparedStatement, QueryResult, + get VERSION() { + return Database.getVersion(); + }, + get STORAGE_VERSION() { + return Database.getStorageVersion(); + }, }; diff --git a/tools/nodejs_api/test/test.js b/tools/nodejs_api/test/test.js index d90281ae18..a5e46e12c6 100644 --- a/tools/nodejs_api/test/test.js +++ b/tools/nodejs_api/test/test.js @@ -17,4 +17,5 @@ describe("kuzu", () => { importTest("Extension loading", "./test_extension.js"); importTest("Query parameters", "./test_parameter.js"); importTest("Concurrent query execution", "./test_concurrency.js"); + importTest("Version", "./test_version.js"); }); diff --git a/tools/nodejs_api/test/test_version.js b/tools/nodejs_api/test/test_version.js new file mode 100644 index 0000000000..00c8090587 --- /dev/null +++ b/tools/nodejs_api/test/test_version.js @@ -0,0 +1,13 @@ +const { assert } = require("chai"); + +describe("Get version", function () { + it("should get the version of the library", function () { + assert.isString(kuzu.VERSION); + assert.notEqual(kuzu.VERSION, ""); + }); + + it("should get the storage version of the library", function () { + assert.isNumber(kuzu.STORAGE_VERSION); + assert.isAtLeast(kuzu.STORAGE_VERSION, 1); + }); +}); From 2c65a3929ee50a18317f12b671cbe35452f3a05d Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Tue, 27 Feb 2024 20:54:07 +0800 Subject: [PATCH 4/9] X --- scripts/update-version-info.py | 46 ------------------- tools/java_api/src/jni/kuzu_java.cpp | 11 ++++- .../src/main/java/com/kuzudb/KuzuNative.java | 4 ++ .../src/main/java/com/kuzudb/KuzuVersion.java | 23 ++++++++++ .../java/com/kuzudb/test/VersionTest.java | 21 +++++++++ 5 files changed, 58 insertions(+), 47 deletions(-) delete mode 100644 scripts/update-version-info.py create mode 100644 tools/java_api/src/main/java/com/kuzudb/KuzuVersion.java create mode 100644 tools/java_api/src/test/java/com/kuzudb/test/VersionTest.java diff --git a/scripts/update-version-info.py b/scripts/update-version-info.py deleted file mode 100644 index 821a2cee06..0000000000 --- a/scripts/update-version-info.py +++ /dev/null @@ -1,46 +0,0 @@ -import os - - -def main(): - storage_info_path = os.path.join( - os.path.dirname(__file__), "..", "src", "include", "storage", "storage_info.h" - ) - version_info = eval( - open(storage_info_path) - .read() - .split("getStorageVersionInfo()")[1] - .split("static storage_version_t")[0] - .strip() - .replace("return", "") - .replace("{", "(") - .replace("}", ")") - .replace(";", "") - .strip() - ) - version_info_dict = {} - for ver, storage_ver in version_info: - version_info_dict[ver] = storage_ver - cmake_lists_path = os.path.abspath( - os.path.join(os.path.dirname(__file__), "..", "CMakeLists.txt") - ) - cmake_version = ( - open(cmake_lists_path) - .read() - .split("project(Kuzu VERSION ")[1] - .split(")")[0] - .strip() - .split(" ")[0] - .strip() - ) - if cmake_version in version_info_dict: - storage_version = version_info_dict[cmake_version] - else: - # If the version is not found, it means that the version is a dev version, - # so we default to the latest storage version - storage_version = max(version_info_dict.values()) - print("CMake version: %s" % cmake_version) - print("Storage version: %d" % storage_version) - - -if __name__ == "__main__": - main() diff --git a/tools/java_api/src/jni/kuzu_java.cpp b/tools/java_api/src/jni/kuzu_java.cpp index 6126363d02..edc7370c5f 100644 --- a/tools/java_api/src/jni/kuzu_java.cpp +++ b/tools/java_api/src/jni/kuzu_java.cpp @@ -166,7 +166,8 @@ JNIEXPORT void JNICALL Java_com_kuzudb_KuzuNative_kuzu_1native_1reload_1library( env->ReleaseStringUTFChars(lib_path, path); if (handle == nullptr) { jclass Exception = env->FindClass("java/lang/Exception"); - auto error = dlerror(); // NOLINT(concurrency-mt-unsafe): load can only be executed in single thread. + auto error = + dlerror(); // NOLINT(concurrency-mt-unsafe): load can only be executed in single thread. env->ThrowNew(Exception, error); } #endif @@ -1254,3 +1255,11 @@ JNIEXPORT jobject JNICALL Java_com_kuzudb_KuzuNative_kuzu_1rdf_1variant_1get_1va return nullptr; } } + +JNIEXPORT jstring JNICALL Java_com_kuzudb_KuzuNative_kuzu_1get_1version(JNIEnv* env, jclass) { + return env->NewStringUTF(Version::getVersion()); +} + +JNIEXPORT jlong JNICALL Java_com_kuzudb_KuzuNative_kuzu_1get_1storage_1version(JNIEnv*, jclass) { + return static_cast(Version::getStorageVersion()); +} diff --git a/tools/java_api/src/main/java/com/kuzudb/KuzuNative.java b/tools/java_api/src/main/java/com/kuzudb/KuzuNative.java index 5bdc24dce2..201cea4ded 100644 --- a/tools/java_api/src/main/java/com/kuzudb/KuzuNative.java +++ b/tools/java_api/src/main/java/com/kuzudb/KuzuNative.java @@ -221,4 +221,8 @@ protected static native long kuzu_data_type_create( protected static native KuzuDataType kuzu_rdf_variant_get_data_type(KuzuValue rdf_variant); protected static native T kuzu_rdf_variant_get_value(KuzuValue rdf_variant); + + protected static native String kuzu_get_version(); + + protected static native long kuzu_get_storage_version(); } diff --git a/tools/java_api/src/main/java/com/kuzudb/KuzuVersion.java b/tools/java_api/src/main/java/com/kuzudb/KuzuVersion.java new file mode 100644 index 0000000000..513c303c17 --- /dev/null +++ b/tools/java_api/src/main/java/com/kuzudb/KuzuVersion.java @@ -0,0 +1,23 @@ +package com.kuzudb; + +/** + * KuzuVersion is a class to get the version of the Kùzu. + */ +public class KuzuVersion { + + /** + * Get the version of the Kùzu. + * @return The version of the Kùzu. + */ + public static String getVersion() { + return KuzuNative.kuzu_get_version(); + } + + /** + * Get the storage version of the Kùzu. + * @return The storage version of the Kùzu. + */ + public static long getStorageVersion() { + return KuzuNative.kuzu_get_storage_version(); + } +} \ No newline at end of file diff --git a/tools/java_api/src/test/java/com/kuzudb/test/VersionTest.java b/tools/java_api/src/test/java/com/kuzudb/test/VersionTest.java new file mode 100644 index 0000000000..2ecdd7e137 --- /dev/null +++ b/tools/java_api/src/test/java/com/kuzudb/test/VersionTest.java @@ -0,0 +1,21 @@ +package com.kuzudb.java_test; + +import com.kuzudb.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class VersionTest extends TestBase { + + @Test + void GetVersion() { + String version = KuzuVersion.getVersion(); + assertTrue(!version.equals("")); + } + + @Test + void GetStorageVersion() { + long storage_version = KuzuVersion.getStorageVersion(); + assertTrue(storage_version > 0); + } +} From 473b9e95c346dc952ff8f2766668d9592ce92519 Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Tue, 27 Feb 2024 20:55:53 +0800 Subject: [PATCH 5/9] X --- src/c_api/version.cpp | 2 +- src/include/main/version.h | 2 +- tools/java_api/src/main/java/com/kuzudb/KuzuVersion.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/c_api/version.cpp b/src/c_api/version.cpp index 3a27a1b727..eefda6e655 100644 --- a/src/c_api/version.cpp +++ b/src/c_api/version.cpp @@ -9,4 +9,4 @@ char* kuzu_get_version() { uint64_t kuzu_get_storage_version() { return kuzu::main::Version::getStorageVersion(); -} \ No newline at end of file +} diff --git a/src/include/main/version.h b/src/include/main/version.h index 2088a662d4..ec92397dce 100644 --- a/src/include/main/version.h +++ b/src/include/main/version.h @@ -22,4 +22,4 @@ struct Version { } }; } // namespace main -} // namespace kuzu \ No newline at end of file +} // namespace kuzu diff --git a/tools/java_api/src/main/java/com/kuzudb/KuzuVersion.java b/tools/java_api/src/main/java/com/kuzudb/KuzuVersion.java index 513c303c17..b329fa74f0 100644 --- a/tools/java_api/src/main/java/com/kuzudb/KuzuVersion.java +++ b/tools/java_api/src/main/java/com/kuzudb/KuzuVersion.java @@ -20,4 +20,4 @@ public static String getVersion() { public static long getStorageVersion() { return KuzuNative.kuzu_get_storage_version(); } -} \ No newline at end of file +} From c343ff0b49c8cbc56554b91c5a9204bb8a9261f3 Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Tue, 27 Feb 2024 20:56:18 +0800 Subject: [PATCH 6/9] X --- test/c_api/version_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/c_api/version_test.cpp b/test/c_api/version_test.cpp index ff2fcbbe38..bc5803dcc5 100644 --- a/test/c_api/version_test.cpp +++ b/test/c_api/version_test.cpp @@ -38,4 +38,4 @@ TEST_F(CApiVersionTest, GetStorageVersion) { catalogFile.read(reinterpret_cast(&actualVersion), sizeof(actualVersion)); catalogFile.close(); ASSERT_EQ(storageVersion, actualVersion); -} \ No newline at end of file +} From 0d58b55ce37cd806ca0a3dda7388d7e889d555c2 Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Tue, 27 Feb 2024 21:06:49 +0800 Subject: [PATCH 7/9] X --- src/include/main/version.h | 8 +++----- src/main/CMakeLists.txt | 1 + src/main/version.cpp | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 src/main/version.cpp diff --git a/src/include/main/version.h b/src/include/main/version.h index ec92397dce..35dabe8eaa 100644 --- a/src/include/main/version.h +++ b/src/include/main/version.h @@ -1,7 +1,7 @@ #pragma once +#include #include "common/api.h" -#include "storage/storage_info.h" namespace kuzu { namespace main { @@ -11,15 +11,13 @@ struct Version { * @brief Get the version of the Kùzu library. * @return const char* The version of the Kùzu library. */ - KUZU_API inline static const char* getVersion() { return KUZU_CMAKE_VERSION; } + KUZU_API static const char* getVersion(); /** * @brief Get the storage version of the Kùzu library. * @return uint64_t The storage version of the Kùzu library. */ - KUZU_API inline static uint64_t getStorageVersion() { - return storage::StorageVersionInfo::getStorageVersion(); - } + KUZU_API static uint64_t getStorageVersion(); }; } // namespace main } // namespace kuzu diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index 619a73f66f..5d9049d143 100644 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -8,6 +8,7 @@ add_library(kuzu_main query_result.cpp query_summary.cpp storage_driver.cpp + version.cpp db_config.cpp) set(ALL_OBJECT_FILES diff --git a/src/main/version.cpp b/src/main/version.cpp new file mode 100644 index 0000000000..04081fc1f4 --- /dev/null +++ b/src/main/version.cpp @@ -0,0 +1,14 @@ +#include "main/version.h" +#include "storage/storage_info.h" + +namespace kuzu { +namespace main { +const char* Version::getVersion() { + return KUZU_CMAKE_VERSION; +} + +uint64_t Version::getStorageVersion() { + return storage::StorageVersionInfo::getStorageVersion(); +} +} // namespace main +} // namespace kuzu \ No newline at end of file From c77f03923a2079256f5e9009188cb473dfe4ec3e Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Tue, 27 Feb 2024 21:09:21 +0800 Subject: [PATCH 8/9] X --- src/main/version.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/version.cpp b/src/main/version.cpp index 04081fc1f4..69e056ca3b 100644 --- a/src/main/version.cpp +++ b/src/main/version.cpp @@ -1,4 +1,5 @@ #include "main/version.h" + #include "storage/storage_info.h" namespace kuzu { From 136b804f8d94032ca38bcb4bde7b29a8619b76a9 Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Tue, 27 Feb 2024 21:12:57 +0800 Subject: [PATCH 9/9] X --- src/main/version.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/version.cpp b/src/main/version.cpp index 69e056ca3b..440a0c2db2 100644 --- a/src/main/version.cpp +++ b/src/main/version.cpp @@ -12,4 +12,4 @@ uint64_t Version::getStorageVersion() { return storage::StorageVersionInfo::getStorageVersion(); } } // namespace main -} // namespace kuzu \ No newline at end of file +} // namespace kuzu