diff --git a/README b/README deleted file mode 100644 index e69de29..0000000 diff --git a/benchmarks/benchmark_cached_key_map_random.js b/benchmarks/benchmark_cached_key_map_random.js index ea4695b..31ddac8 100644 --- a/benchmarks/benchmark_cached_key_map_random.js +++ b/benchmarks/benchmark_cached_key_map_random.js @@ -24,7 +24,6 @@ module.exports.run = function(benchmark, next) { benchmark.end(); - var map = {}; var keys = []; var key_count = 0; @@ -41,7 +40,6 @@ module.exports.run = function(benchmark, next) { var value = random.createRandomObject(); var key = random.createRandomString(16); keys.push(key); - map[key] = value; key_map.put(key, value, function(err) { if (err) { throw err; diff --git a/benchmarks/benchmark_cached_ordered_index.js b/benchmarks/benchmark_cached_ordered_index.js index beaa643..c9e6cdd 100644 --- a/benchmarks/benchmark_cached_ordered_index.js +++ b/benchmarks/benchmark_cached_ordered_index.js @@ -26,7 +26,6 @@ module.exports.run = function(benchmark, next) { }; }; - var map = {}; var key_count = 0; benchmark.start('clearing key map'); @@ -46,7 +45,6 @@ module.exports.run = function(benchmark, next) { var value_index = i % 3; var value = createRandomObject(a_values[value_index], b_values[value_index]); var key = random.createRandomString(16); - map[key] = value; key_map.put(key, value, function(err) { if (err) { throw err; diff --git a/benchmarks/benchmark_cached_unordered_index.js b/benchmarks/benchmark_cached_unordered_index.js index 6db113b..b5c7133 100644 --- a/benchmarks/benchmark_cached_unordered_index.js +++ b/benchmarks/benchmark_cached_unordered_index.js @@ -26,7 +26,6 @@ module.exports.run = function(benchmark, next) { }; }; - var map = {}; var key_count = 0; benchmark.start('clearing key map'); @@ -46,7 +45,6 @@ module.exports.run = function(benchmark, next) { var value_index = i % 3; var value = createRandomObject(a_values[value_index], b_values[value_index]); var key = random.createRandomString(16); - map[key] = value; key_map.put(key, value, function(err) { if (err) { throw err; diff --git a/benchmarks/benchmark_collection.js b/benchmarks/benchmark_collection.js index 4027e28..91c96ea 100644 --- a/benchmarks/benchmark_collection.js +++ b/benchmarks/benchmark_collection.js @@ -10,7 +10,6 @@ module.exports.run = function(benchmark, next) { } benchmark.end(); - var assert = require('assert'); benchmark.start('prunning collection'); collection.clear(function(err) { @@ -34,7 +33,7 @@ module.exports.run = function(benchmark, next) { var index = 0; benchmark.start('reading entire collection of ' + OBJECT_COUNT + ' records'); collection.read(function(error, record) { - assert.equal(error, null); + if (error) { throw error; } if (record === null) { benchmark.end(); collection.end(function(err) { diff --git a/benchmarks/benchmark_collection_filter.js b/benchmarks/benchmark_collection_filter.js index 2b5373e..e0028f3 100644 --- a/benchmarks/benchmark_collection_filter.js +++ b/benchmarks/benchmark_collection_filter.js @@ -1,7 +1,6 @@ module.exports.run = function(benchmark, next) { var random = require('../tools/random_generator'); - var assert = require('assert'); require(__dirname + '/../lib/alfred/collection.js').open(__dirname + '/../tmp/collection_filter_benchmark.alf', function(err, collection) { if (err) { diff --git a/benchmarks/benchmark_indexed_key_map.js b/benchmarks/benchmark_indexed_key_map.js index 8711fea..3800e67 100644 --- a/benchmarks/benchmark_indexed_key_map.js +++ b/benchmarks/benchmark_indexed_key_map.js @@ -1,6 +1,5 @@ module.exports.run = function(benchmark, next) { - var assert = require('assert'); var sys = require('sys') || require('util'); var fs = require('fs'); var random = require('../tools/random_generator'); @@ -24,7 +23,6 @@ module.exports.run = function(benchmark, next) { benchmark.end(); - var map = {}; var keys = []; var key_count = 0; @@ -41,7 +39,6 @@ module.exports.run = function(benchmark, next) { var value = random.createRandomObject(); var key = random.createRandomString(16); keys.push(key); - map[key] = value; key_map.put(key, value, function(err) { if (err) { throw err; @@ -66,7 +63,7 @@ module.exports.run = function(benchmark, next) { benchmark.end(); var timeout = setTimeout(function() { - assert.ok(false, "timeout"); + throw new Error('timeout'); }, 240000); var tested_keys = 0; @@ -80,9 +77,8 @@ module.exports.run = function(benchmark, next) { for (var i = 0; i < OBJECT_COUNT; i++) { (function(i) { var key = keys[i]; - var value = map[key]; key_map.get(key, function(err, record) { - assert.deepEqual(record, value); + if (err) { throw err; } }); tested_keys ++; if (tested_keys == going_for) { diff --git a/benchmarks/benchmark_indexed_key_map_random.js b/benchmarks/benchmark_indexed_key_map_random.js index 47e79f5..6efa09d 100644 --- a/benchmarks/benchmark_indexed_key_map_random.js +++ b/benchmarks/benchmark_indexed_key_map_random.js @@ -24,7 +24,6 @@ module.exports.run = function(benchmark, next) { benchmark.end(); - var map = {}; var keys = []; var key_count = 0; @@ -41,7 +40,6 @@ module.exports.run = function(benchmark, next) { var value = random.createRandomObject(); var key = random.createRandomString(16); keys.push(key); - map[key] = value; key_map.put(key, value, function(err) { if (err) { throw err; diff --git a/benchmarks/benchmark_key_map.js b/benchmarks/benchmark_key_map.js index 8e04d9c..3d76091 100644 --- a/benchmarks/benchmark_key_map.js +++ b/benchmarks/benchmark_key_map.js @@ -12,7 +12,6 @@ module.exports.run = function(benchmark, next) { var RETRIEVE_RANDOM_COUNT = 10; //0; var keys = []; - var map = {}; key_map.clear(function(err) { if (err) { @@ -25,7 +24,6 @@ module.exports.run = function(benchmark, next) { var value = random.createRandomObject(); var key = random.createRandomString(16); keys.push(key); - map[key] = value; key_map.put(key, value, function(err) { if (err) { throw err; diff --git a/benchmarks/benchmark_key_map_each_with_pos.js b/benchmarks/benchmark_key_map_each_with_pos.js index c8a9f00..0a6cac7 100644 --- a/benchmarks/benchmark_key_map_each_with_pos.js +++ b/benchmarks/benchmark_key_map_each_with_pos.js @@ -12,7 +12,6 @@ module.exports.run = function(benchmark, next) { throw err; } - var map = {}; var key_count = 0; key_map.clear(function(err) { @@ -23,7 +22,6 @@ module.exports.run = function(benchmark, next) { (function(i) { var value = random.createRandomObject(); var key = random.createRandomString(16); - map[key] = value; key_map.put(key, value, function(err) { if (err) { throw err; diff --git a/benchmarks/results/summaries/latest b/benchmarks/results/summaries/latest index eb8ad7a..4072605 120000 --- a/benchmarks/results/summaries/latest +++ b/benchmarks/results/summaries/latest @@ -1 +1 @@ -20110107125104 \ No newline at end of file +20110107224917 \ No newline at end of file diff --git a/lib/alfred/files/file.js b/lib/alfred/files/file.js index 0e29613..3e87d08 100644 --- a/lib/alfred/files/file.js +++ b/lib/alfred/files/file.js @@ -206,7 +206,7 @@ File.prototype.readOne = function(position, callback) { this.queue_size ++; - var buf = new Buffer(this.options.buffer_length), + var buf = new Buffer(14), read_string = new Buffer(this.options.buffer_length); bytesRead = 0, self = this, @@ -245,11 +245,12 @@ File.prototype.readOne = function(position, callback) { } if (!processed_header) { - // now length is the record length + 40 * 2 (header is 12 bytes and trailer is 40 bytes) + // now length is the record length + 54 (header is 12 bytes and trailer is 40 bytes) length = parseInt(read_string.toString('utf8', 2, 14), 10) + 54; var new_buf = new Buffer(length); read_string.copy(new_buf, 0, 0, bytesRead); read_string = new_buf; + buf = new Buffer(length); processed_header = true; } if (bytesRead >= length) { diff --git a/package.json b/package.json index 7695fba..1bcdf78 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name" : "alfred" , "description" : "In-process key-value store" -, "version" : "0.1.0beta5" +, "version" : "0.1.0beta6" , "homepage" : "http://pgte.github.com/alfred" , "author" : "Pedro Teixeira (http://metaduck.com)" , "contributors" : @@ -20,7 +20,7 @@ , "dependencies" : { "step" : ">=0.0.3" - , "carrier" : ">= 0.0.4" + , "carrier" : ">= 0.1.0" , "crc" : ">= 0.1.0" } , "licenses" :