Created
August 15, 2013 13:54
-
-
Save drewkerrigan/6240995 to your computer and use it in GitHub Desktop.
run:
npm install 'git://github.com/nathanaschbacher/nodiak.git#master'
first
This file contains hidden or 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
var cluster = require('cluster'); | |
var riak = require('nodiak').getClient('http', 'localhost', 9098); | |
var numObjects = 1000; | |
if (cluster.isMaster) { | |
var worker = cluster.fork(); | |
} else { | |
for(var i = 0; i <= numObjects; i++) { | |
var robj = riak.bucket("test_bucket").object.new(null, {message: "hello, this is a test"}); | |
robj.addToIndex("someindex", "something_" + i); | |
saveOne(i, robj); | |
} | |
} | |
function saveOne(i, robj) { | |
riak.bucket("test_bucket").objects.save(robj, function(errs, obj) { | |
// if (errs) { | |
// console.log("errors", errs); | |
// console.log("data", obj); | |
// } else { | |
if (i == numObjects - 1) { | |
loadTestTwoI(function(errs, data, continuation){ | |
console.log("errors", errs); | |
console.log("data", data); | |
console.log("continuation", continuation); | |
}); | |
} | |
//} | |
}); | |
} | |
function loadTestTwoI(callback) { | |
for(var i = 0; i <= numObjects; i++) { | |
riak.bucket("test_bucket").search.twoi("someindex"+i, "someindex", {}, callback); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment