Skip to content

Commit ca2299c

Browse files
andyfengHKUray6080
andauthored
remove RDF (#4344)
Co-authored-by: Guodong Jin <guod.jin@gmail.com>
1 parent 51afc59 commit ca2299c

3 files changed

Lines changed: 0 additions & 122 deletions

File tree

src_cpp/node_util.cpp

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,12 @@
11
#include "include/node_util.h"
22

33
#include "common/exception/exception.h"
4-
#include "common/types/blob.h"
54
#include "common/types/value/nested.h"
65
#include "common/types/value/node.h"
7-
#include "common/types/value/rdf_variant.h"
86
#include "common/types/value/recursive_rel.h"
97
#include "common/types/value/rel.h"
108
#include "common/types/value/value.h"
119

12-
Napi::Value ConvertRdfVariantToNapiObject(const Value& value, Napi::Env env) {
13-
auto type = RdfVariant::getLogicalTypeID(&value);
14-
switch (type) {
15-
case LogicalTypeID::STRING: {
16-
auto str = RdfVariant::getValue<std::string>(&value);
17-
return Napi::String::New(env, str.data(), str.size());
18-
}
19-
case LogicalTypeID::BLOB: {
20-
auto blobStr = RdfVariant::getValue<blob_t>(&value).value.getAsString();
21-
return Napi::Buffer<char>::Copy(env, blobStr.c_str(), blobStr.size());
22-
}
23-
case LogicalTypeID::INT64: {
24-
return Napi::Number::New(env, RdfVariant::getValue<int64_t>(&value));
25-
}
26-
case LogicalTypeID::INT32: {
27-
return Napi::Number::New(env, RdfVariant::getValue<int32_t>(&value));
28-
}
29-
case LogicalTypeID::INT16: {
30-
return Napi::Number::New(env, RdfVariant::getValue<int16_t>(&value));
31-
}
32-
case LogicalTypeID::INT8: {
33-
return Napi::Number::New(env, RdfVariant::getValue<int8_t>(&value));
34-
}
35-
case LogicalTypeID::UINT64: {
36-
return Napi::Number::New(env, RdfVariant::getValue<uint64_t>(&value));
37-
}
38-
case LogicalTypeID::UINT32: {
39-
return Napi::Number::New(env, RdfVariant::getValue<uint32_t>(&value));
40-
}
41-
case LogicalTypeID::UINT16: {
42-
return Napi::Number::New(env, RdfVariant::getValue<uint16_t>(&value));
43-
}
44-
case LogicalTypeID::UINT8: {
45-
return Napi::Number::New(env, RdfVariant::getValue<uint8_t>(&value));
46-
}
47-
case LogicalTypeID::DOUBLE: {
48-
return Napi::Number::New(env, RdfVariant::getValue<double>(&value));
49-
}
50-
case LogicalTypeID::FLOAT: {
51-
return Napi::Number::New(env, RdfVariant::getValue<float>(&value));
52-
}
53-
case LogicalTypeID::BOOL: {
54-
return Napi::Boolean::New(env, RdfVariant::getValue<bool>(&value));
55-
}
56-
case LogicalTypeID::DATE: {
57-
auto dateVal = RdfVariant::getValue<date_t>(&value);
58-
// Javascript Date type contains both date and time information. This returns the Date at
59-
// 00:00:00 in UTC timezone.
60-
auto milliseconds = Date::getEpochNanoSeconds(dateVal) / Interval::NANOS_PER_MICRO /
61-
Interval::MICROS_PER_MSEC;
62-
return Napi::Date::New(env, milliseconds);
63-
}
64-
case LogicalTypeID::TIMESTAMP: {
65-
auto timestampVal = RdfVariant::getValue<timestamp_t>(&value);
66-
auto milliseconds = timestampVal.value / Interval::MICROS_PER_MSEC;
67-
return Napi::Date::New(env, milliseconds);
68-
}
69-
case LogicalTypeID::INTERVAL: {
70-
auto intervalVal = RdfVariant::getValue<interval_t>(&value);
71-
// TODO: By default, Node.js returns the difference in milliseconds between two dates, so we
72-
// follow the convention here, but it might not be the best choice in terms of usability.
73-
auto microseconds = intervalVal.micros;
74-
microseconds += intervalVal.days * Interval::MICROS_PER_DAY;
75-
microseconds += intervalVal.months * Interval::MICROS_PER_MONTH;
76-
auto milliseconds = microseconds / Interval::MICROS_PER_MSEC;
77-
return Napi::Number::New(env, milliseconds);
78-
}
79-
default: {
80-
KU_UNREACHABLE;
81-
}
82-
}
83-
}
84-
8510
Napi::Value Util::ConvertToNapiObject(const Value& value, Napi::Env env) {
8611
if (value.isNull()) {
8712
return env.Null();
@@ -270,9 +195,6 @@ Napi::Value Util::ConvertToNapiObject(const Value& value, Napi::Env env) {
270195
}
271196
return napiObj;
272197
}
273-
case LogicalTypeID::RDF_VARIANT: {
274-
return ConvertRdfVariantToNapiObject(value, env);
275-
}
276198
case LogicalTypeID::DECIMAL: {
277199
auto valString = value.toString();
278200
return Napi::String::New(env, valString).ToNumber();

test/common.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,6 @@ const initTests = async () => {
5959
'copy moviesSerial from "../../dataset/tinysnb-serial/vMovies.csv"'
6060
);
6161

62-
const rdfSchema = await fs.readFile(
63-
"../../dataset/rdf/rdf_variant/schema.cypher"
64-
);
65-
const rdfCopy = await fs.readFile(
66-
"../../dataset/rdf/rdf_variant/copy.cypher"
67-
);
68-
for (const file of [rdfSchema, rdfCopy]) {
69-
const lines = file.toString().split("\n");
70-
for (const line of lines) {
71-
if (line.trim().length === 0) {
72-
continue;
73-
}
74-
await conn.query(line);
75-
}
76-
}
77-
7862
global.dbPath = dbPath;
7963
global.db = db;
8064
global.conn = conn;

test/test_data_type.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -501,34 +501,6 @@ describe("MAP", function () {
501501
});
502502
});
503503

504-
describe("RDF_VARIANT", function () {
505-
it("should convert RDF_VARIANT type", async function () {
506-
const queryResult = await conn.query(
507-
"MATCH (a:T_l) RETURN a.val ORDER BY a.id;"
508-
);
509-
const result = await queryResult.getAll();
510-
assert.equal(result.length, 16);
511-
assert.deepEqual(result[0]["a.val"], 12);
512-
assert.deepEqual(result[1]["a.val"], 43);
513-
assert.deepEqual(result[2]["a.val"], 33);
514-
assert.deepEqual(result[3]["a.val"], 2);
515-
assert.deepEqual(result[4]["a.val"], 90);
516-
assert.deepEqual(result[5]["a.val"], 77);
517-
assert.deepEqual(result[6]["a.val"], 12);
518-
assert.deepEqual(result[7]["a.val"], 1);
519-
let val = result[8]["a.val"];
520-
assert.approximately(val, 4.4, EPSILON);
521-
val = result[9]["a.val"];
522-
assert.approximately(val, 1.2, EPSILON);
523-
assert.deepEqual(result[10]["a.val"], true);
524-
assert.deepEqual(result[11]["a.val"], "hhh");
525-
assert.deepEqual(result[12]["a.val"], new Date("2024-01-01"));
526-
assert.deepEqual(result[13]["a.val"], new Date("2024-01-01 11:25:30Z"));
527-
assert.deepEqual(result[14]["a.val"], 172800000);
528-
assert.deepEqual(result[15]["a.val"], new Uint8Array([0xb2]));
529-
});
530-
});
531-
532504
describe("DECIMAL", function () {
533505
it("should convert DECIMAL type", async function () {
534506
const queryResult = await conn.query(

0 commit comments

Comments
 (0)