Skip to content

Commit 75daa3e

Browse files
committed
add int128 and supported functions
1 parent 7b7da54 commit 75daa3e

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ project (kuzujs)
33

44
set(CMAKE_CXX_STANDARD 20)
55

6-
add_definitions(-DNAPI_VERSION=5)
6+
add_definitions(-DNAPI_VERSION=6)
77
add_definitions(-DNODE_RUNTIME=node)
88
add_definitions(-DBUILDING_NODE_EXTENSION)
99

src_cpp/node_util.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ Napi::Value Util::ConvertToNapiObject(const Value& value, Napi::Env env) {
4242
case LogicalTypeID::SERIAL: {
4343
return Napi::Number::New(env, value.getValue<int64_t>());
4444
}
45+
case LogicalTypeID::INT128: {
46+
auto val = value.getValue<kuzu::common::int128_t>();
47+
auto negative = val.high < 0;
48+
if (negative) {
49+
kuzu::common::Int128_t::negateInPlace(val);
50+
}
51+
const uint64_t words[] = {val.low, static_cast<uint64_t>(val.high)};
52+
return Napi::BigInt::New(env, negative, 2, words);
53+
}
4554
case LogicalTypeID::FLOAT: {
4655
return Napi::Number::New(env, value.getValue<float>());
4756
}

test/test_data_type.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ describe("RECURSIVE_REL", function () {
394394
temprature: 32800,
395395
ulength: 33768,
396396
ulevel: 250,
397+
hugedata: BigInt("1844674407370955161811111111"),
397398
grading: null,
398399
rating: null,
399400
location: null,

0 commit comments

Comments
 (0)