@nxtedition/rocksdb 11.1.7 → 12.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.cc +0 -99
- package/binding.gyp +16 -26
- package/index.js +0 -2
- package/iterator.js +5 -5
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/@nxtedition+rocksdb.node +0 -0
- package/prebuilds/linux-x64/@nxtedition+rocksdb.node +0 -0
- package/regex.js +0 -29
package/binding.cc
CHANGED
|
@@ -18,8 +18,6 @@
|
|
|
18
18
|
#include <rocksdb/table.h>
|
|
19
19
|
#include <rocksdb/write_batch.h>
|
|
20
20
|
|
|
21
|
-
#include <boost/regex.hpp>
|
|
22
|
-
|
|
23
21
|
#include <iostream>
|
|
24
22
|
#include <memory>
|
|
25
23
|
#include <optional>
|
|
@@ -1481,99 +1479,6 @@ NAPI_METHOD(batch_iterate) {
|
|
|
1481
1479
|
return result;
|
|
1482
1480
|
}
|
|
1483
1481
|
|
|
1484
|
-
NAPI_METHOD(regex_init) {
|
|
1485
|
-
NAPI_ARGV(1);
|
|
1486
|
-
|
|
1487
|
-
std::string pattern;
|
|
1488
|
-
NAPI_STATUS_THROWS(GetString(env, argv[0], pattern));
|
|
1489
|
-
|
|
1490
|
-
try {
|
|
1491
|
-
auto regex = std::make_unique<boost::regex>(pattern, boost::regex::optimize | boost::regex::ECMAScript);
|
|
1492
|
-
|
|
1493
|
-
napi_value result;
|
|
1494
|
-
NAPI_STATUS_THROWS(napi_create_external(env, regex.get(), Finalize<boost::regex>, regex.get(), &result));
|
|
1495
|
-
regex.release();
|
|
1496
|
-
|
|
1497
|
-
return result;
|
|
1498
|
-
} catch (const std::exception& e) {
|
|
1499
|
-
napi_throw_error(env, nullptr, e.what());
|
|
1500
|
-
return 0;
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
NAPI_METHOD(regex_test) {
|
|
1505
|
-
NAPI_ARGV(4);
|
|
1506
|
-
|
|
1507
|
-
boost::regex* regex;
|
|
1508
|
-
NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(®ex)));
|
|
1509
|
-
|
|
1510
|
-
rocksdb::Slice value;
|
|
1511
|
-
NAPI_STATUS_THROWS(GetValue(env, argv[1], value));
|
|
1512
|
-
|
|
1513
|
-
int offset = 0;
|
|
1514
|
-
NAPI_STATUS_THROWS(GetValue(env, argv[2], offset));
|
|
1515
|
-
offset = std::max(0, std::min<int>(offset, value.size()));
|
|
1516
|
-
|
|
1517
|
-
int length = 0;
|
|
1518
|
-
NAPI_STATUS_THROWS(GetValue(env, argv[3], length));
|
|
1519
|
-
length = std::max(0, std::min<int>(length, value.size() - offset));
|
|
1520
|
-
|
|
1521
|
-
try {
|
|
1522
|
-
const bool match = boost::regex_search(value.data() + offset, value.data() + offset + length, *regex);
|
|
1523
|
-
|
|
1524
|
-
napi_value result;
|
|
1525
|
-
NAPI_STATUS_THROWS(napi_get_boolean(env, match, &result));
|
|
1526
|
-
|
|
1527
|
-
return result;
|
|
1528
|
-
} catch (const std::exception& e) {
|
|
1529
|
-
napi_throw_error(env, nullptr, e.what());
|
|
1530
|
-
return 0;
|
|
1531
|
-
}
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
|
-
NAPI_METHOD(regex_test_many) {
|
|
1535
|
-
NAPI_ARGV(2);
|
|
1536
|
-
|
|
1537
|
-
boost::regex* regex;
|
|
1538
|
-
NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(®ex)));
|
|
1539
|
-
|
|
1540
|
-
uint32_t count;
|
|
1541
|
-
NAPI_STATUS_THROWS(napi_get_array_length(env, argv[1], &count));
|
|
1542
|
-
|
|
1543
|
-
napi_value result;
|
|
1544
|
-
NAPI_STATUS_THROWS(napi_create_array_with_length(env, count, &result));
|
|
1545
|
-
|
|
1546
|
-
try {
|
|
1547
|
-
std::vector<rocksdb::Slice> keys;
|
|
1548
|
-
keys.resize(count);
|
|
1549
|
-
|
|
1550
|
-
std::vector<bool> matches;
|
|
1551
|
-
matches.resize(count);
|
|
1552
|
-
|
|
1553
|
-
for (uint32_t n = 0; n < count; n++) {
|
|
1554
|
-
napi_value valueElement;
|
|
1555
|
-
NAPI_STATUS_THROWS(napi_get_element(env, argv[1], n, &valueElement));
|
|
1556
|
-
NAPI_STATUS_THROWS(GetValue(env, valueElement, keys[n]))
|
|
1557
|
-
}
|
|
1558
|
-
|
|
1559
|
-
for (uint32_t n = 0; n < count; n++) {
|
|
1560
|
-
matches[n] = boost::regex_search(keys[n].data(), keys[n].data() + keys[n].size(), *regex);
|
|
1561
|
-
}
|
|
1562
|
-
|
|
1563
|
-
for (uint32_t n = 0; n < count; n++) {
|
|
1564
|
-
napi_value element;
|
|
1565
|
-
NAPI_STATUS_THROWS(napi_get_boolean(env, matches[n], &element));
|
|
1566
|
-
NAPI_STATUS_THROWS(napi_set_element(env, result, n, element));
|
|
1567
|
-
}
|
|
1568
|
-
|
|
1569
|
-
return result;
|
|
1570
|
-
} catch (const std::exception& e) {
|
|
1571
|
-
napi_throw_error(env, nullptr, e.what());
|
|
1572
|
-
return 0;
|
|
1573
|
-
}
|
|
1574
|
-
}
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
1482
|
NAPI_INIT() {
|
|
1578
1483
|
NAPI_EXPORT_FUNCTION(db_init);
|
|
1579
1484
|
NAPI_EXPORT_FUNCTION(db_open);
|
|
@@ -1601,8 +1506,4 @@ NAPI_INIT() {
|
|
|
1601
1506
|
NAPI_EXPORT_FUNCTION(batch_merge);
|
|
1602
1507
|
NAPI_EXPORT_FUNCTION(batch_count);
|
|
1603
1508
|
NAPI_EXPORT_FUNCTION(batch_iterate);
|
|
1604
|
-
|
|
1605
|
-
NAPI_EXPORT_FUNCTION(regex_init);
|
|
1606
|
-
NAPI_EXPORT_FUNCTION(regex_test_many);
|
|
1607
|
-
NAPI_EXPORT_FUNCTION(regex_test);
|
|
1608
1509
|
}
|
package/binding.gyp
CHANGED
|
@@ -3,31 +3,21 @@
|
|
|
3
3
|
"targets": [
|
|
4
4
|
{
|
|
5
5
|
"target_name": "leveldown",
|
|
6
|
-
"defines": [
|
|
7
|
-
"BOOST_REGEX_STANDALONE=yes"
|
|
8
|
-
],
|
|
6
|
+
"defines": ["BOOST_REGEX_STANDALONE=yes"],
|
|
9
7
|
"conditions": [
|
|
10
8
|
[
|
|
11
9
|
"OS == 'linux'",
|
|
12
10
|
{
|
|
13
|
-
"cflags": [
|
|
14
|
-
|
|
15
|
-
"-
|
|
16
|
-
"
|
|
17
|
-
"-mavx2",
|
|
18
|
-
"-mbmi",
|
|
19
|
-
"-mlzcnt"
|
|
11
|
+
"cflags": ["-march=znver1"],
|
|
12
|
+
"include_dirs": [
|
|
13
|
+
"/usr/lib/x86_64-linux-gnu/include",
|
|
14
|
+
"/usr/lib/include",
|
|
20
15
|
],
|
|
21
|
-
|
|
22
|
-
"/usr/lib/x86_64-linux-gnu/include",
|
|
23
|
-
"/usr/lib/include",
|
|
24
|
-
# "/usr/local/Cellar/jemalloc/5.3.0/include"
|
|
25
|
-
],
|
|
26
|
-
"ccflags": ["-flto"],
|
|
16
|
+
"ccflags": ["-flto", '-march=znver1'],
|
|
27
17
|
"cflags!": ["-fno-exceptions"],
|
|
28
18
|
"cflags_cc!": ["-fno-exceptions"],
|
|
29
|
-
"ldflags": ["-flto", "-fuse-linker-plugin"]
|
|
30
|
-
}
|
|
19
|
+
"ldflags": ["-flto", "-fuse-linker-plugin"],
|
|
20
|
+
},
|
|
31
21
|
],
|
|
32
22
|
[
|
|
33
23
|
"OS == 'mac'",
|
|
@@ -37,7 +27,7 @@
|
|
|
37
27
|
"-Wno-sign-compare",
|
|
38
28
|
"-Wno-unused-variable",
|
|
39
29
|
"-Wno-unused-function",
|
|
40
|
-
"-Wno-ignored-qualifiers"
|
|
30
|
+
"-Wno-ignored-qualifiers",
|
|
41
31
|
],
|
|
42
32
|
"OTHER_CPLUSPLUSFLAGS": [
|
|
43
33
|
"-mmacosx-version-min=13.4.0",
|
|
@@ -45,18 +35,18 @@
|
|
|
45
35
|
"-fno-omit-frame-pointer",
|
|
46
36
|
"-momit-leaf-frame-pointer",
|
|
47
37
|
"-arch x86_64",
|
|
48
|
-
"-arch arm64"
|
|
38
|
+
"-arch arm64",
|
|
49
39
|
],
|
|
50
40
|
"GCC_ENABLE_CPP_RTTI": "YES",
|
|
51
41
|
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
|
|
52
|
-
"MACOSX_DEPLOYMENT_TARGET": "13.4.0"
|
|
42
|
+
"MACOSX_DEPLOYMENT_TARGET": "13.4.0",
|
|
53
43
|
}
|
|
54
|
-
}
|
|
55
|
-
]
|
|
44
|
+
},
|
|
45
|
+
],
|
|
56
46
|
],
|
|
57
47
|
"dependencies": ["<(module_root_dir)/deps/rocksdb/rocksdb.gyp:rocksdb"],
|
|
58
|
-
"include_dirs": ["<!(node -e \"require('napi-macros')\")"
|
|
59
|
-
"sources": ["binding.cc"]
|
|
48
|
+
"include_dirs": ["<!(node -e \"require('napi-macros')\")"],
|
|
49
|
+
"sources": ["binding.cc"],
|
|
60
50
|
}
|
|
61
|
-
]
|
|
51
|
+
],
|
|
62
52
|
}
|
package/index.js
CHANGED
|
@@ -5,7 +5,6 @@ const { AbstractLevel } = require('abstract-level')
|
|
|
5
5
|
const ModuleError = require('module-error')
|
|
6
6
|
const binding = require('./binding')
|
|
7
7
|
const { ChainedBatch } = require('./chained-batch')
|
|
8
|
-
const { Regex } = require('./regex')
|
|
9
8
|
const { Iterator } = require('./iterator')
|
|
10
9
|
const fs = require('node:fs')
|
|
11
10
|
const assert = require('node:assert')
|
|
@@ -265,4 +264,3 @@ class RocksLevel extends AbstractLevel {
|
|
|
265
264
|
}
|
|
266
265
|
|
|
267
266
|
exports.RocksLevel = RocksLevel
|
|
268
|
-
exports.Regex = Regex
|
package/iterator.js
CHANGED
|
@@ -98,24 +98,24 @@ class Iterator extends AbstractIterator {
|
|
|
98
98
|
return []
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
const
|
|
101
|
+
const result = binding.iterator_nextv(this[kContext], size)
|
|
102
102
|
|
|
103
103
|
this[kFirst] = false
|
|
104
|
-
this[kFinished] = finished
|
|
104
|
+
this[kFinished] = result.finished
|
|
105
105
|
|
|
106
|
-
return
|
|
106
|
+
return result
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
_close (callback) {
|
|
110
110
|
try {
|
|
111
|
-
this.
|
|
111
|
+
this._closeSync()
|
|
112
112
|
process.nextTick(callback)
|
|
113
113
|
} catch (err) {
|
|
114
114
|
process.nextTick(callback, err)
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
_closeSync () {
|
|
119
119
|
this[kCache] = kEmpty
|
|
120
120
|
binding.iterator_close(this[kContext])
|
|
121
121
|
}
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
package/regex.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const binding = require('./binding')
|
|
4
|
-
|
|
5
|
-
class Regex {
|
|
6
|
-
#context
|
|
7
|
-
|
|
8
|
-
constructor (pattern) {
|
|
9
|
-
this.#context = binding.regex_init(pattern)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
test (buffer, byteOffset, byteLength) {
|
|
13
|
-
if (byteOffset === undefined) {
|
|
14
|
-
byteOffset = 0
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (byteLength === undefined) {
|
|
18
|
-
byteLength = buffer.byteLength - byteOffset
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return binding.regex_test(this.#context, buffer, byteOffset, byteLength)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
testMany (values) {
|
|
25
|
-
return binding.regex_test_many(this.#context, values)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
exports.Regex = Regex
|