From c314e4f403234a969562ef00ea2cc27b8ee18fef Mon Sep 17 00:00:00 2001 From: Louis Chatriot Date: Sat, 1 Jun 2013 16:53:24 +0200 Subject: [PATCH] Update benchmark works again --- benchmarks/commonUtilities.js | 1 + benchmarks/update.js | 2 ++ lib/datastore.js | 1 + package.json | 2 +- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/benchmarks/commonUtilities.js b/benchmarks/commonUtilities.js index 5ba0c62..3d6f800 100644 --- a/benchmarks/commonUtilities.js +++ b/benchmarks/commonUtilities.js @@ -156,6 +156,7 @@ module.exports.updateDocs = function (options, d, n, profiler, cb) { // Will not actually modify the document but will take the same time d.update({ docNumber: order[i] }, { docNumber: order[i] }, options, function (err, nr) { + if (err) { return cb(err); } if (nr !== 1) { return cb('One update didnt work'); } executeAsap(function () { runFrom(i + 1); diff --git a/benchmarks/update.js b/benchmarks/update.js index e27e009..b9a3c27 100644 --- a/benchmarks/update.js +++ b/benchmarks/update.js @@ -37,6 +37,8 @@ async.waterfall([ , function (cb) { profiler.beginProfiling(); return cb(); } , async.apply(commonUtilities.insertDocs, d, n, profiler) +// CHECK THAT MULTIPLE LOAD DATABASE DONT SCREW INDEXES + // Test with update only one document , function (cb) { profiler.step('MULTI: FALSE'); return cb(); } , async.apply(commonUtilities.updateDocs, { multi: false }, d, n, profiler) diff --git a/lib/datastore.js b/lib/datastore.js index 424585c..d607f1f 100644 --- a/lib/datastore.js +++ b/lib/datastore.js @@ -198,6 +198,7 @@ Datastore.prototype._loadDatabase = function (cb) { customUtils.ensureDirectoryExists(path.dirname(self.filename), function (err) { fs.exists(self.filename, function (exists) { if (!exists) { + self.resetIndexes(); self.datafileSize = 0; fs.writeFile(self.filename, '', 'utf8', function (err) { return callback(err); }); return; diff --git a/package.json b/package.json index 660afb6..dca094a 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "dependencies": { "async": "~0.2.8", "underscore": "~1.4.4", - "binary-search-tree": "0.1.3" + "binary-search-tree": "0.1.4" }, "devDependencies": { "chai": "1.0.x",