@nxtedition/rocksdb 7.0.41 → 7.0.44
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
CHANGED
|
@@ -180,6 +180,7 @@ static napi_status ToString(napi_env env, napi_value from, rocksdb::PinnableSlic
|
|
|
180
180
|
size_t length = 0;
|
|
181
181
|
NAPI_STATUS_RETURN(napi_get_buffer_info(env, from, reinterpret_cast<void**>(&buf), &length));
|
|
182
182
|
|
|
183
|
+
// TODO (fix): Should extend life of "from". Or "to" should be a non-pinnable slice.
|
|
183
184
|
to.PinSlice(rocksdb::Slice(buf, length), noop, nullptr, nullptr);
|
|
184
185
|
} else {
|
|
185
186
|
return napi_invalid_arg;
|
|
@@ -1387,6 +1388,50 @@ struct GetManyWorker final : public Worker {
|
|
|
1387
1388
|
const rocksdb::Snapshot* snapshot_;
|
|
1388
1389
|
};
|
|
1389
1390
|
|
|
1391
|
+
typedef std::vector<std::string> Vector;
|
|
1392
|
+
|
|
1393
|
+
NAPI_METHOD(vector_init) {
|
|
1394
|
+
auto vector = new Vector();
|
|
1395
|
+
|
|
1396
|
+
napi_value result;
|
|
1397
|
+
NAPI_STATUS_THROWS(napi_create_external(env, vector, Finalize<Vector>, vector, &result));
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
NAPI_METHOD(vector_push) {
|
|
1401
|
+
NAPI_ARGV(2);
|
|
1402
|
+
|
|
1403
|
+
Vector* vector;
|
|
1404
|
+
NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&vector)));
|
|
1405
|
+
|
|
1406
|
+
std::string value;
|
|
1407
|
+
NAPI_STATUS_THROWS(ToString(env, argv[1], value));
|
|
1408
|
+
|
|
1409
|
+
vector->push_back(std::move(value));
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
NAPI_METHOD(db_get_many2) {
|
|
1413
|
+
NAPI_ARGV(4);
|
|
1414
|
+
|
|
1415
|
+
Database* database;
|
|
1416
|
+
NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&database)));
|
|
1417
|
+
|
|
1418
|
+
Vector* vector;
|
|
1419
|
+
NAPI_STATUS_THROWS(napi_get_value_external(env, argv[1], reinterpret_cast<void**>(&vector)));
|
|
1420
|
+
|
|
1421
|
+
const bool asBuffer = EncodingIsBuffer(env, argv[2], "valueEncoding");
|
|
1422
|
+
const bool fillCache = BooleanProperty(env, argv[2], "fillCache").value_or(true);
|
|
1423
|
+
const bool ignoreRangeDeletions = BooleanProperty(env, argv[2], "ignoreRangeDeletions").value_or(false);
|
|
1424
|
+
|
|
1425
|
+
rocksdb::ColumnFamilyHandle* column;
|
|
1426
|
+
NAPI_STATUS_THROWS(GetColumnFamily(database, env, argv[2], &column));
|
|
1427
|
+
|
|
1428
|
+
auto worker =
|
|
1429
|
+
new GetManyWorker(env, database, column, std::move(*vector), argv[3], asBuffer, fillCache, ignoreRangeDeletions);
|
|
1430
|
+
worker->Queue(env);
|
|
1431
|
+
|
|
1432
|
+
return 0;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1390
1435
|
NAPI_METHOD(db_get_many) {
|
|
1391
1436
|
NAPI_ARGV(4);
|
|
1392
1437
|
|
|
@@ -2051,4 +2096,8 @@ NAPI_INIT() {
|
|
|
2051
2096
|
NAPI_EXPORT_FUNCTION(batch_put_log_data);
|
|
2052
2097
|
NAPI_EXPORT_FUNCTION(batch_merge);
|
|
2053
2098
|
NAPI_EXPORT_FUNCTION(batch_count);
|
|
2099
|
+
|
|
2100
|
+
NAPI_EXPORT_FUNCTION(vector_init);
|
|
2101
|
+
NAPI_EXPORT_FUNCTION(vector_push);
|
|
2102
|
+
NAPI_EXPORT_FUNCTION(db_get_many2);
|
|
2054
2103
|
}
|
package/max_rev_operator.h
CHANGED
|
@@ -1,30 +1,15 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
-
#include <memory.h>
|
|
4
|
-
|
|
5
3
|
int compareRev(const rocksdb::Slice& a, const rocksdb::Slice& b) {
|
|
6
|
-
auto indexA =
|
|
4
|
+
auto indexA = 0UL;
|
|
5
|
+
auto indexB = 0UL;
|
|
7
6
|
const auto endA = a.size();
|
|
8
|
-
auto lenA = endA;
|
|
9
|
-
|
|
10
|
-
auto indexB = 0;
|
|
11
7
|
const auto endB = b.size();
|
|
12
|
-
auto lenB = endB;
|
|
13
|
-
|
|
14
|
-
// Skip leading zeroes
|
|
15
|
-
while (a[indexA] == '0') {
|
|
16
|
-
++indexA;
|
|
17
|
-
--lenA;
|
|
18
|
-
}
|
|
19
|
-
while (b[indexB] == '0') {
|
|
20
|
-
++indexB;
|
|
21
|
-
--lenB;
|
|
22
|
-
}
|
|
23
8
|
|
|
24
9
|
// Compare the revision number
|
|
25
10
|
auto result = 0;
|
|
26
11
|
const auto end = std::min(endA, endB);
|
|
27
|
-
while (indexA < end) {
|
|
12
|
+
while (indexA < end && indexB < end) {
|
|
28
13
|
const auto ac = a[indexA++];
|
|
29
14
|
const auto bc = b[indexB++];
|
|
30
15
|
|
|
@@ -47,7 +32,7 @@ int compareRev(const rocksdb::Slice& a, const rocksdb::Slice& b) {
|
|
|
47
32
|
}
|
|
48
33
|
|
|
49
34
|
// Compare the rest
|
|
50
|
-
while (indexA < end) {
|
|
35
|
+
while (indexA < end && indexB < end) {
|
|
51
36
|
const auto ac = a[indexA++];
|
|
52
37
|
const auto bc = b[indexB++];
|
|
53
38
|
if (ac != bc) {
|
|
@@ -55,11 +40,9 @@ int compareRev(const rocksdb::Slice& a, const rocksdb::Slice& b) {
|
|
|
55
40
|
}
|
|
56
41
|
}
|
|
57
42
|
|
|
58
|
-
return
|
|
43
|
+
return endA - endB;
|
|
59
44
|
}
|
|
60
45
|
|
|
61
|
-
// Merge operator that picks the maximum operand, Comparison is based on
|
|
62
|
-
// Slice::compare
|
|
63
46
|
class MaxRevOperator : public rocksdb::MergeOperator {
|
|
64
47
|
public:
|
|
65
48
|
bool FullMergeV2(const MergeOperationInput& merge_in,
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|