Created
June 30, 2013 00:24
-
-
Save brycebaril/5893248 to your computer and use it in GitHub Desktop.
This file contains 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 lvlup = require("levelup") | |
var db = lvlup("/tmp/source_db") | |
var batch = 10000 | |
function makeBatch(num) { | |
var b = [] | |
for (var i = num; i < num + batch; i++) { | |
b.push({type: "put", key: "z~" + i, value: Math.random()}) | |
} | |
return b | |
} | |
function populate(start) { | |
db.batch(makeBatch(start), function (err) { | |
if (err) throw err | |
start += batch | |
if (start < 1000000) { | |
console.log(start) | |
populate(start) | |
} | |
}) | |
} | |
populate(0) |
This file contains 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 lvlup = require("levelup") | |
var src = lvlup("/tmp/source_db") | |
var tgt = lvlup("/tmp/target_db") | |
var start = Date.now() | |
src.createReadStream() | |
.pipe(tgt.createWriteStream() | |
.on("close", function () { | |
console.log("Done, in %s", Date.now() - start) | |
}) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment