[Pkg-javascript-commits] [node-leveldown] 382/492: take tiny steps and make sure tests pass and it compiles
Andrew Kelley
andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:14:19 UTC 2014
This is an automated email from the git hooks/post-receive script.
andrewrk-guest pushed a commit to annotated tag rocksdb-0.10.1
in repository node-leveldown.
commit d45b205af2485bb62048e6dd1b270a3e72a0ab5b
Author: Dominic Tarr <dominic.tarr at gmail.com>
Date: Thu Aug 15 16:12:31 2013 +0100
take tiny steps and make sure tests pass and it compiles
---
src/iterator.cc | 49 +++++++++++++++++++++++++++++++++++++++++++++++--
src/iterator.h | 10 +++++++++-
2 files changed, 56 insertions(+), 3 deletions(-)
diff --git a/src/iterator.cc b/src/iterator.cc
index 545432f..5428389 100644
--- a/src/iterator.cc
+++ b/src/iterator.cc
@@ -27,6 +27,10 @@ Iterator::Iterator (
, bool keyAsBuffer
, bool valueAsBuffer
, v8::Local<v8::Object> &startHandle
+ , std::string* lt
+ , std::string* lte
+ , std::string* gt
+ , std::string* gte
) : database(database)
, id(id)
, start(start)
@@ -37,6 +41,10 @@ Iterator::Iterator (
, limit(limit)
, keyAsBuffer(keyAsBuffer)
, valueAsBuffer(valueAsBuffer)
+ , lt(lt)
+ , lte(lte)
+ , gt(gt)
+ , gte(gte)
{
NanScope();
@@ -95,11 +103,16 @@ bool Iterator::IteratorNext (std::string& key, std::string& value) {
}
// 'end' here is an inclusive test
+ int isEnd = end == NULL ? 1 : end->compare(dbIterator->key().ToString());
+ bool endInclusive = true;
+ bool startInclusive = true;
+
+
if (dbIterator->Valid()
&& (limit < 0 || ++count <= limit)
&& (end == NULL
- || (reverse && end->compare(dbIterator->key().ToString()) <= 0)
- || (!reverse && end->compare(dbIterator->key().ToString()) >= 0))) {
+ || (reverse && (endInclusive ? isEnd <= 0 : isEnd < 0))
+ || (!reverse && (endInclusive ? isEnd >= 0 : isEnd > 0)))) {
if (keys)
key.assign(dbIterator->key().data(), dbIterator->key().size());
@@ -244,6 +257,17 @@ NAN_METHOD(Iterator::New) {
v8::Local<v8::Object> optionsObj;
+ v8::Local<v8::Object> ltHandle;
+ v8::Local<v8::Object> lteHandle;
+ v8::Local<v8::Object> gtHandle;
+ v8::Local<v8::Object> gteHandle;
+
+ std::string* lt = NULL;
+ std::string* lte = NULL;
+ std::string* gt = NULL;
+ std::string* gte = NULL;
+
+
if (args.Length() > 1 && args[2]->IsObject()) {
optionsObj = v8::Local<v8::Object>::Cast(args[2]);
@@ -278,8 +302,25 @@ NAN_METHOD(Iterator::New) {
limit = v8::Local<v8::Integer>::Cast(optionsObj->Get(
NanSymbol("limit")))->Value();
}
+
+ if (optionsObj->Has(NanSymbol("lt"))
+ && (node::Buffer::HasInstance(optionsObj->Get(NanSymbol("lt")))
+ || optionsObj->Get(NanSymbol("lt"))->IsString())) {
+
+ v8::Local<v8::Value> ltBuffer =
+ v8::Local<v8::Value>::New(optionsObj->Get(NanSymbol("lt")));
+
+ // ignore end if it has size 0 since a Slice can't have length 0
+ if (StringOrBufferLength(ltBuffer) > 0) {
+ LD_STRING_OR_BUFFER_TO_SLICE(_lt, ltBuffer, lt)
+ lt = new std::string(_lt.data(), _lt.size());
+ }
+ }
+
}
+
+
bool reverse = NanBooleanOptionValue(optionsObj, NanSymbol("reverse"));
bool keys = NanBooleanOptionValue(optionsObj, NanSymbol("keys"), true);
bool values = NanBooleanOptionValue(optionsObj, NanSymbol("values"), true);
@@ -308,6 +349,10 @@ NAN_METHOD(Iterator::New) {
, keyAsBuffer
, valueAsBuffer
, startHandle
+ , lt
+ , lte
+ , gt
+ , gte
);
iterator->Wrap(args.This());
diff --git a/src/iterator.h b/src/iterator.h
index 4893dea..2178132 100644
--- a/src/iterator.h
+++ b/src/iterator.h
@@ -42,6 +42,10 @@ public:
, bool keyAsBuffer
, bool valueAsBuffer
, v8::Local<v8::Object> &startHandle
+ , std::string* lt
+ , std::string* lte
+ , std::string* gt
+ , std::string* gte
);
~Iterator ();
@@ -63,7 +67,11 @@ private:
bool values;
int limit;
int count;
-
+ std::string* lt;
+ std::string* lte;
+ std::string* gt;
+ std::string* gte;
+
public:
bool keyAsBuffer;
bool valueAsBuffer;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-leveldown.git
More information about the Pkg-javascript-commits
mailing list