Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Get Seek working again.
Next step turn iterator code into async.
  • Loading branch information
my8bird committed Sep 7, 2011
1 parent 63ac116 commit 773f833
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 77 deletions.
4 changes: 4 additions & 0 deletions README.markdown
Expand Up @@ -8,6 +8,10 @@ While implementing nStore, I realized there are a couple things that V8 and node

Since LevelDB provides good primitives like MVCC and binary support (It was designed to back IndexDB in the Chrome browser), then it can be used as a base to implement things like CouchDB.

## TODO

1. Trun Iterator code to be async

## Status

This project is still under heavy development in my free-time. It was started by a long night where I couldn't sleep. I am not a C++ coder and am learning as I go.
Expand Down
12 changes: 5 additions & 7 deletions demo/iterator.coffee
Expand Up @@ -38,12 +38,13 @@ d.addCallback () ->

iterator.seekToFirst()


while iterator.valid()
key = iterator.key().toString('utf8')

if lastKey && lastKey > key
console.log('found sorting error')
else
console.log(key)

lastKey = key
readCount++
Expand All @@ -53,21 +54,18 @@ d.addCallback () ->
console.log('read sequential ' + readCount + ' db contents in ' + (Date.now() - start) + 'ms')

d.addCallback () ->
console.log "Seek is broken"
return
console.log '1'
console.log 'Start Seek test'
iterator = db.newIterator({})
console.log '2'

for i in [0 .. 100]
testUUID = uuid()
iterator.seek(new Buffer(testUUID))
iterator.seek("" + testUUID)

console.log('looking for first key after: ' + testUUID)

# if we found something the report
if (iterator.valid())
console.log('FOUND: ' + iterator.key())
console.log('FOUND: ' + iterator.key().toString('utf-8'))


d.addCallback () ->
Expand Down
61 changes: 0 additions & 61 deletions demo/iterator.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -3,7 +3,7 @@
"tags": ["database", "cache"],
"description": "Bindings for using LevelDB through node.",
"homepage": "https://github.com/my8bird/node-leveldb",
"version": "0.3.0",
"version": "0.3.5",
"author": {
"name": "Nathan Landis",
"email": "my8bird@gmail.com"},
Expand Down
13 changes: 6 additions & 7 deletions src/Iterator.cc
@@ -1,5 +1,6 @@
#include "Iterator.h"
#include "helpers.h"
#include "iostream"

using namespace node_leveldb;

Expand Down Expand Up @@ -76,13 +77,10 @@ Handle<Value> Iterator::SeekToLast(const Arguments& args) {
Handle<Value> Iterator::Seek(const Arguments& args) {
HandleScope scope;

// Check args
if (!(args.Length() == 2 && Buffer::HasInstance(args[1]))) {
return ThrowException(Exception::TypeError(String::New("Invalid arguments: Expected (Buffer)")));
} // if

//leveldb::Slice key = JsToSlice(args[0], &self->strings);
//ObjectWrap::Unwrap<Iterator>(args.This())->it->Seek(key);
std::vector<std::string> strings;

leveldb::Slice key = JsToSlice(args[0], &strings);
ObjectWrap::Unwrap<Iterator>(args.This())->it->Seek(key);

return Undefined();
}
Expand Down Expand Up @@ -118,3 +116,4 @@ Handle<Value> Iterator::status(const Arguments& args) {

return processStatus(status);
}

3 changes: 2 additions & 1 deletion src/Iterator.h
Expand Up @@ -37,4 +37,5 @@ class Iterator : ObjectWrap {

} // node_leveldb

#endif ITERATOR_H_
#endif

0 comments on commit 773f833

Please sign in to comment.