From a19927667ab40ca14d15bdb62c700b62b8a86b91 Mon Sep 17 00:00:00 2001 From: ralphtheninja Date: Mon, 19 Jan 2015 15:15:16 +0100 Subject: [PATCH 01/32] abstract-leveldown ~2.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 39082817..3cb63210 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ ], "main": "leveldown.js", "dependencies": { - "abstract-leveldown": "~2.0.0", + "abstract-leveldown": "~2.1.0", "bindings": "~1.2.1", "fast-future": "~1.0.0", "nan": "~1.5.0" From b57827cd2985d39472443826d881e9fb2a778a08 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Sun, 22 Mar 2015 18:09:25 +0100 Subject: [PATCH 02/32] use n instead of nvm for working iojs support --- .travis.yml | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2dc68bc3..d9284578 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,30 @@ -language: node_js -node_js: - - "0.10" -branches: - only: - - master -notifications: - email: - - rod@vagg.org -script: npm test +language: c before_install: - - npm install -g npm@latest + - rm -rf ~/.nvm + - wget https://raw.githubusercontent.com/visionmedia/n/master/bin/n -qO n + - chmod +x n + - sudo cp n /usr/local/bin/n + - sudo chmod -R a+xw /usr/local + - n --version + +script: + - n 0.10 + - node -v; which node; npm -v; which npm + - JOBS=max npm install + - npm test && rm -rf node_modules/ + + - n latest + - node -v; which node; npm -v; which npm + - JOBS=max npm install + - npm test && rm -rf node_modules/ + - n io latest + - iojs -v; which iojs; npm -v; which npm + - JOBS=max npm install + - npm test + +notifications: + email: + - rod@vagg.org + - ralphtheninja@riseup.net From 71f4e6b0809d7be5a81135ee51c6ba5931c87353 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Sun, 22 Mar 2015 19:53:41 +0100 Subject: [PATCH 03/32] run node-gyp in the postinstall phase if `preinstall` script is not set, then `npm` will default that to `node-gyp rebuild` *if* there is a binding.gyp file present. This is problematic because: If we want to run node-gyp on as many cores as possible, we can do that by simply overriding the `preinstall` script, like: ```json "scripts": { "preinstall": "JOBS=max node-gyp rebuild" } ``` But since we depend on `nan` to exist for doing this (we build up the include path by require('nan')) this fails, since nan is not there if the node_modules folder is empty. By moving the build to `postinstall` we can know for sure that `nan` will be there before we run `node-gyp`. To prevent `npm` from not running default version of `preinstall`, we just run `true` (yes a bit hacky) --- .travis.yml | 6 +++--- package.json | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index d9284578..e54401d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,17 +11,17 @@ before_install: script: - n 0.10 - node -v; which node; npm -v; which npm - - JOBS=max npm install + - npm install - npm test && rm -rf node_modules/ - n latest - node -v; which node; npm -v; which npm - - JOBS=max npm install + - npm install - npm test && rm -rf node_modules/ - n io latest - iojs -v; which iojs; npm -v; which npm - - JOBS=max npm install + - npm install - npm test notifications: diff --git a/package.json b/package.json index 3cb63210..7cb09593 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,9 @@ "tap": "~0.4.12" }, "scripts": { - "test": "tap test/*-test.js --stderr" + "test": "tap test/*-test.js --stderr", + "preinstall": "true", + "postinstall": "JOBS=max node-gyp rebuild" }, "license": "MIT", "gypfile": true From 9cbf592bea2dc05df09d7a10a95fddec1943f75d Mon Sep 17 00:00:00 2001 From: Max Ogden Date: Sat, 25 Apr 2015 15:19:10 -0700 Subject: [PATCH 04/32] add documentation about snapshots --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index c6f81a9b..e4a1fcd2 100644 --- a/README.md +++ b/README.md @@ -265,6 +265,12 @@ Currently LevelDOWN does not track the state of the underlying LevelDB instance. LevelUP currently tracks and manages state and will prevent out-of-state operations from being send to LevelDOWN. If you use LevelDOWN directly then you must track and manage state for yourself. + +Snapshots +--------------- + +LevelDOWN exposes a feature of LevelDB called [snapshots](http://leveldb.googlecode.com/git-history/f779e7a5d89f853fc5224f9eb8103ca2b8f2f555/doc/index.html). This means that when you do e.g. `createReadStream` and `createWriteStream` at the same time, any data modified by the write stream will not affect data emitted from the read stream. In other words, a LevelDB Snapshot captures the latest state at the time the snapshot was created, enabling the snapshot to iterate or read the data without seeing any subsequent writes. Any read not performed on a snapshot will implicitly use the latest state. + Getting support --------------- From 8470a6367831b98cc601027a8cce433f0e0511ac Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Sun, 26 Apr 2015 14:28:24 +0200 Subject: [PATCH 05/32] s/rvagg\/node-/level\// --- README.md | 10 +++++----- package.json | 4 ++-- src/async.h | 6 +++--- src/batch_async.cc | 6 +++--- src/batch_async.h | 6 +++--- src/database.cc | 7 +++---- src/database.h | 6 +++--- src/database_async.cc | 6 +++--- src/database_async.h | 6 +++--- src/iterator.cc | 6 +++--- src/iterator.h | 6 +++--- src/iterator_async.cc | 6 +++--- src/iterator_async.h | 6 +++--- src/leveldown.cc | 6 +++--- src/leveldown.h | 6 +++--- src/leveldown_async.cc | 6 +++--- src/leveldown_async.h | 6 +++--- 17 files changed, 52 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index e4a1fcd2..a79f0cd2 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,11 @@ LevelDOWN A Low-level Node.js LevelDB binding ------------------------- -[![Build Status](https://secure.travis-ci.org/rvagg/node-leveldown.png)](http://travis-ci.org/rvagg/node-leveldown) +[![Build Status](https://secure.travis-ci.org/Level/leveldown.png)](http://travis-ci.org/Level/leveldown) [![NPM](https://nodei.co/npm/leveldown.png?stars&downloads&downloadRank)](https://nodei.co/npm/leveldown/) [![NPM](https://nodei.co/npm-dl/leveldown.png?months=6&height=3)](https://nodei.co/npm/leveldown/) -LevelDOWN was extracted from [LevelUP](https://github.com/rvagg/node-levelup) and now serves as a stand-alone binding for LevelDB. +LevelDOWN was extracted from [LevelUP](https://github.com/level/levelup) and now serves as a stand-alone binding for LevelDB. It is **strongly recommended** that you use LevelUP in preference to LevelDOWN unless you have measurable performance reasons to do so. LevelUP is optimised for usability and safety. Although we are working to improve the safety of the LevelDOWN interface it is still easy to crash your Node process if you don't do things in just the right way. @@ -25,7 +25,7 @@ Tested & supported platforms * **Solaris** (SmartOS & Nodejitsu) * **FreeBSD** * **Windows** - * Node 0.10 and above only, see [issue #5](https://github.com/rvagg/node-levelup/issues/5) for more info + * Node 0.10 and above only, see [issue #5](https://github.com/level/levelup/issues/5) for more info * See installation instructions for *node-gyp* dependencies [here](https://github.com/TooTallNate/node-gyp#installation), you'll need these (free) components from Microsoft to compile and run any native Node add-on in Windows. @@ -148,7 +148,7 @@ The `callback` function will be called with no arguments if the operation is suc ### leveldown#batch(operations[, options], callback) batch() is an instance method on an existing database object. Used for very fast bulk-write operations (both *put* and *delete*). The `operations` argument should be an `Array` containing a list of operations to be executed sequentially, although as a whole they are performed as an atomic operation inside LevelDB. Each operation is contained in an object having the following properties: `type`, `key`, `value`, where the *type* is either `'put'` or `'del'`. In the case of `'del'` the `'value'` property is ignored. Any entries with a `'key'` of `null` or `undefined` will cause an error to be returned on the `callback`. Any entries where the *type* is `'put'` that have a `'value'` of `undefined`, `null`, `[]`, `''` or `new Buffer(0)` will be stored as a zero-length character array and therefore be fetched during reads as either `''` or `new Buffer(0)` depending on how they are requested. -See [LevelUP](https://github.com/rvagg/node-levelup#batch) for full documentation on how this works in practice. +See [LevelUP](https://github.com/level/levelup#batch) for full documentation on how this works in practice. #### `options` @@ -289,7 +289,7 @@ LevelDOWN is an **OPEN Open Source Project**. This means that: > Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project. -See the [CONTRIBUTING.md](https://github.com/rvagg/node-leveldown/blob/master/CONTRIBUTING.md) file for more details. +See the [CONTRIBUTING.md](https://github.com/level/leveldown/blob/master/CONTRIBUTING.md) file for more details. ### Contributors diff --git a/package.json b/package.json index 7cb09593..ab83f234 100644 --- a/package.json +++ b/package.json @@ -19,9 +19,9 @@ ], "repository": { "type": "git", - "url": "https://github.com/rvagg/node-leveldown.git" + "url": "https://github.com/level/leveldown.git" }, - "homepage": "https://github.com/rvagg/node-leveldown", + "homepage": "https://github.com/level/leveldown", "keywords": [ "leveldb", "level" diff --git a/src/async.h b/src/async.h index 1be7ca26..54bf40c3 100644 --- a/src/async.h +++ b/src/async.h @@ -1,6 +1,6 @@ -/* Copyright (c) 2012-2014 LevelDOWN contributors - * See list at - * MIT License +/* Copyright (c) 2012-2015 LevelDOWN contributors + * See list at + * MIT License */ #ifndef LD_ASYNC_H diff --git a/src/batch_async.cc b/src/batch_async.cc index 92d911d9..c3863191 100644 --- a/src/batch_async.cc +++ b/src/batch_async.cc @@ -1,6 +1,6 @@ -/* Copyright (c) 2012-2014 LevelDOWN contributors - * See list at - * MIT License +/* Copyright (c) 2012-2015 LevelDOWN contributors + * See list at + * MIT License */ diff --git a/src/batch_async.h b/src/batch_async.h index 5323d1ac..218591fa 100644 --- a/src/batch_async.h +++ b/src/batch_async.h @@ -1,6 +1,6 @@ -/* Copyright (c) 2012-2014 LevelDOWN contributors - * See list at - * MIT License +/* Copyright (c) 2012-2015 LevelDOWN contributors + * See list at + * MIT License */ #ifndef LD_BATCH_ASYNC_H diff --git a/src/database.cc b/src/database.cc index bb5702a3..2f6497af 100644 --- a/src/database.cc +++ b/src/database.cc @@ -1,7 +1,6 @@ -/* Copyright (c) 2012-2014 LevelDOWN contributors - * See list at - * MIT License - * +/* Copyright (c) 2012-2015 LevelDOWN contributors + * See list at + * MIT License */ #include diff --git a/src/database.h b/src/database.h index c466a7b4..2517d093 100644 --- a/src/database.h +++ b/src/database.h @@ -1,6 +1,6 @@ -/* Copyright (c) 2012-2014 LevelDOWN contributors - * See list at - * MIT License +/* Copyright (c) 2012-2015 LevelDOWN contributors + * See list at + * MIT License */ #ifndef LD_DATABASE_H diff --git a/src/database_async.cc b/src/database_async.cc index 96943c0d..5ed674e2 100644 --- a/src/database_async.cc +++ b/src/database_async.cc @@ -1,6 +1,6 @@ -/* Copyright (c) 2012-2014 LevelDOWN contributors - * See list at - * MIT License +/* Copyright (c) 2012-2015 LevelDOWN contributors + * See list at + * MIT License */ #include diff --git a/src/database_async.h b/src/database_async.h index 3d8c040f..60b7d1b0 100644 --- a/src/database_async.h +++ b/src/database_async.h @@ -1,6 +1,6 @@ -/* Copyright (c) 2012-2014 LevelDOWN contributors - * See list at - * MIT License +/* Copyright (c) 2012-2015 LevelDOWN contributors + * See list at + * MIT License */ #ifndef LD_DATABASE_ASYNC_H diff --git a/src/iterator.cc b/src/iterator.cc index 180de6d4..005c2741 100644 --- a/src/iterator.cc +++ b/src/iterator.cc @@ -1,6 +1,6 @@ -/* Copyright (c) 2012-2014 LevelDOWN contributors - * See list at - * MIT License +/* Copyright (c) 2012-2015 LevelDOWN contributors + * See list at + * MIT License */ #include diff --git a/src/iterator.h b/src/iterator.h index d8ed5f2c..ae2b353a 100644 --- a/src/iterator.h +++ b/src/iterator.h @@ -1,6 +1,6 @@ -/* Copyright (c) 2012-2014 LevelDOWN contributors - * See list at - * MIT License +/* Copyright (c) 2012-2015 LevelDOWN contributors + * See list at + * MIT License */ #ifndef LD_ITERATOR_H diff --git a/src/iterator_async.cc b/src/iterator_async.cc index f3db790b..fffbbd4c 100644 --- a/src/iterator_async.cc +++ b/src/iterator_async.cc @@ -1,6 +1,6 @@ -/* Copyright (c) 2012-2014 LevelDOWN contributors - * See list at - * MIT License +/* Copyright (c) 2012-2015 LevelDOWN contributors + * See list at + * MIT License */ #include diff --git a/src/iterator_async.h b/src/iterator_async.h index edb8f4d6..9d6c7a3c 100644 --- a/src/iterator_async.h +++ b/src/iterator_async.h @@ -1,6 +1,6 @@ -/* Copyright (c) 2012-2014 LevelDOWN contributors - * See list at - * MIT License +/* Copyright (c) 2012-2015 LevelDOWN contributors + * See list at + * MIT License */ #ifndef LD_ITERATOR_ASYNC_H diff --git a/src/leveldown.cc b/src/leveldown.cc index 20baf3d2..2a4ed317 100644 --- a/src/leveldown.cc +++ b/src/leveldown.cc @@ -1,6 +1,6 @@ -/* Copyright (c) 2012-2014 LevelDOWN contributors - * See list at - * MIT License +/* Copyright (c) 2012-2015 LevelDOWN contributors + * See list at + * MIT License */ #include diff --git a/src/leveldown.h b/src/leveldown.h index cdeee4fc..a704c066 100644 --- a/src/leveldown.h +++ b/src/leveldown.h @@ -1,6 +1,6 @@ -/* Copyright (c) 2012-2014 LevelDOWN contributors - * See list at - * MIT License +/* Copyright (c) 2012-2015 LevelDOWN contributors + * See list at + * MIT License */ #ifndef LD_LEVELDOWN_H #define LD_LEVELDOWN_H diff --git a/src/leveldown_async.cc b/src/leveldown_async.cc index 58726596..675a2347 100644 --- a/src/leveldown_async.cc +++ b/src/leveldown_async.cc @@ -1,6 +1,6 @@ -/* Copyright (c) 2012-2014 LevelDOWN contributors - * See list at - * MIT License +/* Copyright (c) 2012-2015 LevelDOWN contributors + * See list at + * MIT License */ #include diff --git a/src/leveldown_async.h b/src/leveldown_async.h index eb1b844f..689342dc 100644 --- a/src/leveldown_async.h +++ b/src/leveldown_async.h @@ -1,6 +1,6 @@ -/* Copyright (c) 2012-2014 LevelDOWN contributors - * See list at - * MIT License +/* Copyright (c) 2012-2015 LevelDOWN contributors + * See list at + * MIT License */ #ifndef LD_LEVELDOWN_ASYNC_H From 9215bf5a0aece59a361dc901c9149cef26a4ddd1 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Sun, 26 Apr 2015 15:02:07 +0200 Subject: [PATCH 06/32] Revert "run node-gyp in the postinstall phase" This reverts commit 71f4e6b0809d7be5a81135ee51c6ba5931c87353. --- .travis.yml | 6 +++--- package.json | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index e54401d5..d9284578 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,17 +11,17 @@ before_install: script: - n 0.10 - node -v; which node; npm -v; which npm - - npm install + - JOBS=max npm install - npm test && rm -rf node_modules/ - n latest - node -v; which node; npm -v; which npm - - npm install + - JOBS=max npm install - npm test && rm -rf node_modules/ - n io latest - iojs -v; which iojs; npm -v; which npm - - npm install + - JOBS=max npm install - npm test notifications: diff --git a/package.json b/package.json index ab83f234..24afe61b 100644 --- a/package.json +++ b/package.json @@ -43,9 +43,7 @@ "tap": "~0.4.12" }, "scripts": { - "test": "tap test/*-test.js --stderr", - "preinstall": "true", - "postinstall": "JOBS=max node-gyp rebuild" + "test": "tap test/*-test.js --stderr" }, "license": "MIT", "gypfile": true From 00bde585a06600880ad21848767ab9086d1e172b Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Sun, 26 Apr 2015 15:12:32 +0200 Subject: [PATCH 07/32] 1.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 24afe61b..d6c75557 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "leveldown", "description": "A Node.js LevelDB binding, primary backend for LevelUP", - "version": "1.0.1", + "version": "1.0.2", "contributors": [ "Rod Vagg (https://github.com/rvagg)", "John Chesley (https://github.com/chesles/)", From 5fa781b7e7f5f75dc5e8f0ec9c96d5dc8e66baae Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Sun, 26 Apr 2015 15:25:39 +0200 Subject: [PATCH 08/32] update CHANGELOG.md (using changelog-maker) --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a01aa842..246d2750 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +### 1.0.2 Apr 26 2015 + * [[`8470a63678`](https://github.com/level/leveldown/commit/8470a63678)] - s/rvagg\/node-/level\// (Lars-Magnus Skog) + * [[`9cbf592bea`](https://github.com/level/leveldown/commit/9cbf592bea)] - add documentation about snapshots (Max Ogden) + * [[`b57827cd29`](https://github.com/level/leveldown/commit/b57827cd29)] - use n instead of nvm for working iojs support (Lars-Magnus Skog) + * [[`a19927667a`](https://github.com/level/leveldown/commit/a19927667a)] - abstract-leveldown ~2.1.0 (ralphtheninja) + * [[`95ccdf0850`](https://github.com/level/leveldown/commit/95ccdf0850)] - update logo and copyright (Lars-Magnus Skog) + * [[`09e89d7abb`](https://github.com/level/leveldown/commit/09e89d7abb)] - updated my email (ralphtheninja) + +### 1.0.1 Jan 16 2015 + * [[`6df3ecd6f5`](https://github.com/level/leveldown/commit/6df3ecd6f5)] - nan 1.5 for io.js support (Rod Vagg) + * [[`5198231a88`](https://github.com/level/leveldown/commit/5198231a88)] - Fix LevelDB builds for modern gcc versions (Sharvil Nanavati) + ### 1.0.0 Aug 26 2014 * NAN@1.3 for Node 0.11.13+ support (@rvagg) * Allow writing empty values: null, undefined, '', [] and Buffer(0). Entries come out as '' or Buffer(0) (@ggreer, @juliangruber, @rvagg) From 03fbbfb99f9638e46c5ba13c303e8a62d8b07136 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Mon, 27 Apr 2015 14:32:33 +0200 Subject: [PATCH 09/32] fix bench/db-bench.js --- bench/db-bench.js | 62 +++++++++++++++++++++++------------------------ package.json | 2 ++ 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/bench/db-bench.js b/bench/db-bench.js index e81ac66d..0f155157 100755 --- a/bench/db-bench.js +++ b/bench/db-bench.js @@ -1,40 +1,36 @@ #!/usr/bin/env node -const leveldown = require('../') - , fs = require('fs') - , du = require('du') - , rimraf = require('rimraf') +const leveldown = require('../') + , fs = require('fs') + , du = require('du') + , rimraf = require('rimraf') - , argv = require('optimist').argv + , argv = require('optimist').argv - , options = { + , options = { benchmark : argv.benchmark , useExisting : argv.use_existing - , db : argv.db + , db : argv.db || __dirname + '/db' , num : argv.num || 1000000 , concurrency : argv.concurrency || 4 , cacheSize : argv.cacheSize || 8 , writeBufferSize : argv.writeBufferSize || 4 , valueSize : argv.valueSize || 100 - , timingOutput : argv.timingOutput + , timingOutput : argv.timingOutput || __dirname + '/timingOutput' , throughputOutput : argv.throughputOutput } - , randomData = require('./random-data')() - , keyTmpl = '0000000000000000' + , randomString = require('slump').string + , keyTmpl = '0000000000000000' if (!options.useExisting) { leveldown.destroy(options.db, function () {}) } var db = leveldown(options.db) - , timesStream = options.timingOutput - && fs.createWriteStream(options.timingOutput, 'utf8') -// , throughputStream = options.throughputOutput -// && fs.createWriteStream(options.throughputOutput, 'utf8') + , timesStream = fs.createWriteStream(options.timingOutput, 'utf8') -// make a 16 char padded key -function makeKey () { +function make16CharPaddedKey () { var r = Math.floor(Math.random() * options.num) , k = keyTmpl + r return k.substr(k.length - 16) @@ -42,17 +38,7 @@ function makeKey () { timesStream.write('Elapsed (ms), Entries, Bytes, Last 1000 Avg Time, MB/s\n') -setTimeout(function () { - db.open({ - errorIfExists : false - , createIfMissing : true - , cacheSize : options.cacheSize << 20 - , writeBufferSize : options.writeBufferSize << 20 - }, function (err) { - - if (err) - throw err - +function start () { var inProgress = 0 , totalWrites = 0 , totalBytes = 0 @@ -103,19 +89,16 @@ setTimeout(function () { + ',' + (Math.floor(((totalBytes / 1048576) / (elapsed / 1000)) * 100) / 100) + '\n') timesAccum = 0 - //timesStream.write(writeBuf) - //writeBuf = '' } var time = process.hrtime() - db.put(makeKey(), randomData.generate(options.valueSize), function (err) { + db.put(make16CharPaddedKey(), randomString({ length: options.valueSize }), function (err) { if (err) throw err totalBytes += keyTmpl.length + options.valueSize timesAccum += process.hrtime(time)[1] - //writeBuf += (Date.now() - startTime) + ',' + process.hrtime(time)[1] + '\n' inProgress-- process.nextTick(write) }) @@ -123,4 +106,19 @@ setTimeout(function () { for (var i = 0; i < options.concurrency; i++) write() -})}, 500) +} + +setTimeout(function () { + db.open({ + errorIfExists : false + , createIfMissing : true + , cacheSize : options.cacheSize << 20 + , writeBufferSize : options.writeBufferSize << 20 + }, function (err) { + if (err) + throw err + + start() + + }) +}, 500) diff --git a/package.json b/package.json index d6c75557..e6d7b1f4 100644 --- a/package.json +++ b/package.json @@ -38,8 +38,10 @@ "mkfiletree": "~0.0.1", "monotonic-timestamp": "~0.0.8", "node-gyp": "~1.0.1", + "optimist": "~0.6.1", "readfiletree": "~0.0.1", "rimraf": "~2.2.8", + "slump": "~2.0.0", "tap": "~0.4.12" }, "scripts": { From ca9101542a8320cdd0da91bdd7d131bb0b4552b3 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Mon, 27 Apr 2015 15:23:16 +0200 Subject: [PATCH 10/32] fix write-random.js, use leveldown instead of lmdb --- bench/write-random.js | 6 +----- bench/write-sorted.js | 6 +----- package.json | 1 + 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/bench/write-random.js b/bench/write-random.js index a8d419f3..a56a321c 100644 --- a/bench/write-random.js +++ b/bench/write-random.js @@ -1,4 +1,4 @@ -const leveldown = require('../../lmdb/') +const leveldown = require('../') , crypto = require('crypto') , fs = require('fs') , du = require('du') @@ -31,15 +31,12 @@ db.open(function (err) { var inProgress = 0 , totalWrites = 0 , startTime = Date.now() - //, timesTotal = 0 , writeBuf = '' function write() { if (totalWrites % 100000 == 0) console.log(inProgress, totalWrites) if (totalWrites % 1000 == 0) { - //timesStream.write((Date.now() - startTime) + ',' + Math.floor(timesTotal / 1000) + '\n') - //timesTotal = 0 timesStream.write(writeBuf) writeBuf = '' } @@ -56,7 +53,6 @@ db.open(function (err) { db.put(uuid.v4(), data, function (err) { if (err) throw err - //timesTotal += process.hrtime(time)[1] writeBuf += (Date.now() - startTime) + ',' + process.hrtime(time)[1] + '\n' inProgress-- process.nextTick(write) diff --git a/bench/write-sorted.js b/bench/write-sorted.js index 766c2d49..74b0a158 100644 --- a/bench/write-sorted.js +++ b/bench/write-sorted.js @@ -31,15 +31,12 @@ db.open({ errorIfExists: true, createIfMissing: true }, function (err) { var inProgress = 0 , totalWrites = 0 , startTime = Date.now() - //, timesTotal = 0 , writeBuf = '' function write() { if (totalWrites % 100000 == 0) console.log(inProgress, totalWrites) if (totalWrites % 1000 == 0) { - //timesStream.write((Date.now() - startTime) + ',' + Math.floor(timesTotal / 1000) + '\n') - //timesTotal = 0 timesStream.write(writeBuf) writeBuf = '' } @@ -56,7 +53,6 @@ db.open({ errorIfExists: true, createIfMissing: true }, function (err) { db.put(timestamp(), data, function (err) { if (err) throw err - //timesTotal += process.hrtime(time)[1] writeBuf += (Date.now() - startTime) + ',' + process.hrtime(time)[1] + '\n' inProgress-- process.nextTick(write) @@ -66,4 +62,4 @@ db.open({ errorIfExists: true, createIfMissing: true }, function (err) { } write() -}) \ No newline at end of file +}) diff --git a/package.json b/package.json index e6d7b1f4..dbe4f140 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "mkfiletree": "~0.0.1", "monotonic-timestamp": "~0.0.8", "node-gyp": "~1.0.1", + "node-uuid": "~1.4.3", "optimist": "~0.6.1", "readfiletree": "~0.0.1", "rimraf": "~2.2.8", From 82479b689f00a05beac36ca7631e4e32fb9c87e0 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Fri, 1 May 2015 14:41:19 +0200 Subject: [PATCH 11/32] tap -> tape + faucet --- package.json | 5 +++-- test/approximate-size-test.js | 5 ++--- test/batch-test.js | 5 ++--- test/chained-batch-test.js | 5 ++--- test/cleanup-hanging-iterators-test.js | 4 ++-- test/close-test.js | 5 ++--- test/del-test.js | 5 ++--- test/destroy-test.js | 4 ++-- test/get-test.js | 5 ++--- test/getproperty-test.js | 4 ++-- test/iterator-recursion-test.js | 25 ++++++++++++------------- test/iterator-test.js | 5 ++--- test/leveldown-test.js | 5 ++--- test/{make-test.js => make.js} | 4 ++-- test/open-test.js | 5 ++--- test/port-libuv-fix-test.js | 2 +- test/put-get-del-test.js | 5 ++--- test/put-test.js | 5 ++--- test/ranges-test.js | 5 ++--- test/repair-test.js | 6 +++--- 20 files changed, 51 insertions(+), 63 deletions(-) rename test/{make-test.js => make.js} (94%) diff --git a/package.json b/package.json index dbe4f140..af9b5b23 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ }, "devDependencies": { "du": "~0.1.0", + "faucet": "0.0.1", "mkfiletree": "~0.0.1", "monotonic-timestamp": "~0.0.8", "node-gyp": "~1.0.1", @@ -43,10 +44,10 @@ "readfiletree": "~0.0.1", "rimraf": "~2.2.8", "slump": "~2.0.0", - "tap": "~0.4.12" + "tape": "~4.0.0" }, "scripts": { - "test": "tap test/*-test.js --stderr" + "test": "tape test/*-test.js | faucet" }, "license": "MIT", "gypfile": true diff --git a/test/approximate-size-test.js b/test/approximate-size-test.js index 788d10e1..31038a48 100644 --- a/test/approximate-size-test.js +++ b/test/approximate-size-test.js @@ -1,7 +1,6 @@ -const test = require('tap').test +const test = require('tape') , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , abstract = require('abstract-leveldown/abstract/approximate-size-test') -if (require.main === module) - abstract.all(leveldown, test, testCommon) \ No newline at end of file +abstract.all(leveldown, test, testCommon) diff --git a/test/batch-test.js b/test/batch-test.js index 4040eeac..c93e6eff 100644 --- a/test/batch-test.js +++ b/test/batch-test.js @@ -1,7 +1,6 @@ -const test = require('tap').test +const test = require('tape') , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , abstract = require('abstract-leveldown/abstract/batch-test') -if (require.main === module) - abstract.all(leveldown, test, testCommon) \ No newline at end of file +abstract.all(leveldown, test, testCommon) diff --git a/test/chained-batch-test.js b/test/chained-batch-test.js index 562f8685..cc20f9e4 100644 --- a/test/chained-batch-test.js +++ b/test/chained-batch-test.js @@ -1,7 +1,6 @@ -const test = require('tap').test +const test = require('tape') , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , abstract = require('abstract-leveldown/abstract/chained-batch-test') -if (require.main === module) - abstract.all(leveldown, test, testCommon) \ No newline at end of file +abstract.all(leveldown, test, testCommon) diff --git a/test/cleanup-hanging-iterators-test.js b/test/cleanup-hanging-iterators-test.js index f811b7db..3ed394e6 100644 --- a/test/cleanup-hanging-iterators-test.js +++ b/test/cleanup-hanging-iterators-test.js @@ -1,7 +1,7 @@ -const test = require('tap').test +const test = require('tape') , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') - , makeTest = require('./make-test') + , makeTest = require('./make') makeTest('test ended iterator', function (db, t, done) { // standard iterator with an end() properly called, easy diff --git a/test/close-test.js b/test/close-test.js index 3b9f9e79..ae5d3bf8 100644 --- a/test/close-test.js +++ b/test/close-test.js @@ -1,4 +1,4 @@ -const test = require('tap').test +const test = require('tape') , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , abstract = require('abstract-leveldown/abstract/close-test') @@ -19,5 +19,4 @@ module.exports.all = function (leveldown) { module.exports.tearDown() } -if (require.main === module) - module.exports.all(leveldown) \ No newline at end of file +module.exports.all(leveldown) diff --git a/test/del-test.js b/test/del-test.js index f1b12c9b..b21712be 100644 --- a/test/del-test.js +++ b/test/del-test.js @@ -1,7 +1,6 @@ -const test = require('tap').test +const test = require('tape') , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , abstract = require('abstract-leveldown/abstract/del-test') -if (require.main === module) - abstract.all(leveldown, test, testCommon) \ No newline at end of file +abstract.all(leveldown, test, testCommon) diff --git a/test/destroy-test.js b/test/destroy-test.js index aa970534..d1be840e 100644 --- a/test/destroy-test.js +++ b/test/destroy-test.js @@ -1,11 +1,11 @@ -const test = require('tap').test +const test = require('tape') , fs = require('fs') , path = require('path') , mkfiletree = require('mkfiletree') , readfiletree = require('readfiletree') , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') - , makeTest = require('./make-test') + , makeTest = require('./make') test('test argument-less destroy() throws', function (t) { t.throws( diff --git a/test/get-test.js b/test/get-test.js index 5423ea1b..52270ad3 100644 --- a/test/get-test.js +++ b/test/get-test.js @@ -1,7 +1,6 @@ -const test = require('tap').test +const test = require('tape') , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , abstract = require('abstract-leveldown/abstract/get-test') -if (require.main === module) - abstract.all(leveldown, test, testCommon) \ No newline at end of file +abstract.all(leveldown, test, testCommon) diff --git a/test/getproperty-test.js b/test/getproperty-test.js index db48946f..46bce118 100644 --- a/test/getproperty-test.js +++ b/test/getproperty-test.js @@ -1,4 +1,4 @@ -const test = require('tap').test +const test = require('tape') , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') @@ -54,4 +54,4 @@ test('test invalid getProperty("leveldb.sstables")', function (t) { test('tearDown', function (t) { db.close(testCommon.tearDown.bind(null, t)) -}) \ No newline at end of file +}) diff --git a/test/iterator-recursion-test.js b/test/iterator-recursion-test.js index ff2a780b..db18dab3 100644 --- a/test/iterator-recursion-test.js +++ b/test/iterator-recursion-test.js @@ -1,4 +1,4 @@ -const test = require('tap').test +const test = require('tape') , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , child_process = require('child_process') @@ -32,20 +32,19 @@ test('try to create an iterator with a blown stack', function (t) { // Reducing the stack size down from the default 984 for the child node // process makes it easier to trigger the bug condition. But making it too low // causes the child process to die for other reasons. - var opts = { execArgv: ["--stack-size=128"] } - , child = child_process.fork(__dirname + '/stack-blower.js', ["run"], opts) + var opts = { execArgv: [ '--stack-size=128' ] } + , child = child_process.fork(__dirname + '/stack-blower.js', [ 'run' ], opts) + + t.plan(2) child.on('message', function (m) { - t.ok(true, m) - child.disconnect() - - t.end() - }) - .on('exit', function (code, sig) { - t.ok(false, "Child exited with code=" + code + " sig=" + sig) + t.ok(true, m) + child.disconnect() + }) - t.end() - }) + child.on('exit', function (code, sig) { + t.equal(code, 0, 'child exited normally') + }) }) test('iterate over a large iterator with a large watermark', function (t) { @@ -69,4 +68,4 @@ test('iterate over a large iterator with a large watermark', function (t) { test('tearDown', function (t) { db.close(testCommon.tearDown.bind(null, t)) -}) \ No newline at end of file +}) diff --git a/test/iterator-test.js b/test/iterator-test.js index 18073f61..1c179a9b 100644 --- a/test/iterator-test.js +++ b/test/iterator-test.js @@ -1,7 +1,6 @@ -const test = require('tap').test +const test = require('tape') , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , abstract = require('abstract-leveldown/abstract/iterator-test') -if (require.main === module) - abstract.all(leveldown, test, testCommon) \ No newline at end of file +abstract.all(leveldown, test, testCommon) diff --git a/test/leveldown-test.js b/test/leveldown-test.js index d65e0783..11db1c38 100644 --- a/test/leveldown-test.js +++ b/test/leveldown-test.js @@ -1,6 +1,5 @@ -const test = require('tap').test +const test = require('tape') , leveldown = require('../') , abstract = require('abstract-leveldown/abstract/leveldown-test') -if (require.main === module) - abstract.args(leveldown, test) \ No newline at end of file +abstract.args(leveldown, test) diff --git a/test/make-test.js b/test/make.js similarity index 94% rename from test/make-test.js rename to test/make.js index 167027d2..aeccf3b4 100644 --- a/test/make-test.js +++ b/test/make.js @@ -1,4 +1,4 @@ -const test = require('tap').test +const test = require('tape') , testCommon = require('abstract-leveldown/testCommon') , cleanup = testCommon.cleanup , location = testCommon.location @@ -35,4 +35,4 @@ function makeTest (name, testFn) { }) } -module.exports = makeTest \ No newline at end of file +module.exports = makeTest diff --git a/test/open-test.js b/test/open-test.js index 4d849962..0da638a3 100644 --- a/test/open-test.js +++ b/test/open-test.js @@ -1,7 +1,6 @@ -const test = require('tap').test +const test = require('tape') , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , abstract = require('abstract-leveldown/abstract/open-test') -if (require.main === module) - abstract.all(leveldown, test, testCommon) \ No newline at end of file +abstract.all(leveldown, test, testCommon) diff --git a/test/port-libuv-fix-test.js b/test/port-libuv-fix-test.js index 089f1e66..300baa71 100644 --- a/test/port-libuv-fix-test.js +++ b/test/port-libuv-fix-test.js @@ -1,4 +1,4 @@ -const test = require('tap').test +const test = require('tape') , path = require('path') , fs = require('fs') diff --git a/test/put-get-del-test.js b/test/put-get-del-test.js index 631d886c..0f688585 100644 --- a/test/put-get-del-test.js +++ b/test/put-get-del-test.js @@ -1,4 +1,4 @@ -const test = require('tap').test +const test = require('tape') , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , fs = require('fs') @@ -6,5 +6,4 @@ const test = require('tap').test , testBuffer = fs.readFileSync(path.join(__dirname, 'data/testdata.bin')) , abstract = require('abstract-leveldown/abstract/put-get-del-test') -if (require.main === module) - abstract.all(leveldown, test, testCommon, testBuffer) +abstract.all(leveldown, test, testCommon, testBuffer) diff --git a/test/put-test.js b/test/put-test.js index f24997f9..e437f5ee 100644 --- a/test/put-test.js +++ b/test/put-test.js @@ -1,7 +1,6 @@ -const test = require('tap').test +const test = require('tape') , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , abstract = require('abstract-leveldown/abstract/put-test') -if (require.main === module) - abstract.all(leveldown, test, testCommon) \ No newline at end of file +abstract.all(leveldown, test, testCommon) diff --git a/test/ranges-test.js b/test/ranges-test.js index 59742d4e..7f16a2d0 100644 --- a/test/ranges-test.js +++ b/test/ranges-test.js @@ -1,7 +1,6 @@ -const test = require('tap').test +const test = require('tape') , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , abstract = require('abstract-leveldown/abstract/ranges-test') -if (require.main === module) - abstract.all(leveldown, test, testCommon) +abstract.all(leveldown, test, testCommon) diff --git a/test/repair-test.js b/test/repair-test.js index 225a3ac3..17f35148 100644 --- a/test/repair-test.js +++ b/test/repair-test.js @@ -1,11 +1,11 @@ -const test = require('tap').test +const test = require('tape') , fs = require('fs') , path = require('path') , mkfiletree = require('mkfiletree') , readfiletree = require('readfiletree') , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') - , makeTest = require('./make-test') + , makeTest = require('./make') test('test argument-less repair() throws', function (t) { t.throws( @@ -27,7 +27,7 @@ test('test callback-less, 1-arg, repair() throws', function (t) { test('test repair non-existant directory returns error', function (t) { leveldown.repair('/1/2/3/4', function (err) { - t.like(/no such/i, err, 'error on callback') + t.ok(/no such/i.test(err), 'error on callback') t.end() }) }) From 3412a4178c8dc139a6fbdd2ed47125eb402b9114 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Sat, 2 May 2015 12:17:26 +0200 Subject: [PATCH 12/32] 1.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index af9b5b23..b7ee2468 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "leveldown", "description": "A Node.js LevelDB binding, primary backend for LevelUP", - "version": "1.0.2", + "version": "1.0.3", "contributors": [ "Rod Vagg (https://github.com/rvagg)", "John Chesley (https://github.com/chesles/)", From b550c982911ff7de28cfd7ca765e5ad9e7b5794b Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Tue, 5 May 2015 03:09:47 +0200 Subject: [PATCH 13/32] update nan for iojs 2.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b7ee2468..d25a387d 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "abstract-leveldown": "~2.1.0", "bindings": "~1.2.1", "fast-future": "~1.0.0", - "nan": "~1.5.0" + "nan": "~1.8.4" }, "devDependencies": { "du": "~0.1.0", From b2bd73e6939a472d2e81116bd5e984b1eaa0d715 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Tue, 5 May 2015 03:17:16 +0200 Subject: [PATCH 14/32] 1.0.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d25a387d..0261dee5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "leveldown", "description": "A Node.js LevelDB binding, primary backend for LevelUP", - "version": "1.0.3", + "version": "1.0.4", "contributors": [ "Rod Vagg (https://github.com/rvagg)", "John Chesley (https://github.com/chesles/)", From 9064099fe7c32713ea759ee1d396ca5fd1a3764a Mon Sep 17 00:00:00 2001 From: Julian Gruber Date: Tue, 5 May 2015 10:42:15 +0200 Subject: [PATCH 15/32] pass db to abstractIterator so gc keeps it --- iterator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iterator.js b/iterator.js index 202c6d42..f3f5c1e3 100644 --- a/iterator.js +++ b/iterator.js @@ -3,7 +3,7 @@ const util = require('util') function Iterator (db, options) { - AbstractIterator.call(this, options) + AbstractIterator.call(this, db) this.binding = db.binding.iterator(options) this.cache = null @@ -51,4 +51,4 @@ Iterator.prototype._end = function (callback) { } -module.exports = Iterator \ No newline at end of file +module.exports = Iterator From aa4df49ba0d3841c5ae22889d1883b01101f24f7 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Tue, 5 May 2015 13:51:57 +0200 Subject: [PATCH 16/32] 1.0.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0261dee5..cd94f18d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "leveldown", "description": "A Node.js LevelDB binding, primary backend for LevelUP", - "version": "1.0.4", + "version": "1.0.5", "contributors": [ "Rod Vagg (https://github.com/rvagg)", "John Chesley (https://github.com/chesles/)", From 007550e7f71485e0a2b91717d4de22b31c32a816 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Tue, 5 May 2015 15:21:48 +0200 Subject: [PATCH 17/32] 1.0.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cd94f18d..3d6d03e3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "leveldown", "description": "A Node.js LevelDB binding, primary backend for LevelUP", - "version": "1.0.5", + "version": "1.0.6", "contributors": [ "Rod Vagg (https://github.com/rvagg)", "John Chesley (https://github.com/chesles/)", From f70b6576e7ef0ba5e0c7d786e4da7266f1ba0ca2 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Wed, 6 May 2015 17:40:21 +0200 Subject: [PATCH 18/32] update .travis.yml (nvm works on travis now) --- .travis.yml | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index d9284578..9661b5cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,30 +1,14 @@ -language: c +language: node_js before_install: - - rm -rf ~/.nvm - - wget https://raw.githubusercontent.com/visionmedia/n/master/bin/n -qO n - - chmod +x n - - sudo cp n /usr/local/bin/n - - sudo chmod -R a+xw /usr/local - - n --version + - export JOBS=max -script: - - n 0.10 - - node -v; which node; npm -v; which npm - - JOBS=max npm install - - npm test && rm -rf node_modules/ - - - n latest - - node -v; which node; npm -v; which npm - - JOBS=max npm install - - npm test && rm -rf node_modules/ +node_js: + - "2.0.0" + - "1.8.1" + - "0.12" + - "0.10" - - n io latest - - iojs -v; which iojs; npm -v; which npm - - JOBS=max npm install +script: - npm test -notifications: - email: - - rod@vagg.org - - ralphtheninja@riseup.net From 8cb90e6b6dc225febf2f7b4ab557678418c4ba09 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Tue, 12 May 2015 16:11:16 +0200 Subject: [PATCH 19/32] update abstract-leveldown --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3d6d03e3..07f5f817 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ ], "main": "leveldown.js", "dependencies": { - "abstract-leveldown": "~2.1.0", + "abstract-leveldown": "~2.2.1", "bindings": "~1.2.1", "fast-future": "~1.0.0", "nan": "~1.8.4" From fcdc46183e1c7dff4d584dbf52927757f2c20d68 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Tue, 12 May 2015 02:53:13 +0200 Subject: [PATCH 20/32] simplify location logic, let Database take care of allocation --- src/database.cc | 35 ++++++++++++----------------------- src/database.h | 11 +++++------ src/database_async.cc | 2 +- 3 files changed, 18 insertions(+), 30 deletions(-) diff --git a/src/database.cc b/src/database.cc index 2f6497af..f2c9e242 100644 --- a/src/database.cc +++ b/src/database.cc @@ -20,13 +20,13 @@ namespace leveldown { static v8::Persistent database_constructor; -Database::Database (NanUtf8String* location) : location(location) { - db = NULL; - currentIteratorId = 0; - pendingCloseWorker = NULL; - blockCache = NULL; - filterPolicy = NULL; -}; +Database::Database (v8::Handle from) + : location(new NanUtf8String(from)) + , db(NULL) + , currentIteratorId(0) + , pendingCloseWorker(NULL) + , blockCache(NULL) + , filterPolicy(NULL) {}; Database::~Database () { if (db != NULL) @@ -34,15 +34,12 @@ Database::~Database () { delete location; }; -NanUtf8String* Database::Location() { return location; } - /* Calls from worker threads, NO V8 HERE *****************************/ leveldb::Status Database::OpenDatabase ( leveldb::Options* options - , std::string location ) { - return leveldb::DB::Open(*options, location, &db); + return leveldb::DB::Open(*options, **location, &db); } leveldb::Status Database::PutToDatabase ( @@ -131,9 +128,7 @@ void Database::CloseDatabase () { NAN_METHOD(LevelDOWN) { NanScope(); - v8::Local location; - if (args.Length() != 0 && args[0]->IsString()) - location = args[0].As(); + v8::Local location = args[0].As(); NanReturnValue(Database::NewInstance(location)); } @@ -156,9 +151,7 @@ void Database::Init () { NAN_METHOD(Database::New) { NanScope(); - NanUtf8String* location = new NanUtf8String(args[0]); - - Database* obj = new Database(location); + Database* obj = new Database(args[0]); obj->Wrap(args.This()); NanReturnValue(args.This()); @@ -172,12 +165,8 @@ v8::Handle Database::NewInstance (v8::Local &location) { v8::Local constructorHandle = NanNew(database_constructor); - if (location.IsEmpty()) { - instance = constructorHandle->GetFunction()->NewInstance(0, NULL); - } else { - v8::Handle argv[] = { location }; - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - } + v8::Handle argv[] = { location }; + instance = constructorHandle->GetFunction()->NewInstance(1, argv); return NanEscapeScope(instance); } diff --git a/src/database.h b/src/database.h index 2517d093..c6579cb1 100644 --- a/src/database.h +++ b/src/database.h @@ -48,7 +48,7 @@ class Database : public node::ObjectWrap { static void Init (); static v8::Handle NewInstance (v8::Local &location); - leveldb::Status OpenDatabase (leveldb::Options* options, std::string location); + leveldb::Status OpenDatabase (leveldb::Options* options); leveldb::Status PutToDatabase ( leveldb::WriteOptions* options , leveldb::Slice key @@ -73,19 +73,18 @@ class Database : public node::ObjectWrap { const leveldb::Snapshot* NewSnapshot (); void ReleaseSnapshot (const leveldb::Snapshot* snapshot); void CloseDatabase (); - NanUtf8String* Location(); void ReleaseIterator (uint32_t id); - Database (NanUtf8String* location); + Database (v8::Handle from); ~Database (); private: - leveldb::DB* db; - const leveldb::FilterPolicy* filterPolicy; - leveldb::Cache* blockCache; NanUtf8String* location; + leveldb::DB* db; uint32_t currentIteratorId; void(*pendingCloseWorker); + leveldb::Cache* blockCache; + const leveldb::FilterPolicy* filterPolicy; std::map< uint32_t, leveldown::Iterator * > iterators; diff --git a/src/database_async.cc b/src/database_async.cc index 5ed674e2..2a97a3d6 100644 --- a/src/database_async.cc +++ b/src/database_async.cc @@ -51,7 +51,7 @@ OpenWorker::~OpenWorker () { } void OpenWorker::Execute () { - SetStatus(database->OpenDatabase(options, **(database->Location()))); + SetStatus(database->OpenDatabase(options)); } /** CLOSE WORKER **/ From 39c614a24f2d518fe469826f17fb84df20f337ab Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Sat, 9 May 2015 14:17:32 +0200 Subject: [PATCH 21/32] NanBooleanOptionValue -> BooleanOptionValue --- .gitignore | 1 + src/batch.cc | 3 ++- src/common.h | 29 +++++++++++++++++++++++++++++ src/database.cc | 18 +++++++++--------- src/iterator.cc | 13 +++++++------ 5 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 src/common.h diff --git a/.gitignore b/.gitignore index 43b07bd2..a3e4ea53 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ bench/ *.obj *.1sdk.pdb *.lastbuildstate +npm-debug.log diff --git a/src/batch.cc b/src/batch.cc index 32dfbe3f..b90f92ed 100644 --- a/src/batch.cc +++ b/src/batch.cc @@ -5,6 +5,7 @@ #include "database.h" #include "batch_async.h" #include "batch.h" +#include "common.h" namespace leveldown { @@ -47,7 +48,7 @@ NAN_METHOD(Batch::New) { optionsObj = v8::Local::Cast(args[1]); } - bool sync = NanBooleanOptionValue(optionsObj, NanNew("sync")); + bool sync = BooleanOptionValue(optionsObj, NanNew("sync")); Batch* batch = new Batch(database, sync); batch->Wrap(args.This()); diff --git a/src/common.h b/src/common.h new file mode 100644 index 00000000..fd5d28ce --- /dev/null +++ b/src/common.h @@ -0,0 +1,29 @@ +/* Copyright (c) 2012-2015 LevelDOWN contributors + * See list at + * MIT License + */ + +#ifndef LD_COMMON_H +#define LD_COMMON_H + +#include + +namespace leveldown { + +NAN_INLINE bool BooleanOptionValue(v8::Local options, + v8::Handle key, + bool def = false) { + if (def) { + return options.IsEmpty() + || !options->Has(key) + || options->Get(key)->BooleanValue(); + } else { + return !options.IsEmpty() + && options->Has(key) + && options->Get(key)->BooleanValue(); + } +} + +} // namespace leveldown + +#endif diff --git a/src/database.cc b/src/database.cc index 2f6497af..93d362dd 100644 --- a/src/database.cc +++ b/src/database.cc @@ -15,6 +15,7 @@ #include "database_async.h" #include "batch.h" #include "iterator.h" +#include "common.h" namespace leveldown { @@ -187,15 +188,14 @@ NAN_METHOD(Database::Open) { LD_METHOD_SETUP_COMMON(open, 0, 1) - bool createIfMissing = NanBooleanOptionValue( + bool createIfMissing = BooleanOptionValue( optionsObj , NanNew("createIfMissing") , true ); - bool errorIfExists = - NanBooleanOptionValue(optionsObj, NanNew("errorIfExists")); + bool errorIfExists = BooleanOptionValue(optionsObj, NanNew("errorIfExists")); bool compression = - NanBooleanOptionValue(optionsObj, NanNew("compression"), true); + BooleanOptionValue(optionsObj, NanNew("compression"), true); uint32_t cacheSize = NanUInt32OptionValue( optionsObj @@ -318,7 +318,7 @@ NAN_METHOD(Database::Put) { LD_STRING_OR_BUFFER_TO_SLICE(key, keyHandle, key) LD_STRING_OR_BUFFER_TO_SLICE(value, valueHandle, value) - bool sync = NanBooleanOptionValue(optionsObj, NanNew("sync")); + bool sync = BooleanOptionValue(optionsObj, NanNew("sync")); WriteWorker* worker = new WriteWorker( database @@ -346,8 +346,8 @@ NAN_METHOD(Database::Get) { v8::Local keyHandle = args[0].As(); LD_STRING_OR_BUFFER_TO_SLICE(key, keyHandle, key) - bool asBuffer = NanBooleanOptionValue(optionsObj, NanNew("asBuffer"), true); - bool fillCache = NanBooleanOptionValue(optionsObj, NanNew("fillCache"), true); + bool asBuffer = BooleanOptionValue(optionsObj, NanNew("asBuffer"), true); + bool fillCache = BooleanOptionValue(optionsObj, NanNew("fillCache"), true); ReadWorker* worker = new ReadWorker( database @@ -373,7 +373,7 @@ NAN_METHOD(Database::Delete) { v8::Local keyHandle = args[0].As(); LD_STRING_OR_BUFFER_TO_SLICE(key, keyHandle, key) - bool sync = NanBooleanOptionValue(optionsObj, NanNew("sync")); + bool sync = BooleanOptionValue(optionsObj, NanNew("sync")); DeleteWorker* worker = new DeleteWorker( database @@ -403,7 +403,7 @@ NAN_METHOD(Database::Batch) { LD_METHOD_SETUP_COMMON(batch, 1, 2) - bool sync = NanBooleanOptionValue(optionsObj, NanNew("sync")); + bool sync = BooleanOptionValue(optionsObj, NanNew("sync")); v8::Local array = v8::Local::Cast(args[0]); diff --git a/src/iterator.cc b/src/iterator.cc index 005c2741..b749c35b 100644 --- a/src/iterator.cc +++ b/src/iterator.cc @@ -9,6 +9,7 @@ #include "database.h" #include "iterator.h" #include "iterator_async.h" +#include "common.h" namespace leveldown { @@ -314,7 +315,7 @@ NAN_METHOD(Iterator::New) { if (args.Length() > 1 && args[2]->IsObject()) { optionsObj = v8::Local::Cast(args[2]); - reverse = NanBooleanOptionValue(optionsObj, NanNew("reverse")); + reverse = BooleanOptionValue(optionsObj, NanNew("reverse")); if (optionsObj->Has(NanNew("start")) && (node::Buffer::HasInstance(optionsObj->Get(NanNew("start"))) @@ -414,19 +415,19 @@ NAN_METHOD(Iterator::New) { } - bool keys = NanBooleanOptionValue(optionsObj, NanNew("keys"), true); - bool values = NanBooleanOptionValue(optionsObj, NanNew("values"), true); - bool keyAsBuffer = NanBooleanOptionValue( + bool keys = BooleanOptionValue(optionsObj, NanNew("keys"), true); + bool values = BooleanOptionValue(optionsObj, NanNew("values"), true); + bool keyAsBuffer = BooleanOptionValue( optionsObj , NanNew("keyAsBuffer") , true ); - bool valueAsBuffer = NanBooleanOptionValue( + bool valueAsBuffer = BooleanOptionValue( optionsObj , NanNew("valueAsBuffer") , true ); - bool fillCache = NanBooleanOptionValue(optionsObj, NanNew("fillCache")); + bool fillCache = BooleanOptionValue(optionsObj, NanNew("fillCache")); Iterator* iterator = new Iterator( database From 56def2d7c8a53e8af5b36aa635a00bf487aac8c8 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Sat, 9 May 2015 14:19:10 +0200 Subject: [PATCH 22/32] NanUInt32OptionValue -> UInt32OptionValue --- src/common.h | 10 ++++++++++ src/database.cc | 10 +++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/common.h b/src/common.h index fd5d28ce..78b9de3d 100644 --- a/src/common.h +++ b/src/common.h @@ -24,6 +24,16 @@ NAN_INLINE bool BooleanOptionValue(v8::Local options, } } +NAN_INLINE uint32_t UInt32OptionValue(v8::Local options, + v8::Handle key, + uint32_t def) { + return !options.IsEmpty() + && options->Has(key) + && options->Get(key)->IsNumber() + ? options->Get(key)->Uint32Value() + : def; +} + } // namespace leveldown #endif diff --git a/src/database.cc b/src/database.cc index 93d362dd..c662a38a 100644 --- a/src/database.cc +++ b/src/database.cc @@ -197,27 +197,27 @@ NAN_METHOD(Database::Open) { bool compression = BooleanOptionValue(optionsObj, NanNew("compression"), true); - uint32_t cacheSize = NanUInt32OptionValue( + uint32_t cacheSize = UInt32OptionValue( optionsObj , NanNew("cacheSize") , 8 << 20 ); - uint32_t writeBufferSize = NanUInt32OptionValue( + uint32_t writeBufferSize = UInt32OptionValue( optionsObj , NanNew("writeBufferSize") , 4 << 20 ); - uint32_t blockSize = NanUInt32OptionValue( + uint32_t blockSize = UInt32OptionValue( optionsObj , NanNew("blockSize") , 4096 ); - uint32_t maxOpenFiles = NanUInt32OptionValue( + uint32_t maxOpenFiles = UInt32OptionValue( optionsObj , NanNew("maxOpenFiles") , 1000 ); - uint32_t blockRestartInterval = NanUInt32OptionValue( + uint32_t blockRestartInterval = UInt32OptionValue( optionsObj , NanNew("blockRestartInterval") , 16 From ca1f4746c4528746b64cc7c4e20e236140c28c26 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Sat, 9 May 2015 14:27:20 +0200 Subject: [PATCH 23/32] refactor BooleanOptionValue --- src/common.h | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/common.h b/src/common.h index 78b9de3d..38b43312 100644 --- a/src/common.h +++ b/src/common.h @@ -13,15 +13,10 @@ namespace leveldown { NAN_INLINE bool BooleanOptionValue(v8::Local options, v8::Handle key, bool def = false) { - if (def) { - return options.IsEmpty() - || !options->Has(key) - || options->Get(key)->BooleanValue(); - } else { - return !options.IsEmpty() - && options->Has(key) - && options->Get(key)->BooleanValue(); - } + return !options.IsEmpty() + && options->Has(key) + ? options->Get(key)->BooleanValue() + : def; } NAN_INLINE uint32_t UInt32OptionValue(v8::Local options, From b56a86323eefea3b9bacc271bb31437ec2e70d23 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Sat, 9 May 2015 14:51:24 +0200 Subject: [PATCH 24/32] refactor NanNew() on strings into option value functions --- src/batch.cc | 2 +- src/common.h | 6 ++++-- src/database.cc | 53 +++++++++++++++++-------------------------------- src/iterator.cc | 20 ++++++------------- 4 files changed, 29 insertions(+), 52 deletions(-) diff --git a/src/batch.cc b/src/batch.cc index b90f92ed..081e0216 100644 --- a/src/batch.cc +++ b/src/batch.cc @@ -48,7 +48,7 @@ NAN_METHOD(Batch::New) { optionsObj = v8::Local::Cast(args[1]); } - bool sync = BooleanOptionValue(optionsObj, NanNew("sync")); + bool sync = BooleanOptionValue(optionsObj, "sync"); Batch* batch = new Batch(database, sync); batch->Wrap(args.This()); diff --git a/src/common.h b/src/common.h index 38b43312..af844990 100644 --- a/src/common.h +++ b/src/common.h @@ -11,8 +11,9 @@ namespace leveldown { NAN_INLINE bool BooleanOptionValue(v8::Local options, - v8::Handle key, + const char* _key, bool def = false) { + v8::Handle key = NanNew(_key); return !options.IsEmpty() && options->Has(key) ? options->Get(key)->BooleanValue() @@ -20,8 +21,9 @@ NAN_INLINE bool BooleanOptionValue(v8::Local options, } NAN_INLINE uint32_t UInt32OptionValue(v8::Local options, - v8::Handle key, + const char* _key, uint32_t def) { + v8::Handle key = NanNew(_key); return !options.IsEmpty() && options->Has(key) && options->Get(key)->IsNumber() diff --git a/src/database.cc b/src/database.cc index c662a38a..6df9c14b 100644 --- a/src/database.cc +++ b/src/database.cc @@ -188,38 +188,21 @@ NAN_METHOD(Database::Open) { LD_METHOD_SETUP_COMMON(open, 0, 1) - bool createIfMissing = BooleanOptionValue( - optionsObj - , NanNew("createIfMissing") - , true - ); - bool errorIfExists = BooleanOptionValue(optionsObj, NanNew("errorIfExists")); - bool compression = - BooleanOptionValue(optionsObj, NanNew("compression"), true); + bool createIfMissing = BooleanOptionValue(optionsObj, "createIfMissing", true); + bool errorIfExists = BooleanOptionValue(optionsObj, "errorIfExists"); + bool compression = BooleanOptionValue(optionsObj, "compression", true); - uint32_t cacheSize = UInt32OptionValue( - optionsObj - , NanNew("cacheSize") - , 8 << 20 - ); + uint32_t cacheSize = UInt32OptionValue(optionsObj, "cacheSize", 8 << 20); uint32_t writeBufferSize = UInt32OptionValue( optionsObj - , NanNew("writeBufferSize") + , "writeBufferSize" , 4 << 20 ); - uint32_t blockSize = UInt32OptionValue( - optionsObj - , NanNew("blockSize") - , 4096 - ); - uint32_t maxOpenFiles = UInt32OptionValue( - optionsObj - , NanNew("maxOpenFiles") - , 1000 - ); + uint32_t blockSize = UInt32OptionValue(optionsObj, "blockSize", 4096); + uint32_t maxOpenFiles = UInt32OptionValue(optionsObj, "maxOpenFiles", 1000); uint32_t blockRestartInterval = UInt32OptionValue( optionsObj - , NanNew("blockRestartInterval") + , "blockRestartInterval" , 16 ); @@ -315,10 +298,10 @@ NAN_METHOD(Database::Put) { v8::Local keyHandle = args[0].As(); v8::Local valueHandle = args[1].As(); - LD_STRING_OR_BUFFER_TO_SLICE(key, keyHandle, key) - LD_STRING_OR_BUFFER_TO_SLICE(value, valueHandle, value) + LD_STRING_OR_BUFFER_TO_SLICE(key, keyHandle, key); + LD_STRING_OR_BUFFER_TO_SLICE(value, valueHandle, value); - bool sync = BooleanOptionValue(optionsObj, NanNew("sync")); + bool sync = BooleanOptionValue(optionsObj, "sync"); WriteWorker* worker = new WriteWorker( database @@ -344,10 +327,10 @@ NAN_METHOD(Database::Get) { LD_METHOD_SETUP_COMMON(get, 1, 2) v8::Local keyHandle = args[0].As(); - LD_STRING_OR_BUFFER_TO_SLICE(key, keyHandle, key) + LD_STRING_OR_BUFFER_TO_SLICE(key, keyHandle, key); - bool asBuffer = BooleanOptionValue(optionsObj, NanNew("asBuffer"), true); - bool fillCache = BooleanOptionValue(optionsObj, NanNew("fillCache"), true); + bool asBuffer = BooleanOptionValue(optionsObj, "asBuffer", true); + bool fillCache = BooleanOptionValue(optionsObj, "fillCache", true); ReadWorker* worker = new ReadWorker( database @@ -371,9 +354,9 @@ NAN_METHOD(Database::Delete) { LD_METHOD_SETUP_COMMON(del, 1, 2) v8::Local keyHandle = args[0].As(); - LD_STRING_OR_BUFFER_TO_SLICE(key, keyHandle, key) + LD_STRING_OR_BUFFER_TO_SLICE(key, keyHandle, key); - bool sync = BooleanOptionValue(optionsObj, NanNew("sync")); + bool sync = BooleanOptionValue(optionsObj, "sync"); DeleteWorker* worker = new DeleteWorker( database @@ -401,9 +384,9 @@ NAN_METHOD(Database::Batch) { NanReturnValue(Batch::NewInstance(args.This(), optionsObj)); } - LD_METHOD_SETUP_COMMON(batch, 1, 2) + LD_METHOD_SETUP_COMMON(batch, 1, 2); - bool sync = BooleanOptionValue(optionsObj, NanNew("sync")); + bool sync = BooleanOptionValue(optionsObj, "sync"); v8::Local array = v8::Local::Cast(args[0]); diff --git a/src/iterator.cc b/src/iterator.cc index b749c35b..c0cb2228 100644 --- a/src/iterator.cc +++ b/src/iterator.cc @@ -315,7 +315,7 @@ NAN_METHOD(Iterator::New) { if (args.Length() > 1 && args[2]->IsObject()) { optionsObj = v8::Local::Cast(args[2]); - reverse = BooleanOptionValue(optionsObj, NanNew("reverse")); + reverse = BooleanOptionValue(optionsObj, "reverse"); if (optionsObj->Has(NanNew("start")) && (node::Buffer::HasInstance(optionsObj->Get(NanNew("start"))) @@ -415,19 +415,11 @@ NAN_METHOD(Iterator::New) { } - bool keys = BooleanOptionValue(optionsObj, NanNew("keys"), true); - bool values = BooleanOptionValue(optionsObj, NanNew("values"), true); - bool keyAsBuffer = BooleanOptionValue( - optionsObj - , NanNew("keyAsBuffer") - , true - ); - bool valueAsBuffer = BooleanOptionValue( - optionsObj - , NanNew("valueAsBuffer") - , true - ); - bool fillCache = BooleanOptionValue(optionsObj, NanNew("fillCache")); + bool keys = BooleanOptionValue(optionsObj, "keys", true); + bool values = BooleanOptionValue(optionsObj, "values", true); + bool keyAsBuffer = BooleanOptionValue(optionsObj, "keyAsBuffer", true); + bool valueAsBuffer = BooleanOptionValue(optionsObj, "valueAsBuffer", true); + bool fillCache = BooleanOptionValue(optionsObj, "fillCache"); Iterator* iterator = new Iterator( database From 139db7bc7f21386e421d15d179c97cbcaa411386 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Tue, 12 May 2015 22:52:51 +0200 Subject: [PATCH 25/32] use const reference instead of by value in Database constructor --- src/database.cc | 2 +- src/database.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/database.cc b/src/database.cc index f2c9e242..121977b8 100644 --- a/src/database.cc +++ b/src/database.cc @@ -20,7 +20,7 @@ namespace leveldown { static v8::Persistent database_constructor; -Database::Database (v8::Handle from) +Database::Database (const v8::Handle& from) : location(new NanUtf8String(from)) , db(NULL) , currentIteratorId(0) diff --git a/src/database.h b/src/database.h index c6579cb1..7940d44c 100644 --- a/src/database.h +++ b/src/database.h @@ -75,7 +75,7 @@ class Database : public node::ObjectWrap { void CloseDatabase (); void ReleaseIterator (uint32_t id); - Database (v8::Handle from); + Database (const v8::Handle& from); ~Database (); private: From 54186b55181c8fb5f9c7992ba97ecd6cd6f91e06 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Sun, 17 May 2015 00:01:33 +0200 Subject: [PATCH 26/32] update changelog --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 246d2750..cfef1adc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +### 1.0.5/1.0.6 May 5 2015 + +* [[`9064099fe7`](https://github.com/level/leveldown/commit/9064099fe7)] - pass db to abstractIterator so gc keeps it (Julian Gruber) + +### 1.0.4 May 5 2015 + + * [[`b550c98291`](https://github.com/level/leveldown/commit/b550c98291)] - update nan for iojs 2.0.0 (Lars-Magnus Skog) + +### 1.0.3 May 2 2015 + + * [[`82479b689f`](https://github.com/level/leveldown/commit/82479b689f)] - tap -> tape + faucet (Lars-Magnus Skog) + * [[`ca9101542a`](https://github.com/level/leveldown/commit/ca9101542a)] - fix write-random.js, use leveldown instead of lmdb (Lars-Magnus Skog) + * [[`03fbbfb99f`](https://github.com/level/leveldown/commit/03fbbfb99f)] - fix bench/db-bench.js (Lars-Magnus Skog) + ### 1.0.2 Apr 26 2015 * [[`8470a63678`](https://github.com/level/leveldown/commit/8470a63678)] - s/rvagg\/node-/level\// (Lars-Magnus Skog) * [[`9cbf592bea`](https://github.com/level/leveldown/commit/9cbf592bea)] - add documentation about snapshots (Max Ogden) From 382a1a7fa3312600ea7c95e173a628a3d2a4f3e1 Mon Sep 17 00:00:00 2001 From: Julian Gruber Date: Tue, 26 May 2015 18:25:02 +0200 Subject: [PATCH 27/32] add compression test suite --- package.json | 2 + test/compression-test.js | 92 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 test/compression-test.js diff --git a/package.json b/package.json index 07f5f817..28b753b1 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,8 @@ "nan": "~1.8.4" }, "devDependencies": { + "async": "~1.0.0", + "delayed": "~1.0.1", "du": "~0.1.0", "faucet": "0.0.1", "mkfiletree": "~0.0.1", diff --git a/test/compression-test.js b/test/compression-test.js new file mode 100644 index 00000000..af86e2ca --- /dev/null +++ b/test/compression-test.js @@ -0,0 +1,92 @@ +/* Copyright (c) 2012-2015 LevelUP contributors + * See list at + * MIT License + */ + +var async = require('async') + , du = require('du') + , delayed = require('delayed') + , common = require('abstract-leveldown/testCommon') + , leveldown = require('../') + , test = require('tape') + + , compressableData = new Buffer(Array.apply(null, Array(1024 * 100)).map(function () { return 'aaaaaaaaaa' }).join('')) + , multiples = 10 + , dataSize = compressableData.length * multiples + + , verify = function (location, compression, t) { + du(location, function (err, size) { + t.error(err) + if (compression) + t.ok(size < dataSize, 'on-disk size (' + size + ') is less than data size (' + dataSize + ')') + else + t.ok(size >= dataSize, 'on-disk size (' + size + ') is greater than data size (' + dataSize + ')') + t.end() + }) + } + + // close, open, close again.. 'compaction' is also performed on open()s + , cycle = function (db, compression, t, callback) { + var location = db.location + db.close(function (err) { + t.error(err) + db = leveldown(location) + db.open({ errorIfExists: false, compression: compression }, function () { + t.error(err) + db.close(function (err) { + t.error(err) + callback() + }) + }) + }) + } + +test('Compression', function (t) { + t.test('set up', common.setUp) + + t.test('test data is compressed by default (db.put())', function (t) { + var db = leveldown(common.location()) + db.open(function (err) { + t.error(err) + async.forEach( + Array.apply(null, Array(multiples)).map(function (e, i) { + return [ i, compressableData ] + }) + , function (args, callback) { + db.put.apply(db, args.concat([callback])) + } + , cycle.bind(null, db, true, t, delayed.delayed(verify.bind(null, db.location, true, t), 0.01)) + ) + }) + }) + + t.test('test data is not compressed with compression=false on open() (db.put())', function (t) { + var db = leveldown(common.location()) + db.open({ compression: false }, function (err) { + t.error(err) + async.forEach( + Array.apply(null, Array(multiples)).map(function (e, i) { + return [ i, compressableData ] + }) + , function (args, callback) { + db.put.apply(db, args.concat([callback])) + } + , cycle.bind(null, db, false, t, delayed.delayed(verify.bind(null, db.location, false, t), 0.01)) + ) + }) + }) + + t.test('test data is compressed by default (db.batch())', function (t) { + var db = leveldown(common.location()) + db.open(function (err) { + t.error(err) + db.batch( + Array.apply(null, Array(multiples)).map(function (e, i) { + return { type: 'put', key: i, value: compressableData } + }) + , cycle.bind(null, db, false, t, delayed.delayed(verify.bind(null, db.location, false, t), 0.01)) + ) + }) + }) +}) + From 61398a0056fe9938c5adbe12a75ceea6cc962676 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Wed, 27 May 2015 14:28:43 +0200 Subject: [PATCH 28/32] link to level/community --- CONTRIBUTING.md | 27 --------------------------- README.md | 26 +++----------------------- 2 files changed, 3 insertions(+), 50 deletions(-) delete mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 0ed70993..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,27 +0,0 @@ -# LevelDOWN is an OPEN Open Source Project - ------------------------------------------ - -## What? - -Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project. - -## Rules - -There are a few basic ground-rules for contributors: - -1. **No `--force` pushes** or modifying the Git history in any way. -1. **Non-master branches** ought to be used for ongoing work. -1. **External API changes and significant modifications** ought to be subject to an **internal pull-request** to solicit feedback from other contributors. -1. Internal pull-requests to solicit feedback are *encouraged* for any other non-trivial contribution but left to the discretion of the contributor. -1. Contributors should attempt to adhere to the prevailing code-style. - -## Releases - -Declaring formal releases remains the prerogative of the project maintainer. - -## Changes to this arrangement - -This is an experiment and feedback is welcome! This document may also be subject to pull-requests or changes by contributors where you believe you have something valuable to add or change. - ------------------------------------------ diff --git a/README.md b/README.md index a79f0cd2..aada994b 100644 --- a/README.md +++ b/README.md @@ -289,27 +289,7 @@ LevelDOWN is an **OPEN Open Source Project**. This means that: > Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project. -See the [CONTRIBUTING.md](https://github.com/level/leveldown/blob/master/CONTRIBUTING.md) file for more details. - -### Contributors - -LevelDOWN is only possible due to the excellent work of the following contributors: - - - - - - - - - - - - - - - -
Rod VaggGitHub/rvaggTwitter/@rvagg
John ChesleyGitHub/cheslesTwitter/@chesles
Jake VerbatenGitHub/raynosTwitter/@raynos2
Dominic TarrGitHub/dominictarrTwitter/@dominictarr
Max OgdenGitHub/maxogdenTwitter/@maxogden
Lars-Magnus SkogGitHub/ralphtheninjaTwitter/@ralphtheninja
David BjörklundGitHub/keslaTwitter/@david_bjorklund
Julian GruberGitHub/juliangruberTwitter/@juliangruber
Paolo FragomeniGitHub/hij1nxTwitter/@hij1nx
Anton WhalleyGitHub/No9Twitter/@antonwhalley
Matteo CollinaGitHub/mcollinaTwitter/@matteocollina
Pedro TeixeiraGitHub/pgteTwitter/@pgte
James HallidayGitHub/substackTwitter/@substack
+See the [contribution guide](https://github.com/Level/community/blob/master/CONTRIBUTING.md) for more details. ### Windows @@ -320,8 +300,8 @@ A large portion of the Windows support comes from code by [Krzysztof Kowalczyk]( License & copyright ------------------- -Copyright (c) 2012-2015 LevelDOWN contributors (listed above). +Copyright © 2012-2015 **LevelDOWN** [contributors](https://github.com/level/community#contributors). -LevelDOWN is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details. +**LevelDOWN** is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included `LICENSE.md` file for more details. *LevelDOWN builds on the excellent work of the LevelDB and Snappy teams from Google and additional contributors. LevelDB and Snappy are both issued under the [New BSD Licence](http://opensource.org/licenses/BSD-3-Clause).* From 9f03e63c4294dfb2cf622ed990c417f3630a0b8d Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Wed, 27 May 2015 15:14:25 +0200 Subject: [PATCH 29/32] 1.0.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 28b753b1..966f6fe3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "leveldown", "description": "A Node.js LevelDB binding, primary backend for LevelUP", - "version": "1.0.6", + "version": "1.0.7", "contributors": [ "Rod Vagg (https://github.com/rvagg)", "John Chesley (https://github.com/chesles/)", From 4337cebee9af6aca5e487ce14c84b09126a7d68a Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Wed, 27 May 2015 15:22:43 +0200 Subject: [PATCH 30/32] update changelog --- CHANGELOG.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfef1adc..8865dba4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +Note that we have filtered out commits related to new tags, updating changelog and we're also not listing any merge commits, i.e. we are only listing things that changed between versions. + +### 1.0.7 May 27 2015 + + * [[`61398a0056`](https://github.com/level/leveldown/commit/61398a0056)] - link to level/community (Lars-Magnus Skog) + * [[`382a1a7fa3`](https://github.com/level/leveldown/commit/382a1a7fa3)] - add compression test suite (Julian Gruber) + * [[`139db7bc7f`](https://github.com/level/leveldown/commit/139db7bc7f)] - use const reference instead of by value in Database constructor (Lars-Magnus Skog) + * [[`b56a86323e`](https://github.com/level/leveldown/commit/b56a86323e)] - refactor NanNew() on strings into option value functions (Lars-Magnus Skog) + * [[`ca1f4746c4`](https://github.com/level/leveldown/commit/ca1f4746c4)] - refactor BooleanOptionValue (Lars-Magnus Skog) + * [[`56def2d7c8`](https://github.com/level/leveldown/commit/56def2d7c8)] - NanUInt32OptionValue -> UInt32OptionValue (Lars-Magnus Skog) + * [[`39c614a24f`](https://github.com/level/leveldown/commit/39c614a24f)] - NanBooleanOptionValue -> BooleanOptionValue (Lars-Magnus Skog) + * [[`fcdc46183e`](https://github.com/level/leveldown/commit/fcdc46183e)] - simplify location logic, let Database take care of allocation (Lars-Magnus Skog) + * [[`8cb90e6b6d`](https://github.com/level/leveldown/commit/8cb90e6b6d)] - update abstract-leveldown (Lars-Magnus Skog) + * [[`f70b6576e7`](https://github.com/level/leveldown/commit/f70b6576e7)] - update .travis.yml (nvm works on travis now) (Lars-Magnus Skog) + * [[`007550e7f7`](https://github.com/level/leveldown/commit/007550e7f7)] - 1.0.6 (Lars-Magnus Skog) + ### 1.0.5/1.0.6 May 5 2015 * [[`9064099fe7`](https://github.com/level/leveldown/commit/9064099fe7)] - pass db to abstractIterator so gc keeps it (Julian Gruber) From d5da7fa3576b716533554f527d759f7a0a2c6ccc Mon Sep 17 00:00:00 2001 From: Julian Gruber Date: Thu, 28 May 2015 16:17:05 +0200 Subject: [PATCH 31/32] upgrade abstract-leveldown, mainly for .status --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 966f6fe3..d030dd64 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ ], "main": "leveldown.js", "dependencies": { - "abstract-leveldown": "~2.2.1", + "abstract-leveldown": "~2.4.0", "bindings": "~1.2.1", "fast-future": "~1.0.0", "nan": "~1.8.4" From d513066e132bc50520ba37aaf6f401283487a739 Mon Sep 17 00:00:00 2001 From: Julian Gruber Date: Thu, 28 May 2015 22:47:17 +0200 Subject: [PATCH 32/32] 1.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d030dd64..5b1aef12 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "leveldown", "description": "A Node.js LevelDB binding, primary backend for LevelUP", - "version": "1.0.7", + "version": "1.1.0", "contributors": [ "Rod Vagg (https://github.com/rvagg)", "John Chesley (https://github.com/chesles/)",