-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade from
abstract-leveldown
to abstract-level
On the C++ side: - Replace asBuffer options with encoding options - Refactor iterator_next to work for nextv(). We already had a iterator.ReadMany(size) method in C++, with a hardcoded size. Now size is taken from the JS argument to _nextv(size). The cache logic for next() is the same as before. Ref Level/community#70 Ref Level/abstract-level#12 - Use std::vector<Entry> in iterator.cache_ instead of std::vector<std::string> so that the structure of the cache matches the desired result of nextv() in JS. On the JS side: - Use classes for ChainedBatch, Iterator, ClassicLevel - Defer approximateSize() and compactRange() - Encode arguments of approximateSize() and compactRange(). Ref Level/community#85 - Add promise support to additional methods - Remove tests that were copied to abstract-level. This is the most of it, a few more changes are needed in follow-up commits.
- Loading branch information
Showing
25 changed files
with
530 additions
and
562 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,38 @@ | ||
'use strict' | ||
|
||
const util = require('util') | ||
const AbstractChainedBatch = require('abstract-leveldown').AbstractChainedBatch | ||
const { AbstractChainedBatch } = require('abstract-level') | ||
const binding = require('./binding') | ||
|
||
function ChainedBatch (db) { | ||
AbstractChainedBatch.call(this, db) | ||
this.context = binding.batch_init(db.context) | ||
const kContext = Symbol('context') | ||
|
||
class ChainedBatch extends AbstractChainedBatch { | ||
constructor (db, context) { | ||
super(db) | ||
this[kContext] = binding.batch_init(context) | ||
} | ||
} | ||
|
||
// TODO: move to class | ||
|
||
ChainedBatch.prototype._put = function (key, value) { | ||
binding.batch_put(this.context, key, value) | ||
binding.batch_put(this[kContext], key, value) | ||
} | ||
|
||
ChainedBatch.prototype._del = function (key) { | ||
binding.batch_del(this.context, key) | ||
binding.batch_del(this[kContext], key) | ||
} | ||
|
||
ChainedBatch.prototype._clear = function () { | ||
binding.batch_clear(this.context) | ||
binding.batch_clear(this[kContext]) | ||
} | ||
|
||
ChainedBatch.prototype._write = function (options, callback) { | ||
binding.batch_write(this.context, options, callback) | ||
binding.batch_write(this[kContext], options, callback) | ||
} | ||
|
||
util.inherits(ChainedBatch, AbstractChainedBatch) | ||
ChainedBatch.prototype._close = function (callback) { | ||
// TODO: close native batch (currently done on GC) | ||
process.nextTick(callback) | ||
} | ||
|
||
module.exports = ChainedBatch | ||
exports.ChainedBatch = ChainedBatch |
Oops, something went wrong.