[Pkg-javascript-commits] [node-leveldown] 09/23: add liveBackup bindings
Andrew Kelley
andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:21:53 UTC 2014
This is an automated email from the git hooks/post-receive script.
andrewrk-guest pushed a commit to tag hyper-0.10.2
in repository node-leveldown.
commit 408df328afd12cb3e65235aebe7cee6cce911534
Author: Max Ogden <max at maxogden.com>
Date: Thu Aug 29 16:58:59 2013 -0700
add liveBackup bindings
---
src/database.cc | 37 ++++++++++++++++++++++++++++++++++++-
src/database.h | 2 ++
2 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/src/database.cc b/src/database.cc
index 63952ee..d3df8c4 100644
--- a/src/database.cc
+++ b/src/database.cc
@@ -89,6 +89,13 @@ void Database::GetPropertyFromDatabase (
db->GetProperty(property, value);
}
+void Database::LiveBackup (
+ const leveldb::Slice& name
+ ) {
+
+ db->LiveBackup(name);
+}
+
leveldb::Iterator* Database::NewIterator (leveldb::ReadOptions* options) {
return db->NewIterator(*options);
}
@@ -151,6 +158,7 @@ void Database::Init () {
NODE_SET_PROTOTYPE_METHOD(tpl, "batch", Database::Batch);
NODE_SET_PROTOTYPE_METHOD(tpl, "approximateSize", Database::ApproximateSize);
NODE_SET_PROTOTYPE_METHOD(tpl, "getProperty", Database::GetProperty);
+ NODE_SET_PROTOTYPE_METHOD(tpl, "liveBackup", Database::LiveBackup);
NODE_SET_PROTOTYPE_METHOD(tpl, "iterator", Database::Iterator);
}
@@ -543,6 +551,33 @@ NAN_METHOD(Database::GetProperty) {
NanReturnValue(returnValue);
}
+NAN_METHOD(Database::LiveBackup) {
+ NanScope();
+
+ v8::Local<v8::Value> nameV = args[0];
+ v8::Local<v8::Function> callback; // for LD_CB_ERR_IF_NULL_OR_UNDEFINED
+
+ if (!nameV->IsString()) {
+ LD_THROW_RETURN(liveBackup() requires a valid `name` argument)
+ }
+
+ LD_CB_ERR_IF_NULL_OR_UNDEFINED(nameV, name)
+
+ LD_STRING_OR_BUFFER_TO_SLICE(name, nameV, name)
+
+ leveldown::Database* database =
+ node::ObjectWrap::Unwrap<leveldown::Database>(args.This());
+
+ std::string* value = new std::string();
+ database->LiveBackup(name);
+ v8::Local<v8::String> returnValue
+ = v8::String::New(value->c_str(), value->length());
+ delete value;
+ delete[] name.data();
+
+ return returnValue;
+}
+
NAN_METHOD(Database::Iterator) {
NanScope();
@@ -584,5 +619,5 @@ NAN_METHOD(Database::Iterator) {
NanReturnValue(iteratorHandle);
}
-
} // namespace leveldown
+
diff --git a/src/database.h b/src/database.h
index 65b884e..a55631e 100644
--- a/src/database.h
+++ b/src/database.h
@@ -70,6 +70,7 @@ public:
);
uint64_t ApproximateSizeFromDatabase (const leveldb::Range* range);
void GetPropertyFromDatabase (const leveldb::Slice& property, std::string* value);
+ void LiveBackup (const leveldb::Slice& name);
leveldb::Iterator* NewIterator (leveldb::ReadOptions* options);
const leveldb::Snapshot* NewSnapshot ();
void ReleaseSnapshot (const leveldb::Snapshot* snapshot);
@@ -104,6 +105,7 @@ private:
static NAN_METHOD(Iterator);
static NAN_METHOD(ApproximateSize);
static NAN_METHOD(GetProperty);
+ static NAN_METHOD(LiveBackup);
};
} // namespace leveldown
--
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