Skip to content

Commit

Permalink
get compactRange working
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordon Hall committed Feb 1, 2017
1 parent e31f433 commit 14ba38b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ NAN_METHOD(Database::CompactRange) {
v8::Local<v8::Object> endHandle = info[1].As<v8::Object>();

LD_METHOD_SETUP_COMMON(compactRange, -1, 2)

LD_STRING_OR_BUFFER_TO_SLICE(start, startHandle, start)
LD_STRING_OR_BUFFER_TO_SLICE(end, endHandle, end)

Expand Down
13 changes: 8 additions & 5 deletions src/database_async.cc
Original file line number Diff line number Diff line change
Expand Up @@ -280,21 +280,24 @@ CompactRangeWorker::CompactRangeWorker (
{
Nan::HandleScope scope;

SaveToPersistent("start", startHandle);
SaveToPersistent("end", endHandle);
rangeStart = start;
rangeEnd = end;

SaveToPersistent("compactStart", startHandle);
SaveToPersistent("compactEnd", endHandle);
};

CompactRangeWorker::~CompactRangeWorker () {}

void CompactRangeWorker::Execute () {
database->CompactRangeFromDatabase(&start, &end);
database->CompactRangeFromDatabase(&rangeStart, &rangeEnd);
}

void CompactRangeWorker::WorkComplete() {
Nan::HandleScope scope;

DisposeStringOrBufferFromSlice(GetFromPersistent("start"), start);
DisposeStringOrBufferFromSlice(GetFromPersistent("end"), end);
DisposeStringOrBufferFromSlice(GetFromPersistent("compactStart"), rangeStart);
DisposeStringOrBufferFromSlice(GetFromPersistent("compactEnd"), rangeEnd);
AsyncWorker::WorkComplete();
}

Expand Down
4 changes: 2 additions & 2 deletions src/database_async.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ class CompactRangeWorker : public AsyncWorker {
virtual void WorkComplete ();

private:
leveldb::Slice start;
leveldb::Slice end;
leveldb::Slice rangeStart;
leveldb::Slice rangeEnd;
};


Expand Down

0 comments on commit 14ba38b

Please sign in to comment.