-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
24 changed files
with
271 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
#include <cstdint> | ||
|
||
#include "common/api.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 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 static uint64_t getStorageVersion(); | ||
}; | ||
} // namespace main | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
#include <filesystem> | ||
#include <fstream> | ||
|
||
#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<char*>(&actualVersion), sizeof(actualVersion)); | ||
catalogFile.close(); | ||
ASSERT_EQ(storageVersion, actualVersion); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
tools/java_api/src/test/java/com/kuzudb/test/VersionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
def test_version(): | ||
import kuzu | ||
assert kuzu.version != "" | ||
assert kuzu.storage_version > 0 |