@ohos-ports/lmdb 2.5.3 → 2.8.5-beta.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/LICENSE +20 -20
- package/README.md +72 -28
- package/SECURITY.md +12 -12
- package/bin/download-prebuilds.js +15 -0
- package/binding.gyp +115 -111
- package/build/Release/lmdb.node +0 -0
- package/caching.js +212 -156
- package/dependencies/lmdb/libraries/liblmdb/COPYRIGHT +20 -20
- package/dependencies/lmdb/libraries/liblmdb/Doxyfile +1631 -1631
- package/dependencies/lmdb/libraries/liblmdb/LICENSE +47 -47
- package/dependencies/lmdb/libraries/liblmdb/Makefile +136 -136
- package/dependencies/lmdb/libraries/liblmdb/chacha8.c +183 -183
- package/dependencies/lmdb/libraries/liblmdb/chacha8.h +14 -14
- package/dependencies/lmdb/libraries/liblmdb/crypto.c +121 -121
- package/dependencies/lmdb/libraries/liblmdb/intro.doc +192 -192
- package/dependencies/lmdb/libraries/liblmdb/lmdb.h +28 -3
- package/dependencies/lmdb/libraries/liblmdb/mdb.c +157 -31
- package/dependencies/lmdb/libraries/liblmdb/mdb_copy.1 +74 -74
- package/dependencies/lmdb/libraries/liblmdb/mdb_copy.c +106 -106
- package/dependencies/lmdb/libraries/liblmdb/mdb_drop.1 +53 -53
- package/dependencies/lmdb/libraries/liblmdb/mdb_drop.c +154 -154
- package/dependencies/lmdb/libraries/liblmdb/mdb_dump.1 +94 -94
- package/dependencies/lmdb/libraries/liblmdb/mdb_dump.c +333 -333
- package/dependencies/lmdb/libraries/liblmdb/mdb_load.1 +97 -97
- package/dependencies/lmdb/libraries/liblmdb/mdb_load.c +530 -530
- package/dependencies/lmdb/libraries/liblmdb/mdb_stat.1 +83 -83
- package/dependencies/lmdb/libraries/liblmdb/mdb_stat.c +276 -276
- package/dependencies/lmdb/libraries/liblmdb/midl-sparse.c +452 -0
- package/dependencies/lmdb/libraries/liblmdb/midl.c +452 -452
- package/dependencies/lmdb/libraries/liblmdb/midl.h +208 -208
- package/dependencies/lmdb/libraries/liblmdb/module.c +101 -101
- package/dependencies/lmdb/libraries/liblmdb/module.h +16 -16
- package/dependencies/lmdb/libraries/liblmdb/mtest.c +178 -178
- package/dependencies/lmdb/libraries/liblmdb/mtest2.c +124 -124
- package/dependencies/lmdb/libraries/liblmdb/mtest3.c +133 -133
- package/dependencies/lmdb/libraries/liblmdb/mtest4.c +168 -168
- package/dependencies/lmdb/libraries/liblmdb/mtest5.c +135 -135
- package/dependencies/lmdb/libraries/liblmdb/mtest6.c +141 -141
- package/dependencies/lmdb/libraries/liblmdb/mtest_enc.c +190 -190
- package/dependencies/lmdb/libraries/liblmdb/mtest_enc2.c +189 -189
- package/dependencies/lmdb/libraries/liblmdb/mtest_remap.c +177 -177
- package/dependencies/lmdb/libraries/liblmdb/sample-bdb.txt +73 -73
- package/dependencies/lmdb/libraries/liblmdb/sample-mdb.txt +62 -62
- package/dependencies/lmdb/libraries/liblmdb/tooltag +27 -27
- package/dependencies/lmdb-data-v1/libraries/liblmdb/CHANGES +266 -0
- package/dependencies/lmdb-data-v1/libraries/liblmdb/COPYRIGHT +20 -20
- package/dependencies/lmdb-data-v1/libraries/liblmdb/Doxyfile +1631 -1631
- package/dependencies/lmdb-data-v1/libraries/liblmdb/LICENSE +47 -47
- package/dependencies/lmdb-data-v1/libraries/liblmdb/intro.doc +192 -192
- package/dependencies/lmdb-data-v1/libraries/liblmdb/lmdb.h +1608 -1653
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb.c +10320 -11359
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb_copy.1 +55 -61
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb_copy.c +82 -84
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb_dump.1 +75 -81
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb_dump.c +319 -319
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb_load.1 +84 -84
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb_load.c +496 -492
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb_stat.1 +64 -70
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb_stat.c +263 -264
- package/dependencies/lmdb-data-v1/libraries/liblmdb/midl.c +359 -421
- package/dependencies/lmdb-data-v1/libraries/liblmdb/midl.h +186 -200
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mtest.c +177 -177
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mtest2.c +124 -124
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mtest3.c +133 -133
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mtest4.c +168 -168
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mtest5.c +135 -135
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mtest6.c +141 -141
- package/dependencies/lmdb-data-v1/libraries/liblmdb/sample-bdb.txt +73 -73
- package/dependencies/lmdb-data-v1/libraries/liblmdb/sample-mdb.txt +62 -62
- package/dependencies/lmdb-data-v1/libraries/liblmdb/tooltag +22 -27
- package/dependencies/lz4/LICENSE +11 -11
- package/dependencies/lz4/lib/LICENSE +24 -24
- package/dependencies/lz4/lib/Makefile +225 -0
- package/dependencies/lz4/lib/README.md +169 -137
- package/dependencies/lz4/lib/dll/example/Makefile +63 -0
- package/dependencies/lz4/lib/dll/example/README.md +69 -69
- package/dependencies/lz4/lib/dll/liblz4.def +62 -62
- package/dependencies/lz4/lib/liblz4-dll.rc.in +35 -35
- package/dependencies/lz4/lib/liblz4.pc.in +14 -14
- package/dependencies/lz4/lib/lz4.c +2722 -2495
- package/dependencies/lz4/lib/lz4.h +842 -774
- package/dependencies/lz4/lib/lz4file.c +311 -0
- package/dependencies/lz4/lib/lz4file.h +93 -0
- package/dependencies/lz4/lib/lz4frame.c +2078 -1899
- package/dependencies/lz4/lib/lz4frame.h +692 -623
- package/dependencies/lz4/lib/lz4frame_static.h +47 -47
- package/dependencies/lz4/lib/lz4hc.c +1631 -1615
- package/dependencies/lz4/lib/lz4hc.h +413 -413
- package/dependencies/lz4/lib/xxhash.c +1030 -1030
- package/dependencies/lz4/lib/xxhash.h +328 -328
- package/dependencies/v8/v8-fast-api-calls-v16.h +790 -790
- package/dependencies/v8/v8-fast-api-calls.h +784 -888
- package/dist/index.cjs +1050 -584
- package/dist/index.cjs.map +1 -1
- package/index.d.cts +420 -0
- package/index.d.ts +450 -385
- package/index.js +38 -37
- package/keys.js +116 -102
- package/level.js +26 -26
- package/native.js +8 -5
- package/node-index.js +21 -17
- package/open.js +51 -17
- package/package.json +55 -21
- package/read.js +338 -95
- package/src/compression.cpp +12 -9
- package/src/cursor.cpp +82 -31
- package/src/dbi.cpp +78 -40
- package/src/env.cpp +336 -68
- package/src/lmdb-js.cpp +64 -64
- package/src/lmdb-js.h +83 -49
- package/src/misc.cpp +297 -28
- package/src/ordered-binary.cpp +46 -46
- package/src/txn.cpp +210 -257
- package/src/v8-functions.cpp +170 -166
- package/src/windows.c +34 -34
- package/src/writer.cpp +169 -84
- package/util/RangeIterable.js +112 -17
- package/util/set-optional-deps.cjs +14 -10
- package/util/when.js +8 -8
- package/write.js +145 -121
- package/dependencies/lmdb-data-v1/libraries/liblmdb/Makefile +0 -118
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb_drop.1 +0 -40
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb_drop.c +0 -135
- package/rollup.config.js +0 -12
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
This project contains is based on the code from the node-lmdb project ([Copyright (c) 2014 Timur Kristóf](https://github.com/venemo/node-lmdb/)) and LMDB, which has a specific [OpenLDAP license](dependencies/lmdb/libraries/liblmdb/LICENSE),
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
This project contains is based on the code from the node-lmdb project ([Copyright (c) 2014 Timur Kristóf](https://github.com/venemo/node-lmdb/)) and LMDB, which has a specific [OpenLDAP license](dependencies/lmdb/libraries/liblmdb/LICENSE),
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](README.md)
|
|
5
5
|
[](README.md)
|
|
6
6
|
|
|
7
|
-
This is an ultra-fast NodeJS and Deno interface to LMDB; probably the fastest and most efficient key-value/database interface that exists for storage and retrieval of structured JS data (objects, arrays, etc.) in a true persisted, scalable, [ACID compliant](https://en.wikipedia.org/wiki/ACID) database. It provides a simple interface for interacting with LMDB, as a key-value db, that makes it easy to fully leverage the power, crash-proof design, and efficiency of LMDB using intuitive JavaScript, and is designed to scale across multiple processes or threads. Several key features that make it idiomatic, highly performant, and easy to use LMDB efficiently:
|
|
7
|
+
This is an ultra-fast NodeJS, Bun, and Deno interface to LMDB; probably the fastest and most efficient key-value/database interface that exists for storage and retrieval of structured JS data (objects, arrays, etc.) in a true persisted, scalable, [ACID compliant](https://en.wikipedia.org/wiki/ACID) database. It provides a simple interface for interacting with LMDB, as a key-value db, that makes it easy to fully leverage the power, crash-proof design, and efficiency of LMDB using intuitive JavaScript, and is designed to scale across multiple processes or threads. Several key features that make it idiomatic, highly performant, and easy to use LMDB efficiently:
|
|
8
8
|
* High-performance translation of JS values and data structures to/from binary key/value data
|
|
9
9
|
* Queueing asynchronous off-thread write operations with promise-based API
|
|
10
10
|
* Simple transaction management
|
|
@@ -13,7 +13,7 @@ This is an ultra-fast NodeJS and Deno interface to LMDB; probably the fastest an
|
|
|
13
13
|
* Optional native off-main-thread compression with high-performance LZ4 compression <a href="https://github.com/kriszyp/db-benchmark"><img align="right" src="./assets/performance.png" width="380"/></a>
|
|
14
14
|
* And ridiculously fast and efficient, with integrated (de)serialization, data retrieval can be several times faster than `JSON` alone
|
|
15
15
|
|
|
16
|
-
`lmdb-js` is used in many heavy-use production applications, including as a high-performance cache for builds in [Parcel](https://parceljs.org/) and [Elasticsearch's Kibana](https://www.elastic.co/kibana/), as the storage layer for [HarperDB](https://harperdb.io/) and [Gatsby](https://www.gatsbyjs.com/)'s database, and for search and analytical engine for
|
|
16
|
+
`lmdb-js` is used in many heavy-use production applications, including as a high-performance cache for builds in [Parcel](https://parceljs.org/) and [Elasticsearch's Kibana](https://www.elastic.co/kibana/), as the storage layer for [HarperDB](https://harperdb.io/) and [Gatsby](https://www.gatsbyjs.com/)'s database, and for search and analytical engine for [clinical medical research](https://drevidence.com).
|
|
17
17
|
|
|
18
18
|
<a href="https://www.elastic.co/kibana/"><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4466841eed0bf232/5d082a5e97f2babb5af907ee/logo-kibana-32-color.svg" width="40" align="right"></a>
|
|
19
19
|
<a href="https://parceljs.org/"><img src="https://parceljs.org/avatar.633bb25a.avif" width="56" align="right"></a>
|
|
@@ -25,9 +25,13 @@ This library is published to the NPM package `lmdb` (the 1.x versions were publi
|
|
|
25
25
|
```
|
|
26
26
|
npm install lmdb
|
|
27
27
|
```
|
|
28
|
-
`lmdb-js` is based on the Node-API for maximum
|
|
28
|
+
`lmdb-js` is based on the Node-API for maximum compatibility across all supported Node versions and future Deno versions. It also includes accelerated, high-speed functions for direct V8 interaction that are compiled for, and (automatically) loaded in Node v16. The standard Node-API based functions are used in all other versions and still provide excellent performance, but for absolute maximum performance on older versions of Node, you can use `npm install --build-from-source`.
|
|
29
29
|
|
|
30
|
-
In Deno, this package
|
|
30
|
+
In Deno, this package should be loaded using the NPM module identifier (which will download the package):
|
|
31
|
+
```js
|
|
32
|
+
import { open } from 'npm:lmdb';
|
|
33
|
+
```
|
|
34
|
+
Note that Deno and Bun's support for NAPI is not very stable yet, and currently asynchronous transactions (`transaction` method) are not supported (Bun issue [here](https://github.com/oven-sh/bun/issues/158#issuecomment-1126624085)).
|
|
31
35
|
|
|
32
36
|
This library has minimal, tightly-controlled, and maintained dependencies to ensure stability, security, and efficiency. It supports both native ESM and CJS usage.
|
|
33
37
|
|
|
@@ -35,13 +39,13 @@ This library has minimal, tightly-controlled, and maintained dependencies to ens
|
|
|
35
39
|
|
|
36
40
|
This library handles translation of JavaScript values, primitives, arrays, and objects, to and from the binary storage of LMDB keys and values with highly optimized native C++ code for breakneck performance. It supports multiple types of JS values for keys and values, making it easy to use idiomatic JS for storing and retrieving data in LMDB.
|
|
37
41
|
|
|
38
|
-
`lmdb-js` is designed for synchronous reads, and asynchronous writes. In idiomatic
|
|
42
|
+
`lmdb-js` is designed for synchronous reads, and asynchronous writes. In idiomatic JavaScript code, I/O operations are performed asynchronously. LMDB is a memory-mapped database, reading and writing within a transaction does not use any I/O (other than the slight possibility of a page fault), and can usually be performed faster than the event queue callbacks can even execute, and it is easier to write code for instant synchronous values from reads. On the otherhand, commiting transactions does involve I/O, and vastly higher throughput can be achieved by batching operations and executing on a separate thread. Consequently, `lmdb-js` is designed for transactions to go through this asynchronous batching process and return a simple promise that resolves once data is written and flushed to disk.
|
|
39
43
|
|
|
40
|
-
With the default
|
|
44
|
+
With the default syncing configuration, LMDB has a crash-proof design; a machine can be turned off at any point, and data can not be corrupted unless the written data is actually changed or tampered. Writing data and waiting for confirmation that it has been written to the physical medium is critical for data integrity, but is well known to have latency (although not necessarily less efficient). However, by batching writes, when a database is under load, slower transactions enable more writes per transaction, and this library is able to drive LMDB to achieve the maximum levels of throughput with fully synced operations, preserving both the durability/safety of the transactions and unparalleled performance.
|
|
41
45
|
|
|
42
|
-
This library supports and encourages the use of conditional writes; this allows for atomic operations that are
|
|
46
|
+
This library supports and encourages the use of conditional writes; this allows for atomic operations that are dependent on previously read data, and most transactional types of operations can be written with an optimistic-locking based, atomic-conditional-write pattern. This allows this library to delegate writes to off-thread execution, and scale to handle concurrent execution across many processes or threads while maintaining data integrity.
|
|
43
47
|
|
|
44
|
-
This library automatically handles
|
|
48
|
+
This library automatically handles database growth, expanding file size with a smart heuristic that minimizes file fragmentation (as you would expect from a database).
|
|
45
49
|
|
|
46
50
|
This library provides optional compression using LZ4 that works in conjunction with the asynchronous writes by performing the compression in the same thread (off the main thread) that performs the writes in a transaction. LZ4 is extremely fast, and decompression can be performed at roughly 5GB/s, so excellent storage efficiency can be achieved with almost negligible performance impact.
|
|
47
51
|
|
|
@@ -69,7 +73,7 @@ myDB.transaction(() => {
|
|
|
69
73
|
Once you have opened a database, you can store and retrieve values using keys:
|
|
70
74
|
|
|
71
75
|
### Values
|
|
72
|
-
You can store a wide variety of JavaScript values and data structures in this library, including objects (with arbitrary complexity), arrays, buffers, strings, numbers, etc. in your database. Even full structural cloning (with cycles) is
|
|
76
|
+
You can store a wide variety of JavaScript values and data structures in this library, including objects (with arbitrary complexity), arrays, buffers, strings, numbers, etc. in your database. Even full structural cloning (with cycles) is optionally supported. Values are stored and retrieved according to the database encoding, which can be set using the `encoding` property on the database options. By default, data is stored using MessagePack, but there are several supported encodings:
|
|
73
77
|
|
|
74
78
|
* `msgpack` (default) - All values are stored by serializing the value as MessagePack (using the [msgpackr](https://github.com/kriszyp/msgpackr) package). Values are decoded and parsed on retrieval, so `get` and `getRange` will return the object, array, or other value that you have stored. The msgpackr package is extremely fast (usually faster than native JSON), and provides the most flexibility in storing different value types. See the Shared Structures section for how to achieve maximum efficiency with this.
|
|
75
79
|
* `cbor` - This specifies all values use the CBOR format, which requires that the [cbor-x](https://github.com/kriszyp/cbor-x) package be installed. This package is based on [msgpackr](https://github.com/kriszyp/msgpackr) and supports all the same options.
|
|
@@ -81,11 +85,13 @@ You can store a wide variety of JavaScript values and data structures in this li
|
|
|
81
85
|
In addition, you can use `asBinary` to directly store a buffer or Uint8Array as a value, bypassing any encoding.
|
|
82
86
|
|
|
83
87
|
### Keys
|
|
84
|
-
When using the various APIs, keys can be any JS primitive (string, number, boolean, symbol), an array of primitives, or a Buffer. Using the default `ordered-binary` conversion, primitives are translated to binary keys used by LMDB in such a way that consistent ordering is preserved. Numbers are ordered naturally, which come before strings, which are ordered lexically. The keys are stored with type information preserved. The `getRange`operations that return a set of entries will return entries with the original JS primitive values for the keys. If arrays are used as keys, they are
|
|
88
|
+
When using the various APIs, keys can be any JS primitive (string, number, boolean, symbol), an array of primitives, or a Buffer. Using the default `ordered-binary` conversion, primitives are translated to binary keys used by LMDB in such a way that consistent ordering is preserved. Numbers are ordered naturally, which come before strings, which are ordered lexically. The keys are stored with type information preserved. The `getRange`operations that return a set of entries will return entries with the original JS primitive values for the keys. If arrays are used as keys, they are ordered by first value in the array, with each subsequent element being a tie-breaker. Numbers are stored as doubles, with reversal of sign bit for proper ordering plus type information, so any JS number can be used as a key. For example, here is the order of some different keys:
|
|
85
89
|
|
|
86
90
|
```js
|
|
87
91
|
null // lowest possible value
|
|
88
92
|
Symbol.for('even symbols')
|
|
93
|
+
false
|
|
94
|
+
true
|
|
89
95
|
-10 // negative supported
|
|
90
96
|
-1.1 // decimals supported
|
|
91
97
|
400
|
|
@@ -99,15 +105,19 @@ Symbol.for('even symbols')
|
|
|
99
105
|
Buffer.from([255]) // buffers can be used directly, 255 is higher than any byte produced by primitives
|
|
100
106
|
```
|
|
101
107
|
|
|
102
|
-
|
|
108
|
+
Keys use 0/null bytes as delimiters for arrays, and so strings currently can not have '\x00' (null char) in them.
|
|
109
|
+
|
|
110
|
+
By default, the maximum key size is 1978 bytes. If you explicitly set the `pageSize` to 8192 or higher, the maximum key size will be 4026, but this is the largest key size supported.
|
|
111
|
+
|
|
112
|
+
You can override the default encoding of keys, and cause keys to be returned as binary arrays (`Buffer`s in NodeJS) using the `keyEncoding: 'binary'` database option (generally slower). Use `keyEncoding: 'uint32'` for keys that are strictly 32-bit unsigned integers, or provide a custom key encoder/decoder with `keyEncoder` (see custom key encoding).
|
|
103
113
|
|
|
104
114
|
Once you created have a db, the following methods are available:
|
|
105
115
|
|
|
106
|
-
### `db.get(key): any`
|
|
107
|
-
This will retrieve the value at the specified key. The `key` must be a JS value/primitive as described above, and the return value will be the stored data (dependent on the encoding), or `undefined` if the entry does not exist.
|
|
116
|
+
### `db.get(key, options?): any`
|
|
117
|
+
This will retrieve the value at the specified key. The `key` must be a JS value/primitive as described above, and the return value will be the stored data (dependent on the encoding), or `undefined` if the entry does not exist. The `options` argument may be used to specify an explicit read transaction.
|
|
108
118
|
|
|
109
|
-
### `db.getEntry(key): any`
|
|
110
|
-
This will retrieve the
|
|
119
|
+
### `db.getEntry(key, options?): any`
|
|
120
|
+
This will retrieve the entry at the specified key. The `key` must be a JS value/primitive as described above, and the return value will be the stored entry, or `undefined` if the entry does not exist. An entry is object with a `value` property for the value in the database (as returned by `db.get`), and a `version` property for the version number of the entry in the database (if `useVersions` is enabled for the database). The `options` argument may be used to specify an explicit read transaction.
|
|
111
121
|
|
|
112
122
|
### `db.put(key, value, version?: number, ifVersion?: number): Promise<boolean>`
|
|
113
123
|
This will store the provided value/data at the specified key. If the database is using versioning (see options below), the `version` parameter will be used to set the version number of the entry. If the `ifVersion` parameter is set, the put will only occur if the existing entry at the provided key has the version specified by `ifVersion` at the instance the commit occurs (LMDB commits are atomic by default). If the `ifVersion` parameter is not set, the put will occur regardless of the previous value.
|
|
@@ -117,7 +127,7 @@ This operation will be enqueued to be written in a batch transaction. Any other
|
|
|
117
127
|
If `put` is called inside a transaction, the put will be executed immediately in the current transaction.
|
|
118
128
|
|
|
119
129
|
### `db.remove(key, IfVersion?: number): Promise<boolean>`
|
|
120
|
-
This will delete the entry at the specified key. This functions
|
|
130
|
+
This will delete the entry at the specified key. This functions is similar to `put`, with the same optional conditional version. This is batched along with put operations, and returns a promise indicating the success of the operation.
|
|
121
131
|
|
|
122
132
|
Again, if this is performed inside a transation, the removal will be performed in the current transaction.
|
|
123
133
|
|
|
@@ -151,7 +161,7 @@ function buyShoe() {
|
|
|
151
161
|
|
|
152
162
|
Note that `db.transaction(() => db.put(...))` is functionally the same as calling `db.put(...)`, queuing the put for asynchronously being committed in transaction, except that `put` executes the database's write operation entirely in separate worker thread, whereas `transaction` must also synchronize the callback function in the main JS thread to execute (so it is a little bit less efficient, although still quite fast).
|
|
153
163
|
|
|
154
|
-
|
|
164
|
+
Also, the callback function can be an async function (or return a promise), but this is not recommended. If the function returns a promise, this will delay/defer the commit until the callback's promise is resolved. However, while waiting for the callback to finish, other code may execute operations that would end up in the current transaction and may result in a surprising order of operations, and long running transactions are generally discouraged since they extend the single write lock.
|
|
155
165
|
|
|
156
166
|
### `db.childTransaction(callback: Function): Promise`
|
|
157
167
|
This will run the provided callback in a transaction much like `transaction` except an explicit child transaction will be used specifically for this callback. This makes it possible for the operations to be aborted and rolled back. The callback may return the exported `ABORT` constant to abort the child transaction for this callback. Also, if the callback function throws an error (or returns a reject promise), this will also abort the child transaction. This childTransaction function is not available if caching or `useWritemap` is enabled.
|
|
@@ -214,7 +224,7 @@ db.getRange({ start, end, offset: 10, limit: 10 }) // skip first 10 and get next
|
|
|
214
224
|
If you want to get a true array from the range results, the `asArray` property will return the results as an array.
|
|
215
225
|
|
|
216
226
|
#### Snapshots
|
|
217
|
-
By default a range iterator will use a database snapshot, using a single read transaction that remains open and gives a consistent view of the database at the time it was started, for the duration of iterating through the range. However, if the iteration will take place over a long period of time, keeping a read transaction open for a long time can interfere with LMDB's free space collection and reuse and increase the database size. If you will be using a long duration iterator, you can specify `snapshot: false` flag in the range options to indicate that it snapshotting is not necessary, and it can reset and renew read transactions while iterating, to allow LMDB to collect any space that was freed during iteration.
|
|
227
|
+
By default, a range iterator will use a database snapshot, using a single read transaction that remains open and gives a consistent view of the database at the time it was started, for the duration of iterating through the range. However, if the iteration will take place over a long period of time, keeping a read transaction open for a long time can interfere with LMDB's free space collection and reuse and increase the database size. If you will be using a long duration iterator, you can specify `snapshot: false` flag in the range options to indicate that it snapshotting is not necessary, and it can reset and renew read transactions while iterating, to allow LMDB to collect any space that was freed during iteration.
|
|
218
228
|
|
|
219
229
|
### `db.getValues(key, options?: RangeOptions): Iterable<any>`
|
|
220
230
|
When using a database with duplicate entries per key (with `dupSort` flag), you can use this to retrieve all the values for a given key. This will return an iterator just like `getRange`, except each entry will be the value from the database:
|
|
@@ -235,7 +245,7 @@ for (let value of db.getValues('key1')) {
|
|
|
235
245
|
}
|
|
236
246
|
```
|
|
237
247
|
|
|
238
|
-
You can optionally provide a second argument with the same `options` that `getRange` handles. You can provide a `start` and/or `end` values, which will
|
|
248
|
+
You can optionally provide a second argument with the same `options` that `getRange` handles. You can provide a `start` and/or `end` values, which will define the starting value and ending value for the range of values to return for the key:
|
|
239
249
|
|
|
240
250
|
```js
|
|
241
251
|
for (let value of db.getValues('key1', { start: 'value1', end: 'value3'})) ...
|
|
@@ -244,7 +254,7 @@ for (let value of db.getValues('key1', { start: 'value1', end: 'value3'})) ...
|
|
|
244
254
|
Using `start`/`end` is only supported if using the `ordered-binary` encoding.
|
|
245
255
|
|
|
246
256
|
### `db.getKeys(options: RangeOptions): Iterable<any>`
|
|
247
|
-
This behaves like `getRange`, but only returns the keys. If this is duplicate key database, each key is only returned once (even if it has multiple values/entries).
|
|
257
|
+
This behaves like `getRange`, but only returns the keys. If this is a duplicate key database, each key is only returned once (even if it has multiple values/entries).
|
|
248
258
|
|
|
249
259
|
### `RangeOptions`
|
|
250
260
|
Here are the options that can be provided to the range methods (all are optional):
|
|
@@ -295,7 +305,19 @@ let buffer = encode(myValue) // if we have already serialized a value, perhaps t
|
|
|
295
305
|
db.put(key, asBinary(buffer)) // we can directly store the encoded value
|
|
296
306
|
```
|
|
297
307
|
|
|
298
|
-
### `
|
|
308
|
+
### `db.useReadTransaction(): Transaction`
|
|
309
|
+
This allows you to explicitly start a read transaction, which holds a consistent snapshot of the database, and use it for subsequent retrieval operations. This will mark the read transaction as in use until `transaction.done()` is called. For example:
|
|
310
|
+
```javascript
|
|
311
|
+
let transaction = myDb.useReadTransaction();
|
|
312
|
+
let data = myDb.get('my-key', { transaction });
|
|
313
|
+
await doSomethingElse();
|
|
314
|
+
// the same read transaction is still being used and this will return the same record even if the data has been changed elsewhere:
|
|
315
|
+
data = myDb.get('my-key', { transaction });
|
|
316
|
+
transaction.done(); // make sure you mark the transaction as done
|
|
317
|
+
```
|
|
318
|
+
It is critical that you mark read transactions as done when you no longer need it or you will exhaust the read transactions that are available. Long-lived read transaction also prevent free space reclamation. This can be used with `get`, `getEntry` and range/query methods.
|
|
319
|
+
|
|
320
|
+
### `db.close(): Promise`
|
|
299
321
|
This will close the current db. This closes the underlying LMDB database, and if this is the root database (opened with `open` as opposed to `db.openDB`), it will close the environment (and child databases will no longer be able to interact with the database). This is asynchronous, waiting for any outstanding transactions to finish before closing the database.
|
|
300
322
|
|
|
301
323
|
### `db.doesExist(key, valueOrVersion): boolean`
|
|
@@ -375,6 +397,8 @@ let myDB = open('my-db', {
|
|
|
375
397
|
|
|
376
398
|
Compression is recommended for large databases that may be close to or larger than available RAM, to improve caching and reduce page faults. If you enable compression for a database, you must ensure that the data is always opened with the same compression setting, so that the data will be properly decompressed.
|
|
377
399
|
|
|
400
|
+
By default, opening a database from a root database will inherited the compression settings from the root database.
|
|
401
|
+
|
|
378
402
|
## Caching
|
|
379
403
|
This library supports caching of entries from databases, and uses a [LRU/LFU (LRFU) and weak-referencing caching mechanism](https://github.com/kriszyp/weak-lru-cache) for highly optimized caching and object tracking. There are several key potential benefits to using caching, including performance, key correlation with object identity, and immediate/synchronous access to saved data. Enabling caching will cache `get`s and `put`s, which can make frequent `get`s much faster. Caching is enabled by providing a truthy value for the `cache` property on the database `options`.
|
|
380
404
|
|
|
@@ -405,7 +429,7 @@ Additional databases can be opened within the main database environment with:
|
|
|
405
429
|
`db.openDB(name, options)` or `db.openDB(options)`
|
|
406
430
|
If the `path` has an `.` in it, it is treated as a file name, otherwise it is treated as a directory name, where the data will be stored. The path can be omitted to create a temporary database, which will be created in the system temp directory and deleted on close. The `options` argument to either of the functions should be an object, and supports the following properties, all of which are optional (except `name` if not otherwise specified):
|
|
407
431
|
* `name` - This is the name of the database. This defaults to null (which is the root database) when opening the database environment (`open`). When an opening a database within an environment (`openDB`), this is required, if not specified in first parameter.
|
|
408
|
-
* `encoding` - Sets the encoding for the database values, which can be `'msgpack'`, `'json'`, `'cbor'`, `'string'`, `'ordered-binary'`or `'binary'`.
|
|
432
|
+
* `encoding` - Sets the encoding for the database values, which can be `'msgpack'`, `'json'`, `'cbor'`, `'string'`, `'ordered-binary'`or `'binary'`. Child databases will inherit this from the root database, it is specified.
|
|
409
433
|
* `encoder` - Directly set the encoder to use or provide the settings for an encoder. This can be an object with settings to pass to the encoder or can be an object with `encode` and `decode` methods. It can also be an object with an `Encoder` that will be called to create the encoder instance. This allows you explicitly set the encoder with an import:
|
|
410
434
|
|
|
411
435
|
```js
|
|
@@ -426,9 +450,9 @@ The following additional option properties are only available when creating the
|
|
|
426
450
|
* `path` - This is the file path to the database environment file you will use.
|
|
427
451
|
* `maxDbs` - The maximum number of databases to be able to open within one root database/environment ([there is some extra overhead if this is set very high](http://www.lmdb.tech/doc/group__mdb.html#gaa2fc2f1f37cb1115e733b62cab2fcdbc)). This defaults to 12.
|
|
428
452
|
* `maxReaders` - The maximum number of concurrent read transactions (readers) to be able to open ([more information](http://www.lmdb.tech/doc/group__mdb.html#gae687966c24b790630be2a41573fe40e2)).
|
|
429
|
-
* `overlappingSync` - This enables committing transactions where LMDB waits for a transaction to be fully flushed to disk _after_ the transaction has been committed and defaults to being enabled. This option is discussed in more detail below.
|
|
453
|
+
* `overlappingSync` - This enables committing transactions where LMDB waits for a transaction to be fully flushed to disk _after_ the transaction has been committed and defaults to being enabled on non-Windows OSes. This option is discussed in more detail below.
|
|
430
454
|
* `separateFlushed` - Resolve asynchronous operations when commits are finished and visible and include a separate promise for when a commit is flushed to disk, as a `flushed` property on the commit promise. Note that you can alternately use the `flushed` property on the database.
|
|
431
|
-
* `pageSize` - This defines the page size of the database. This
|
|
455
|
+
* `pageSize` - This defines the page size of the database. This defaults to the default page size of the OS (usually 4,096, except on MacOS with M-series, which is 16,384 bytes). You may want to consider setting this to 8,192 for databases larger than available memory (and moreso if you have range queries) or 4,096 for databases that can mostly cache in memory. Note that this only effects the page size of new databases (does not affect existing databases).
|
|
432
456
|
* `eventTurnBatching` - This is enabled by default and will ensure that all asynchronous write operations performed in the same event turn will be batched together into the same transaction. Disabling this allows lmdb-js to commit a transaction at any time, and asynchronous operations will only be guaranteed to be in the same transaction if explicitly batched together (with `transaction`, `batch`, `ifVersion`). If this is disabled (set to `false`), you can control how many writes can occur before starting a transaction with `txnStartThreshold` (allow a transaction will still be started at the next event turn if the threshold is not met). Disabling event turn batching (and using lower `txnStartThreshold` values) can facilitate a faster response time to write operations. `txnStartThreshold` defaults to 5.
|
|
433
457
|
* `encryptionKey` - This enables encryption, and the provided value is the key that is used for encryption. This may be a buffer or string, but must be 32 bytes/characters long. This uses the Chacha8 cipher for fast and secure on-disk encryption of data.
|
|
434
458
|
* `commitDelay` - This is the amount of time to wait (in milliseconds) for batching write operations before committing the writes (in a transaction). This defaults to 0. A delay of 0 means more immediate commits with less latency (uses `setImmediate`), but a longer delay (which uses `setTimeout`) can be more efficient at collecting more writes into a single transaction and reducing I/O load. Note that NodeJS timers only have an effective resolution of about 10ms, so a `commitDelay` of 1ms will generally wait about 10ms.
|
|
@@ -460,7 +484,7 @@ let v = db.get(key) // this value now be retrieved from the db
|
|
|
460
484
|
await db.flushed // wait for last commit to be fully flushed to disk
|
|
461
485
|
```
|
|
462
486
|
|
|
463
|
-
Enabling `overlappingSync` option is generally not recommended on Windows, as Window's disk flushing operation tends to have very poor performance characteristics on larger databases (whereas Windows tends to perform well with standard transactions). This option
|
|
487
|
+
Enabling `overlappingSync` option is generally not recommended on Windows, as Window's disk flushing operation tends to have very poor performance characteristics on larger databases (whereas Windows tends to perform well with standard transactions). This option is enabled by default for non-Windows platforms.
|
|
464
488
|
|
|
465
489
|
#### Serialization options
|
|
466
490
|
If you are using the default encoding of `'msgpack'`, the [msgpackr](https://github.com/kriszyp/msgpackr) package is used for serialization and deserialization. You can provide encoder options that are passed to msgpackr or cbor, as well, by including them in the `encoder` property object. For example, these options can be potentially useful:
|
|
@@ -497,13 +521,33 @@ dbLevel.get(id).then(...)
|
|
|
497
521
|
|
|
498
522
|
Benchmarking on Node 14.9, with 3.4Ghz i7-4770 Windows, a get operation, using JS numbers as a key, retrieving data from the database (random access), and decoding the data into a structured object with 10 properties (using default [MessagePack encoding](https://github.com/kriszyp/msgpackr)), can be done in about half a microsecond, or about 1,900,000/sec on a single thread. This is almost three times as fast as a single native `JSON.parse` call with the same object without any DB interaction! LMDB scales effortlessly across multiple processes or threads; over 6,000,000 operations/sec on the same 4/8 core computer by running across multiple threads (or 18,000,000 operations/sec with raw binary data). By running writes on a separate transactional thread, writing is extremely fast as well. With encoding the same objects, full encoding and writes can be performed at about 500,000 puts/second or 1,700,000 puts/second on multiple threads.
|
|
499
523
|
|
|
524
|
+
|
|
525
|
+
### Full Prebuild Script
|
|
526
|
+
This package includes an NPM executable to download all the prebuilds for all OS/architectures. This can be useful if
|
|
527
|
+
you are building a full set of files/artifacts to be run on different machines. This requires installing the `prebuildify-ci
|
|
528
|
+
` package (globally is recommended) and adding something like this to your package.json:
|
|
529
|
+
```
|
|
530
|
+
{
|
|
531
|
+
"dependencies": {
|
|
532
|
+
"lmdb": "2.6.0"
|
|
533
|
+
},
|
|
534
|
+
"scripts": {
|
|
535
|
+
"download-lmdb-prebuilds": "download-lmdb-prebuilds"
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
```
|
|
539
|
+
|
|
500
540
|
#### Build Options
|
|
501
541
|
A few LMDB options are available at build time, and can be specified with options with `npm install` (which can be specified in your package.json install script):
|
|
502
|
-
`npm install --use_robust=
|
|
542
|
+
`npm install lmdb --build-from-source --use_robust=false`: This will disable LMDB's MDB_USE_ROBUST option, which uses robust semaphores/mutexes so that if you are using multiple processes, and one process dies in the middle of transaction, the OS will cleanup the semaphore/mutex, aborting the transaction and allowing other processes to run without hanging. There is a slight performance overhead to robust mutexes, but keeping this enabled is recommended if you will be using multiple processes.
|
|
503
543
|
|
|
504
|
-
On MacOS, there is a default limit of 10 robust locked semaphores, which imposes a limit on the number of open write transactions (if you have over 10 database environments with a write transaction). If you need more concurrent write transactions, you can increase your maximum undoable semaphore count
|
|
544
|
+
On MacOS, there is a default limit of 10 robust locked semaphores, which imposes a limit on the number of open write transactions (if you have over 10 database environments with a write transaction). If you need more concurrent write transactions, you can increase your maximum undoable semaphore count with:
|
|
545
|
+
```
|
|
546
|
+
sudo sysctl kern.sysv.semume=50
|
|
547
|
+
```
|
|
548
|
+
Otherwise you may need to disable the robust mutex option. You can also try to minimize overlapping transactions and/or reduce the number of database environments (and use more databases within each environment).
|
|
505
549
|
|
|
506
|
-
`npm install --use_data_v1=true`: This will build from an older version of LMDB that uses the legacy data format version 1 (the latest LMDB uses data format version 2). For portability of the data format, this may be preferable since many libraries still use older versions of LMDB. Since this is an older version of LMDB, some features may not be available, including encryption and remapping.
|
|
550
|
+
`npm install lmdb --build-from-source --use_data_v1=true`: This will build from an older version of LMDB that uses the legacy data format version 1 (the latest LMDB uses data format version 2). For portability of the data format, this may be preferable since many libraries still use older versions of LMDB. Since this is an older version of LMDB, some features may not be available, including encryption and remapping.
|
|
507
551
|
|
|
508
552
|
#### Turbo Mode
|
|
509
553
|
On Node V16+, lmdb-js will automatically enable V8's turbo fast-api calls (the `--turbo-fast-api-calls` V8 flag) to accelerate `lmdb-js`'s turbo-enabled functions. If you do not want this flag enabled, set the env variable `DISABLE_TURBO_CALLS=true` for your node process, or build from source with `--enable_fast_api_calls=false`.
|
package/SECURITY.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# Security Policy
|
|
2
|
-
|
|
3
|
-
## Supported Versions
|
|
4
|
-
|
|
5
|
-
| Version | Supported |
|
|
6
|
-
| ------- | ------------------ |
|
|
7
|
-
| 1.6.x | :white_check_mark: |
|
|
8
|
-
| 2.0.x | :white_check_mark: |
|
|
9
|
-
|
|
10
|
-
## Reporting a Vulnerability
|
|
11
|
-
|
|
12
|
-
Please report security vulnerabilities to kriszyp@gmail.com.
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
| Version | Supported |
|
|
6
|
+
| ------- | ------------------ |
|
|
7
|
+
| 1.6.x | :white_check_mark: |
|
|
8
|
+
| 2.0.x | :white_check_mark: |
|
|
9
|
+
|
|
10
|
+
## Reporting a Vulnerability
|
|
11
|
+
|
|
12
|
+
Please report security vulnerabilities to kriszyp@gmail.com.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { dirname } from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { exec } from 'child_process';
|
|
6
|
+
|
|
7
|
+
exec('download-msgpackr-prebuilds', propagateOutput);
|
|
8
|
+
process.chdir(fileURLToPath(dirname(dirname(import.meta.url))));
|
|
9
|
+
exec('prebuildify-ci download', propagateOutput);
|
|
10
|
+
function propagateOutput(error, stdout, stderr) {
|
|
11
|
+
console.error(stderr);
|
|
12
|
+
console.log(stdout);
|
|
13
|
+
if (error?.code)
|
|
14
|
+
process.exit(error.code);
|
|
15
|
+
}
|
package/binding.gyp
CHANGED
|
@@ -1,111 +1,115 @@
|
|
|
1
|
-
{
|
|
2
|
-
"variables": {
|
|
3
|
-
"os_linux_compiler%": "gcc",
|
|
4
|
-
"use_robust%": "false",
|
|
5
|
-
"use_data_v1%": "false",
|
|
6
|
-
"enable_v8%": "true",
|
|
7
|
-
"enable_fast_api_calls%": "true",
|
|
8
|
-
"enable_pointer_compression%": "false",
|
|
9
|
-
"openssl_fips": "X",
|
|
10
|
-
"target%": "",
|
|
11
|
-
"build_v8_with_gn": "false",
|
|
12
|
-
"runtime%": "node"
|
|
13
|
-
},
|
|
14
|
-
"conditions": [
|
|
15
|
-
['OS=="win"', {
|
|
16
|
-
"variables": {
|
|
17
|
-
"enable_fast_api_calls%": "<!(echo %ENABLE_FAST_API_CALLS%)",
|
|
18
|
-
"enable_v8%": "<!(echo %ENABLE_V8_FUNCTIONS%)",
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
"dependencies/
|
|
36
|
-
"dependencies/
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"src/
|
|
40
|
-
"src/
|
|
41
|
-
"src/
|
|
42
|
-
"src/
|
|
43
|
-
"src/
|
|
44
|
-
"src/
|
|
45
|
-
"src/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"-
|
|
61
|
-
"-Wno-
|
|
62
|
-
"-
|
|
63
|
-
"-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"variables": {
|
|
3
|
+
"os_linux_compiler%": "gcc",
|
|
4
|
+
"use_robust%": "false",
|
|
5
|
+
"use_data_v1%": "false",
|
|
6
|
+
"enable_v8%": "true",
|
|
7
|
+
"enable_fast_api_calls%": "true",
|
|
8
|
+
"enable_pointer_compression%": "false",
|
|
9
|
+
"openssl_fips": "X",
|
|
10
|
+
"target%": "",
|
|
11
|
+
"build_v8_with_gn": "false",
|
|
12
|
+
"runtime%": "node"
|
|
13
|
+
},
|
|
14
|
+
"conditions": [
|
|
15
|
+
['OS=="win"', {
|
|
16
|
+
"variables": {
|
|
17
|
+
"enable_fast_api_calls%": "<!(echo %ENABLE_FAST_API_CALLS%)",
|
|
18
|
+
"enable_v8%": "<!(echo %ENABLE_V8_FUNCTIONS%)",
|
|
19
|
+
"use_data_v1%": "<!(echo %LMDB_DATA_V1%)",
|
|
20
|
+
}
|
|
21
|
+
}],
|
|
22
|
+
['OS!="win"', {
|
|
23
|
+
"variables": {
|
|
24
|
+
"enable_fast_api_calls%": "<!(echo $ENABLE_FAST_API_CALLS)",
|
|
25
|
+
"enable_v8%": "<!(echo $ENABLE_V8_FUNCTIONS)",
|
|
26
|
+
"use_data_v1%": "<!(echo $LMDB_DATA_V1)",
|
|
27
|
+
}
|
|
28
|
+
}]
|
|
29
|
+
],
|
|
30
|
+
"targets": [
|
|
31
|
+
{
|
|
32
|
+
"target_name": "lmdb",
|
|
33
|
+
"sources": [
|
|
34
|
+
"src/lmdb-js.cpp",
|
|
35
|
+
"dependencies/lmdb/libraries/liblmdb/midl.c",
|
|
36
|
+
"dependencies/lmdb/libraries/liblmdb/chacha8.c",
|
|
37
|
+
"dependencies/lz4/lib/lz4.h",
|
|
38
|
+
"dependencies/lz4/lib/lz4.c",
|
|
39
|
+
"src/writer.cpp",
|
|
40
|
+
"src/env.cpp",
|
|
41
|
+
"src/compression.cpp",
|
|
42
|
+
"src/ordered-binary.cpp",
|
|
43
|
+
"src/misc.cpp",
|
|
44
|
+
"src/txn.cpp",
|
|
45
|
+
"src/dbi.cpp",
|
|
46
|
+
"src/cursor.cpp",
|
|
47
|
+
"src/v8-functions.cpp"
|
|
48
|
+
],
|
|
49
|
+
"include_dirs": [
|
|
50
|
+
"<!(node -p \"require('node-addon-api').include_dir\")",
|
|
51
|
+
"dependencies/lz4/lib"
|
|
52
|
+
],
|
|
53
|
+
"defines": ["MDB_MAXKEYSIZE=0", "NAPI_DISABLE_CPP_EXCEPTIONS" ],
|
|
54
|
+
"conditions": [
|
|
55
|
+
["OS=='linux'", {
|
|
56
|
+
"variables": {
|
|
57
|
+
"gcc_version" : "<!(<(os_linux_compiler) -dumpversion | cut -d '.' -f 1)",
|
|
58
|
+
},
|
|
59
|
+
"cflags_cc": [
|
|
60
|
+
"-fPIC",
|
|
61
|
+
"-Wno-strict-aliasing",
|
|
62
|
+
"-Wno-unused-result",
|
|
63
|
+
"-Wno-cast-function-type",
|
|
64
|
+
"-fvisibility=hidden",
|
|
65
|
+
"-fvisibility-inlines-hidden",
|
|
66
|
+
],
|
|
67
|
+
"ldflags": [
|
|
68
|
+
"-fPIC",
|
|
69
|
+
"-fvisibility=hidden"
|
|
70
|
+
],
|
|
71
|
+
"cflags": [
|
|
72
|
+
"-fPIC",
|
|
73
|
+
"-fvisibility=hidden",
|
|
74
|
+
"-O3"
|
|
75
|
+
],
|
|
76
|
+
}],
|
|
77
|
+
["OS=='win'", {
|
|
78
|
+
"libraries": ["ntdll.lib", "synchronization.lib"]
|
|
79
|
+
}],
|
|
80
|
+
["use_data_v1=='true'", {
|
|
81
|
+
"sources": [
|
|
82
|
+
"dependencies/lmdb-data-v1/libraries/liblmdb/mdb.c"
|
|
83
|
+
],
|
|
84
|
+
"include_dirs": [
|
|
85
|
+
"dependencies/lmdb-data-v1/libraries/liblmdb",
|
|
86
|
+
],
|
|
87
|
+
}, {
|
|
88
|
+
"sources": [
|
|
89
|
+
"dependencies/lmdb/libraries/liblmdb/mdb.c"
|
|
90
|
+
],
|
|
91
|
+
"include_dirs": [
|
|
92
|
+
"dependencies/lmdb/libraries/liblmdb",
|
|
93
|
+
],
|
|
94
|
+
}],
|
|
95
|
+
["enable_pointer_compression=='true'", {
|
|
96
|
+
"defines": ["V8_COMPRESS_POINTERS", "V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE"],
|
|
97
|
+
}],
|
|
98
|
+
['runtime=="electron"', {
|
|
99
|
+
"defines": ["NODE_RUNTIME_ELECTRON=1"]
|
|
100
|
+
}],
|
|
101
|
+
["enable_v8!='false'", {
|
|
102
|
+
"defines": ["ENABLE_V8_API=1"],
|
|
103
|
+
}],
|
|
104
|
+
["enable_fast_api_calls=='true'", {
|
|
105
|
+
"defines": ["ENABLE_FAST_API_CALLS=1"],
|
|
106
|
+
}],
|
|
107
|
+
["use_robust=='true'", {
|
|
108
|
+
"defines": ["MDB_USE_ROBUST"],
|
|
109
|
+
}, {
|
|
110
|
+
"defines": ["MDB_USE_ROBUST=0"],
|
|
111
|
+
}],
|
|
112
|
+
],
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
}
|
package/build/Release/lmdb.node
CHANGED
|
Binary file
|