[![license](https://img.shields.io/badge/license-MIT-brightgreen)](LICENSE)
[![npm version](https://img.shields.io/npm/v/lmdb.svg?style=flat-square)](https://www.npmjs.org/package/lmdb)
[![npm downloads](https://img.shields.io/npm/dw/lmdb)](https://www.npmjs.org/package/lmdb)
[![get](https://img.shields.io/badge/get-8.5%20MOPS-yellow)](README.md)
[![put](https://img.shields.io/badge/put-1.7%20MOPS-yellow)](README.md)
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:
* High-performance translation of JS values and data structures to/from binary key/value data
* Queueing asynchronous off-thread write operations with promise-based API
* Simple transaction management
* Iterable queries/cursors
* Record versioning and optimistic locking for scalability/concurrency
* 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>
* And ridiculously fast and efficient, with integrated (de)serialization, data retrieval can be several times faster than `JSON` alone
`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 our [clinical medical research](https://drevidence.com).
<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>
<a href="https://parceljs.org/"><img src="https://parceljs.org/avatar.633bb25a.avif" width="56" align="right"></a>
<a href="https://harperdb.io/"><img src="./assets/harperdb.png" width="55" align="right"/></a>
<a href="https://www.gatsbyjs.com/"><img src="./assets/gatsby.png" width="60" align="right"/></a>
This library is published to the NPM package `lmdb` (the 1.x versions were published to `lmdb-store`), and can be installed with:
```
npm install lmdb
```
`lmdb-js` is based on the Node-API for maximum compatility across all supported Node versions and futue 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`.
In Deno, this package could be directly used from the [deno.land `lmdb` module](https://deno.land/x/lmdb/mod.ts), but Node-API support is currently in-progress, so probably will require Deno v1.24+ (for older versions of Deno, you can use `lmdb-js` v2.2.x).
This library has minimal, tightly-controlled, and maintained dependencies to ensure stability, security, and efficiency. It supports both native ESM and CJS usage.
## Design
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.
`lmdb-js` is designed for synchronous reads, and asynchronous writes. In idiomatic NodeJS and Deno 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.
With the default sync'ing 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 has been writted 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 sync'ed operations, preserving both the durability/safety of the transactions and unparalled performance.
This library supports and encourages the use of conditional writes; this allows for atomic operations that are dependendent 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.
This library automatically handles automatically database growth, expanding file size with a smart heuristic that minimizes file fragmentation (as you would expect from a database).
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.
## Usage
An LMDB database instance is created by using `open` export from the main module:
```js
import { open } from 'lmdb'; // or require
let myDB = open({
path: 'my-db',
// any options go here, we can turn on compression like this:
compression: true,
});
await myDB.put('greeting', { someText: 'Hello, World!' });
myDB.get('greeting').someText // 'Hello, World!'
// or
myDB.transaction(() => {
myDB.put('greeting', { someText: 'Hello, World!' });
myDB.get('greeting').someText // 'Hello, World!'
});
```
(see database options below for more options)
Once you have opened a database, you can store and retrieve values using keys:
### Values
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 an optionally supported. Values are stored and retrieved according 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:
* `msgpack` (default) - All values are stored by serializing the value as MessagePack (using the [msgpackr](https://github.com/kriszyp/msgpackr) package). Values
没有合适的资源?快使用搜索试试~ 我知道了~
计算机图形学大作业:城市三维建模
共5959个文件
js:3500个
ts:990个
json:329个
需积分: 5 7 下载量 10 浏览量
2023-03-08
16:24:13
上传
评论
收藏 162.89MB ZIP 举报
温馨提示
将DWG格式的文件在网页中立体显示是一个需要运用前端技术的有趣项目。在此项目中,我们需要将DWG文件转换为WebGL格式,并通过在网页中渲染WebGL模型来展示三维效果。 首先,我们需要使用一些工具来将DWG文件转换为WebGL格式,例如Autodesk Forge、Three.js等。这些工具可以将DWG文件转换为包含顶点、纹理、材质等信息的JSON或GLTF格式。然后,我们可以通过JavaScript将这些数据加载到WebGL渲染引擎中,并进行渲染。 接下来,我们需要考虑如何在网页中呈现这个三维模型。我们可以使用canvas标签来创建WebGL渲染上下文,并在上面渲染模型。为了使模型可以交互,我们可以使用鼠标或触摸事件来控制摄像机位置和视角。我们还可以添加一些用户界面元素,例如控制面板、信息提示等,以增强用户体验。 为了使模型能够在不同的设备和浏览器中正常运行,我们还需要考虑浏览器兼容性和性能优化。例如,我们可以使用响应式设计来适配不同的屏幕大小和设备类型。我们还可以使用贴图压缩、模型优化等技术来减小模型文件的大小,提高渲染性能。
资源推荐
资源详情
资源评论
收起资源包目录
计算机图形学大作业:城市三维建模 (5959个子文件)
mdb_load.1 3KB
mdb_dump.1 3KB
mdb_load.1 3KB
mdb_dump.1 2KB
mdb_stat.1 2KB
mdb_copy.1 2KB
mdb_stat.1 2KB
mdb_copy.1 2KB
mdb_drop.1 1KB
mdb_drop.1 1KB
1eeb6fa8dd665430 318KB
3edc0141a7cb665b 318KB
ac62ef6dc8436cf6 318KB
acorn 298B
acorn 60B
.babelrc 102B
.babelrc 42B
drone_costum.blend 1.15MB
drone_costum.blend1 1.15MB
range.bnf 619B
browserslist 306B
browserslist-lint 326B
mdb.c 360KB
mdb.c 327KB
lz4.c 105KB
lz4frame.c 80KB
lz4hc.c 69KB
xxhash.c 34KB
mdb_load.c 13KB
mdb_load.c 12KB
midl.c 8KB
midl.c 8KB
mdb_dump.c 7KB
mdb_stat.c 7KB
mdb_dump.c 7KB
mdb_stat.c 7KB
mtest_enc.c 6KB
mtest_enc2.c 6KB
mtest.c 6KB
mtest.c 6KB
mtest_remap.c 6KB
chacha8.c 5KB
mtest4.c 5KB
mtest4.c 5KB
mtest6.c 4KB
mtest6.c 4KB
mtest5.c 4KB
mtest5.c 4KB
mtest3.c 4KB
mtest3.c 4KB
crypto.c 4KB
mtest2.c 4KB
mtest2.c 4KB
mdb_drop.c 3KB
mdb_drop.c 3KB
mdb_copy.c 3KB
module.c 2KB
mdb_copy.c 2KB
windows.c 2KB
nothing.c 0B
nothing.c 0B
cae00ae0f2eaed40 318KB
FSEventsBackend.cc 10KB
WatchmanBackend.cc 8KB
WindowsBackend.cc 8KB
BSER.cc 8KB
InotifyBackend.cc 7KB
binding.cc 6KB
Watcher.cc 5KB
DirTree.cc 4KB
Backend.cc 3KB
legacy.cc 2KB
win_utils.cc 1KB
fts.cc 1KB
BruteForceBackend.cc 977B
three.cjs 1.09MB
node.cjs 98KB
index.cjs 85KB
index-no-eval.cjs 72KB
index.cjs 69KB
index.cjs 62KB
unpack-no-eval.cjs 35KB
Float16Array.cjs 27KB
index.cjs 10KB
primordials.cjs 9KB
index.cjs 9KB
is.cjs 3KB
converter.cjs 2KB
messages.cjs 2KB
spec.cjs 2KB
arrayIterator.cjs 2KB
brand.cjs 900B
DataView.cjs 748B
index.cjs 552B
hfround.cjs 457B
set-optional-deps.cjs 456B
node.cjs 443B
isTypedArray.cjs 332B
exit.cjs 249B
config.cjs 38B
共 5959 条
- 1
- 2
- 3
- 4
- 5
- 6
- 60
资源评论
yyhhhuuuuu
- 粉丝: 7
- 资源: 100
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功