Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

jshintified.

  • Loading branch information...
commit ec5a1cb92cbc6886fa152430362e9dce59a96c06 1 parent 8f1eab9
Matteo Collina authored
1  .jshintrc
View
@@ -1,7 +1,6 @@
{
"node": true,
"browser": true,
- "es5": true,
"curly": true,
"eqeqeq": true,
"immed": true,
2  lib/browserstreamwrapper.js
View
@@ -1 +1 @@
-module.exports = require("readable-stream");
+module.exports = require('readable-stream');
2  lib/getdb-browser.js
View
@@ -1,3 +1,3 @@
-Leveljs = require("level-js");
+var Leveljs = require("level-js");
module.exports = function(l) { return new Leveljs(l); };
2  lib/getdb.js
View
@@ -1 +1 @@
-module.exports = require("leveldown");
+module.exports = require('leveldown');
53 lib/levelgraph.js
View
@@ -1,15 +1,15 @@
-var keyfilter = require("./keyfilterstream")
- , materializer = require("./materializerstream")
- , Variable = require("./variable")
- , Navigator = require("./navigator")
- , extend = require("xtend")
- , utilities = require("./utilities")
- , queryplanner = require("./queryplanner")
- , PassThrough = require("./streamwrapper").PassThrough
- , WriteStream = require("./writestream")
- , levelup = require("levelup")
- , LevelWriteStream = require("level-writestream")
+var keyfilter = require('./keyfilterstream')
+ , materializer = require('./materializerstream')
+ , Variable = require('./variable')
+ , Navigator = require('./navigator')
+ , extend = require('xtend')
+ , utilities = require('./utilities')
+ , queryplanner = require('./queryplanner')
+ , PassThrough = require('./streamwrapper').PassThrough
+ , WriteStream = require('./writestream')
+ , levelup = require('levelup')
+ , levelWriteStream = require('level-writestream')
, Leveljs
, joinStream
, doAction
@@ -26,15 +26,15 @@ module.exports = function levelgraph(leveldb, options) {
var name = leveldb
, db;
- if (typeof leveldb === "string") {
+ if (typeof leveldb === 'string') {
// we are using LevelDown on node or level-js in the Browser
if (!options.db) {
- options.db = require("./getdb");
+ options.db = require('./getdb');
}
leveldb = levelup(name, options);
}
- LevelWriteStream(leveldb);
+ levelWriteStream(leveldb);
db = {
getStream: function(pattern, options) {
@@ -42,15 +42,15 @@ module.exports = function levelgraph(leveldb, options) {
return leveldb.createReadStream(query).
pipe(keyfilter(query));
}
- , get: utilities.wrapCallback("getStream")
- , put: doAction("put", leveldb)
- , del: doAction("del", leveldb)
+ , get: utilities.wrapCallback('getStream')
+ , put: doAction('put', leveldb)
+ , del: doAction('del', leveldb)
, putStream: doActionStream('put', leveldb)
, delStream: doActionStream('del', leveldb)
, close: leveldb.close.bind(leveldb)
, v: Variable
, joinStream: joinStream(leveldb, options)
- , join: utilities.wrapCallback("joinStream")
+ , join: utilities.wrapCallback('joinStream')
, nav: function(start) {
return new Navigator({ start: start, db: this });
}
@@ -60,7 +60,7 @@ module.exports = function levelgraph(leveldb, options) {
};
joinStream = function(db, options) {
- options = extend({ joinAlgorithm: "sort" }, options);
+ options = extend({ joinAlgorithm: 'sort' }, options);
var planner = queryplanner(db, options);
@@ -78,13 +78,14 @@ joinStream = function(db, options) {
planner(query, function(err, newquery) {
if (err) {
- result.emit("error", err);
+ result.emit('error', err);
return;
}
var streams = newquery.map(function(triple) {
var stream = triple.stream
- , index = triple.index
+ , index = triple.index;
+
delete triple.stream;
delete triple.index;
return stream({ triple: triple, db: that, index: index });
@@ -127,12 +128,12 @@ doActionStream = function(type, leveldb) {
var levelStream = leveldb.createWriteStream({ type: type });
var writeStream = new WriteStream();
writeStream.pipe(levelStream);
- levelStream.on("error", function(err) {
- writeStream.emit("error", err);
+ levelStream.on('error', function(err) {
+ writeStream.emit('error', err);
});
- levelStream.on("close", function() {
- writeStream.emit("close");
+ levelStream.on('close', function() {
+ writeStream.emit('close');
});
return writeStream;
};
-}
+};
16 lib/navigator.js
View
@@ -1,7 +1,7 @@
-var Variable = require("./variable")
- , Transform = require("./streamwrapper").Transform
- , CallbackStream = require("callback-stream")
- , wrapCallback = require("./utilities").wrapCallback;
+var Variable = require('./variable')
+ , Transform = require('./streamwrapper').Transform
+ , CallbackStream = require('callback-stream')
+ , wrapCallback = require('./utilities').wrapCallback;
function NavigatorStream(options) {
if (!(this instanceof NavigatorStream)) {
@@ -37,7 +37,7 @@ function Navigator(options) {
var count = 0;
this._nextVar = function() {
- return this.db.v("x" + count++);
+ return this.db.v('x' + count++);
};
this.go(options.start);
@@ -60,8 +60,8 @@ function arch(varKey, lastKey) {
};
}
-Navigator.prototype.archOut = arch("object", "subject");
-Navigator.prototype.archIn = arch("subject", "object");
+Navigator.prototype.archOut = arch('object', 'subject');
+Navigator.prototype.archIn = arch('subject', 'object');
Navigator.prototype.bind = function (value) {
this._initialContext[this._lastElement.name] = value;
@@ -81,7 +81,7 @@ Navigator.prototype.go = function (vertex) {
return this;
};
-Navigator.prototype.triples = wrapCallback("triplesStream");
+Navigator.prototype.triples = wrapCallback('triplesStream');
Navigator.prototype.triplesStream = function (pattern) {
18 lib/queryplanner.js
View
@@ -7,6 +7,14 @@ var utilities = require("./utilities")
, doSortQueryPlan
, async = require("async");
+function orderedPossibleIndex(keys) {
+ return Object.keys(utilities.defs).filter(function(index) {
+ return keys.every(function(key, pos) {
+ return utilities.defs[index][pos] === key;
+ });
+ });
+}
+
function queryplanner(db, options) {
return function planner(query, callback) {
// dupes!
@@ -130,14 +138,6 @@ doSortQueryPlan = function(first, second) {
second.stream = SortJoinStream;
return second;
-}
-
-function orderedPossibleIndex(keys) {
- return Object.keys(utilities.defs).filter(function(index) {
- return keys.every(function(key, pos) {
- return utilities.defs[index][pos] === key;
- });
- });
-}
+};
module.exports = queryplanner;
34 lib/sortjoinstream.js
View
@@ -1,14 +1,14 @@
-var Transform = require("./streamwrapper").Transform
- , Variable = require("./variable")
- , queryMask = require("./utilities").queryMask
- , variablesMask = require("./utilities").variablesMask
+var Transform = require('./streamwrapper').Transform
+ , Variable = require('./variable')
+ , queryMask = require('./utilities').queryMask
+ , variablesMask = require('./utilities').variablesMask
, maskUpdater
, matcher
- , materializer = require("./utilities").materializer
- , createQuery = require("./utilities").createQuery
- , genKey = require("./utilities").genKey
- , genKeys = require("./utilities").genKeys;
+ , materializer = require('./utilities').materializer
+ , createQuery = require('./utilities').createQuery
+ , genKey = require('./utilities').genKey
+ , genKeys = require('./utilities').genKeys;
var counter = 0;
@@ -26,9 +26,9 @@ function SortJoinStream(options) {
this.db = options.db;
var that = this;
- this.once("pipe", function(source) {
- source.on("error", function(err) {
- that.emit("error", err);
+ this.once('pipe', function(source) {
+ source.on('error', function(err) {
+ that.emit('error', err);
});
});
@@ -51,16 +51,16 @@ SortJoinStream.prototype._restart = function() {
this._readStream = this.db.getStream(this._queryMask, { index: this.index });
- this._readStream.on("error", function(err) {
- that.emit("error", err);
+ this._readStream.on('error', function(err) {
+ that.emit('error', err);
});
- this._readStream.on("end", function() {
+ this._readStream.on('end', function() {
that._readStream = null;
that._execLastDone();
});
- this._readStream.on("readable", function() {
+ this._readStream.on('readable', function() {
if (that._toNextTriple) {
that._toNextTriple();
}
@@ -134,7 +134,7 @@ SortJoinStream.prototype._transform = function(context, encoding, done) {
, key
, otherKey;
- key = genKey(that.index, materializer(that.triple, context)) + "::\xff";
+ key = genKey(that.index, materializer(that.triple, context)) + '::\xff';
if (newContext) {
that.push(newContext);
@@ -142,7 +142,7 @@ SortJoinStream.prototype._transform = function(context, encoding, done) {
return;
}
- key = genKey(that.index, materializer(that.triple, context)) + "::\xff";
+ key = genKey(that.index, materializer(that.triple, context)) + '::\xff';
otherKey = genKey(that.index, triple);
if (key >= otherKey) {
2  lib/streamwrapper.js
View
@@ -1 +1 @@
-module.exports = require("stream");
+module.exports = require('stream');
30 lib/utilities.js
View
@@ -1,13 +1,13 @@
-var CallbackStream = require("callback-stream")
- , Variable = require("./variable")
+var CallbackStream = require('callback-stream')
+ , Variable = require('./variable')
, defs = {
- spo: ["subject", "predicate", "object"],
- sop: ["subject", "object", "predicate"],
- pos: ["predicate", "object", "subject"],
- pso: ["predicate", "subject", "object"],
- ops: ["object", "predicate", "subject"],
- osp: ["object", "subject", "predicate"]
+ spo: ['subject', 'predicate', 'object'],
+ sop: ['subject', 'object', 'predicate'],
+ pos: ['predicate', 'object', 'subject'],
+ pso: ['predicate', 'subject', 'object'],
+ ops: ['object', 'predicate', 'subject'],
+ osp: ['object', 'subject', 'predicate']
};
module.exports.defs = defs;
@@ -40,10 +40,10 @@ function genKey(key, triple) {
}
if (result.length < 4) {
- result.push("");
+ result.push('');
}
- return result.join("::");
+ return result.join('::');
}
module.exports.genKey = genKey;
@@ -110,7 +110,7 @@ function createQuery(pattern, options) {
, key = genKey(index, pattern)
, query = {
start: key,
- end: key + "\xff",
+ end: key + '\xff',
fillCache: true
};
@@ -149,15 +149,15 @@ module.exports.materializer = materializer;
a = function(key) {
return defs.spo.indexOf(key) >= 0;
- }
+ };
b = function(triple, key) {
- return typeof triple[key] !== "object";
- }
+ return typeof triple[key] !== 'object';
+ };
c = function(triple, key) {
return triple[key] instanceof Variable;
- }
+ };
var objectMask = function objectMask(criteria, object) {
return Object.keys(object).
28 lib/writestream.js
View
@@ -1,9 +1,22 @@
-var Transform = require("./streamwrapper").Transform;
+var Transform = require('./streamwrapper').Transform;
var genKey = require('./utilities').genKey;
var genKeys = require('./utilities').genKeys;
var defs = require('./utilities').defs;
+function genActions(triple) {
+ var json = JSON.stringify(triple)
+ , keys = genKeys(triple)
+ , i
+ , result = [];
+
+ for (i = 0; i < keys.length; i++) {
+ result.push({ key: keys[i], value: json });
+ }
+
+ return result;
+}
+
function WriteStream(options) {
if (!(this instanceof WriteStream)) {
return new WriteStream(options);
@@ -31,16 +44,3 @@ WriteStream.prototype._transform = function(data, encoding, done) {
};
module.exports = WriteStream;
-
-function genActions(triple) {
- var json = JSON.stringify(triple)
- , keys = genKeys(triple)
- , i
- , result = [];
-
- for (i = 0; i < keys.length; i++) {
- result.push({ key: keys[i], value: json });
- };
-
- return result;
-}
16 package.json
View
@@ -4,7 +4,9 @@
"description": "A graph database for Node.js and the browser built on top of LevelUp",
"main": "lib/levelgraph.js",
"scripts": {
- "test": "make bail"
+ "test": "make bail",
+ "jshint-lib": "jshint lib/*.js",
+ "jshint-test": "jshint test/*.js"
},
"repository": {
"type": "git",
@@ -13,6 +15,11 @@
"bugs": {
"url": "http://github.com/mcollina/levelgraph/issues"
},
+ "pre-commit": [
+ "jshint-lib",
+ "jshint-test",
+ "test"
+ ],
"keywords": [
"leveldb",
"graph",
@@ -31,11 +38,12 @@
"chai": "~1.6.0",
"sinon": "~1.4.2",
"sinon-chai": "~2.1.2",
- "jshint": "~1.1.0",
- "level-test": "~1.5.1",
+ "jshint": "~2.3.0",
+ "level-test": "~1.5.2",
"uglify-js": "~2.3.6",
"browserify": "~2.29.1",
- "levelup": "0.17.0"
+ "levelup": "~0.18.0",
+ "pre-commit": "0.0.4"
},
"dependencies": {
"xtend": "~2.1.1",
2  test/abstract_join_algorithm.js
View
@@ -81,7 +81,7 @@ module.exports = function(joinAlgorithm) {
contexts.forEach(function(context, i) {
var found = Object.keys(contexts).every(function(v) {
- return context[v] == data[v];
+ return context[v] === data[v];
});
if (found) {
contextIndex = i;
488 test/queryplanner_spec.js
View
@@ -1,10 +1,10 @@
-var queryplanner = require("../lib/queryplanner")
- , v = require("../lib/variable")
- , SortJoinStream = require("../lib/sortjoinstream")
- , JoinStream = require("../lib/joinstream");
+var queryplanner = require('../lib/queryplanner')
+ , v = require('../lib/variable')
+ , SortJoinStream = require('../lib/sortjoinstream')
+ , JoinStream = require('../lib/joinstream');
-describe("query planner", function() {
+describe('query planner', function() {
var db, query, planner, stub, expected;
@@ -14,21 +14,21 @@ describe("query planner", function() {
db = {
approximateSize: function() {}
};
- stub = sinon.stub(db, "approximateSize");
+ stub = sinon.stub(db, 'approximateSize');
planner = queryplanner(db, { joinAlgorithm: algorithm });
});
}
- describe("with basic algorithm", function() {
+ describe('with basic algorithm', function() {
- buildBefore("basic");
+ buildBefore('basic');
- it("should return a single condition as-is", function(done) {
- query = [ { predicate: "friend" } ];
- expected = [ { predicate: "friend", stream: JoinStream } ];
+ it('should return a single condition as-is', function(done) {
+ query = [ { predicate: 'friend' } ];
+ expected = [ { predicate: 'friend', stream: JoinStream } ];
stub
- .withArgs("pos::friend::", "pos::friend::\xff", sinon.match.func)
+ .withArgs('pos::friend::', 'pos::friend::\xff', sinon.match.func)
.yields(null, 10);
planner(query, function(err, result) {
@@ -37,29 +37,29 @@ describe("query planner", function() {
});
});
- it("should order two conditions based on their size", function(done) {
+ it('should order two conditions based on their size', function(done) {
query = [{
- subject: "matteo"
- , predicate: "friend"
+ subject: 'matteo'
+ , predicate: 'friend'
}, {
- predicate: "friend"
+ predicate: 'friend'
}];
expected = [{
- subject: "matteo"
- , predicate: "friend"
+ subject: 'matteo'
+ , predicate: 'friend'
, stream: JoinStream
}, {
- predicate: "friend"
+ predicate: 'friend'
, stream: JoinStream
}];
stub
- .withArgs("pso::friend::matteo::", "pso::friend::matteo::\xff")
+ .withArgs('pso::friend::matteo::', 'pso::friend::matteo::\xff')
.yields(null, 1);
stub
- .withArgs("pos::friend::", "pos::friend::\xff")
+ .withArgs('pos::friend::', 'pos::friend::\xff')
.yields(null, 10);
planner(query, function(err, result) {
@@ -68,29 +68,29 @@ describe("query planner", function() {
});
});
- it("should order two conditions based on their size (bis)", function(done) {
+ it('should order two conditions based on their size (bis)', function(done) {
query = [{
- predicate: "friend"
+ predicate: 'friend'
}, {
- subject: "matteo"
- , predicate: "friend"
+ subject: 'matteo'
+ , predicate: 'friend'
}];
expected = [{
- subject: "matteo"
- , predicate: "friend"
+ subject: 'matteo'
+ , predicate: 'friend'
, stream: JoinStream
}, {
- predicate: "friend"
+ predicate: 'friend'
, stream: JoinStream
}];
db.approximateSize
- .withArgs("pos::friend::", "pos::friend::\xff")
+ .withArgs('pos::friend::', 'pos::friend::\xff')
.yields(null, 10);
db.approximateSize
- .withArgs("pso::friend::matteo::", "pso::friend::matteo::\xff")
+ .withArgs('pso::friend::matteo::', 'pso::friend::matteo::\xff')
.yields(null, 1);
planner(query, function(err, result) {
@@ -99,12 +99,12 @@ describe("query planner", function() {
});
});
- it("should avoid variables", function(done) {
- query = [ { predicate: "friend", subject: v("x") } ];
- expected = [ { predicate: "friend", subject: v("x"), stream: JoinStream } ];
+ it('should avoid variables', function(done) {
+ query = [ { predicate: 'friend', subject: v('x') } ];
+ expected = [ { predicate: 'friend', subject: v('x'), stream: JoinStream } ];
stub
- .withArgs("pos::friend::", "pos::friend::\xff", sinon.match.func)
+ .withArgs('pos::friend::', 'pos::friend::\xff', sinon.match.func)
.yields(null, 10);
planner(query, function(err, result) {
@@ -114,16 +114,16 @@ describe("query planner", function() {
});
});
- describe("with sort algorithm", function() {
+ describe('with sort algorithm', function() {
- buildBefore("sort");
+ buildBefore('sort');
- it("should return a single condition with the JoinStream", function(done) {
- query = [ { predicate: "friend" } ];
- expected = [ { predicate: "friend", stream: JoinStream } ];
+ it('should return a single condition with the JoinStream', function(done) {
+ query = [ { predicate: 'friend' } ];
+ expected = [ { predicate: 'friend', stream: JoinStream } ];
stub
- .withArgs("pos::friend::", "pos::friend::\xff", sinon.match.func)
+ .withArgs('pos::friend::', 'pos::friend::\xff', sinon.match.func)
.yields(null, 10);
planner(query, function(err, result) {
@@ -132,37 +132,37 @@ describe("query planner", function() {
});
});
- it("should put the second condition in the same order as the first", function(done) {
+ it('should put the second condition in the same order as the first', function(done) {
query = [{
- subject: v("x")
- , predicate: "friend"
- , object: v("c")
+ subject: v('x')
+ , predicate: 'friend'
+ , object: v('c')
}, {
- subject: v("x")
- , predicate: "abc"
- , object: v("c")
+ subject: v('x')
+ , predicate: 'abc'
+ , object: v('c')
}];
expected = [{
- subject: v("x")
- , predicate: "friend"
- , object: v("c")
+ subject: v('x')
+ , predicate: 'friend'
+ , object: v('c')
, stream: JoinStream
- , index: "pos"
+ , index: 'pos'
}, {
- subject: v("x")
- , predicate: "abc"
- , object: v("c")
+ subject: v('x')
+ , predicate: 'abc'
+ , object: v('c')
, stream: SortJoinStream
- , index: "pos"
+ , index: 'pos'
}];
stub
- .withArgs("pos::friend::", "pos::friend::\xff", sinon.match.func)
+ .withArgs('pos::friend::', 'pos::friend::\xff', sinon.match.func)
.yields(null, 1);
stub
- .withArgs("pos::abc::", "pos::abc::\xff", sinon.match.func)
+ .withArgs('pos::abc::', 'pos::abc::\xff', sinon.match.func)
.yields(null, 10);
planner(query, function(err, result) {
@@ -171,33 +171,33 @@ describe("query planner", function() {
});
});
- it("should create the proper index for the friend-of-a-friend query", function(done) {
+ it('should create the proper index for the friend-of-a-friend query', function(done) {
query = [{
- subject: v("x")
- , predicate: "friend"
- , object: v("c")
+ subject: v('x')
+ , predicate: 'friend'
+ , object: v('c')
}, {
- subject: v("c")
- , predicate: "friend"
- , object: v("x")
+ subject: v('c')
+ , predicate: 'friend'
+ , object: v('x')
}];
expected = [{
- subject: v("x")
- , predicate: "friend"
- , object: v("c")
+ subject: v('x')
+ , predicate: 'friend'
+ , object: v('c')
, stream: JoinStream
- , index: "pos"
+ , index: 'pos'
}, {
- subject: v("c")
- , predicate: "friend"
- , object: v("x")
+ subject: v('c')
+ , predicate: 'friend'
+ , object: v('x')
, stream: SortJoinStream
- , index: "pso"
+ , index: 'pso'
}];
stub
- .withArgs("pos::friend::", "pos::friend::\xff", sinon.match.func)
+ .withArgs('pos::friend::', 'pos::friend::\xff', sinon.match.func)
.yields(null, 10);
planner(query, function(err, result) {
@@ -206,47 +206,47 @@ describe("query planner", function() {
});
});
- it("should use a SortJoinStream for a three-conditions query", function(done) {
+ it('should use a SortJoinStream for a three-conditions query', function(done) {
query = [{
- subject: v("x")
- , predicate: "friend"
- , object: v("c")
+ subject: v('x')
+ , predicate: 'friend'
+ , object: v('c')
}, {
- subject: v("c")
- , predicate: "friend"
- , object: v("x")
+ subject: v('c')
+ , predicate: 'friend'
+ , object: v('x')
}, {
- subject: "bob"
- , predicate: "father"
- , object: v("c")
+ subject: 'bob'
+ , predicate: 'father'
+ , object: v('c')
}];
expected = [{
- subject: v("x")
- , predicate: "friend"
- , object: v("c")
+ subject: v('x')
+ , predicate: 'friend'
+ , object: v('c')
, stream: JoinStream
- , index: "pos"
+ , index: 'pos'
}, {
- subject: v("c")
- , predicate: "friend"
- , object: v("x")
+ subject: v('c')
+ , predicate: 'friend'
+ , object: v('x')
, stream: SortJoinStream
- , index: "pso"
+ , index: 'pso'
}, {
- subject: "bob"
- , predicate: "father"
- , object: v("c")
+ subject: 'bob'
+ , predicate: 'father'
+ , object: v('c')
, stream: SortJoinStream
- , index: "pso"
+ , index: 'pso'
}];
stub
- .withArgs("pos::friend::", "pos::friend::\xff", sinon.match.func)
+ .withArgs('pos::friend::', 'pos::friend::\xff', sinon.match.func)
.yields(null, 10);
stub
- .withArgs("pso::father::bob::", "pso::father::bob::\xff", sinon.match.func)
+ .withArgs('pso::father::bob::', 'pso::father::bob::\xff', sinon.match.func)
.yields(null, 100);
planner(query, function(err, result) {
@@ -255,43 +255,43 @@ describe("query planner", function() {
});
});
- it("should support inverting the index even on three-conditions queries", function(done) {
+ it('should support inverting the index even on three-conditions queries', function(done) {
query = [{
- subject: v("x")
- , predicate: "friend"
- , object: v("c")
+ subject: v('x')
+ , predicate: 'friend'
+ , object: v('c')
}, {
- subject: v("c")
- , predicate: "friend"
- , object: v("y")
+ subject: v('c')
+ , predicate: 'friend'
+ , object: v('y')
}, {
- subject: v("y")
- , predicate: "friend"
- , object: v("z")
+ subject: v('y')
+ , predicate: 'friend'
+ , object: v('z')
}];
expected = [{
- subject: v("x")
- , predicate: "friend"
- , object: v("c")
+ subject: v('x')
+ , predicate: 'friend'
+ , object: v('c')
, stream: JoinStream
- , index: "pos"
+ , index: 'pos'
}, {
- subject: v("c")
- , predicate: "friend"
- , object: v("y")
+ subject: v('c')
+ , predicate: 'friend'
+ , object: v('y')
, stream: SortJoinStream
- , index: "pso"
+ , index: 'pso'
}, {
- subject: v("y")
- , predicate: "friend"
- , object: v("z")
+ subject: v('y')
+ , predicate: 'friend'
+ , object: v('z')
, stream: SortJoinStream
- , index: "pso"
+ , index: 'pso'
}];
stub
- .withArgs("pos::friend::", "pos::friend::\xff", sinon.match.func)
+ .withArgs('pos::friend::', 'pos::friend::\xff', sinon.match.func)
.yields(null, 10);
planner(query, function(err, result) {
@@ -300,47 +300,47 @@ describe("query planner", function() {
});
});
- it("should put the variables from the previous condition in the same order", function(done) {
+ it('should put the variables from the previous condition in the same order', function(done) {
query = [{
- subject: v("x0")
- , predicate: "friend"
- , object: "davide"
+ subject: v('x0')
+ , predicate: 'friend'
+ , object: 'davide'
}, {
- subject: v("x1")
- , predicate: "friend"
- , object: v("x0")
+ subject: v('x1')
+ , predicate: 'friend'
+ , object: v('x0')
}, {
- subject: v("x1")
- , predicate: "friend"
- , object: v("x2")
+ subject: v('x1')
+ , predicate: 'friend'
+ , object: v('x2')
}];
expected = [{
- subject: v("x0")
- , predicate: "friend"
- , object: "davide"
+ subject: v('x0')
+ , predicate: 'friend'
+ , object: 'davide'
, stream: JoinStream
- , index: "ops"
+ , index: 'ops'
}, {
- subject: v("x1")
- , predicate: "friend"
- , object: v("x0")
+ subject: v('x1')
+ , predicate: 'friend'
+ , object: v('x0')
, stream: SortJoinStream
- , index: "pos"
+ , index: 'pos'
}, {
- subject: v("x1")
- , predicate: "friend"
- , object: v("x2")
+ subject: v('x1')
+ , predicate: 'friend'
+ , object: v('x2')
, stream: SortJoinStream
- , index: "pso"
+ , index: 'pso'
}];
stub
- .withArgs("pos::friend::", "pos::friend::\xff", sinon.match.func)
+ .withArgs('pos::friend::', 'pos::friend::\xff', sinon.match.func)
.yields(null, 10);
stub
- .withArgs("ops::davide::friend::", "ops::davide::friend::\xff", sinon.match.func)
+ .withArgs('ops::davide::friend::', 'ops::davide::friend::\xff', sinon.match.func)
.yields(null, 1);
planner(query, function(err, result) {
@@ -349,51 +349,51 @@ describe("query planner", function() {
});
});
- it("should use a SortJoinStream for another three-conditions query", function(done) {
+ it('should use a SortJoinStream for another three-conditions query', function(done) {
query = [{
- subject: "matteo"
- , predicate: "friend"
- , object: v("x")
+ subject: 'matteo'
+ , predicate: 'friend'
+ , object: v('x')
}, {
- subject: v("x")
- , predicate: "friend"
- , object: v("y")
+ subject: v('x')
+ , predicate: 'friend'
+ , object: v('y')
}, {
- subject: v("y")
- , predicate: "friend"
- , object: "daniele"
+ subject: v('y')
+ , predicate: 'friend'
+ , object: 'daniele'
}];
expected = [{
- subject: "matteo"
- , predicate: "friend"
- , object: v("x")
+ subject: 'matteo'
+ , predicate: 'friend'
+ , object: v('x')
, stream: JoinStream
- , index: "pso"
+ , index: 'pso'
}, {
- subject: v("x")
- , predicate: "friend"
- , object: v("y")
+ subject: v('x')
+ , predicate: 'friend'
+ , object: v('y')
, stream: SortJoinStream
- , index: "pso"
+ , index: 'pso'
}, {
- subject: v("y")
- , predicate: "friend"
- , object: "daniele"
+ subject: v('y')
+ , predicate: 'friend'
+ , object: 'daniele'
, stream: SortJoinStream
- , index: "ops"
+ , index: 'ops'
}];
stub
- .withArgs("pos::friend::", "pos::friend::\xff", sinon.match.func)
+ .withArgs('pos::friend::', 'pos::friend::\xff', sinon.match.func)
.yields(null, 10);
stub
- .withArgs("pso::friend::matteo::", "pso::friend::matteo::\xff", sinon.match.func)
+ .withArgs('pso::friend::matteo::', 'pso::friend::matteo::\xff', sinon.match.func)
.yields(null, 1);
stub
- .withArgs("ops::daniele::friend::", "ops::daniele::friend::\xff", sinon.match.func)
+ .withArgs('ops::daniele::friend::', 'ops::daniele::friend::\xff', sinon.match.func)
.yields(null, 100);
planner(query, function(err, result) {
@@ -402,47 +402,47 @@ describe("query planner", function() {
});
});
- it("should use a SortJoinStream for the friend-of-a-friend-of-a-friend scenario", function(done) {
+ it('should use a SortJoinStream for the friend-of-a-friend-of-a-friend scenario', function(done) {
query = [{
- subject: "matteo"
- , predicate: "friend"
- , object: v("x")
+ subject: 'matteo'
+ , predicate: 'friend'
+ , object: v('x')
}, {
- subject: v("x")
- , predicate: "friend"
- , object: v("y")
+ subject: v('x')
+ , predicate: 'friend'
+ , object: v('y')
}, {
- subject: v("y")
- , predicate: "friend"
- , object: v("z")
+ subject: v('y')
+ , predicate: 'friend'
+ , object: v('z')
}];
expected = [{
- subject: "matteo"
- , predicate: "friend"
- , object: v("x")
+ subject: 'matteo'
+ , predicate: 'friend'
+ , object: v('x')
, stream: JoinStream
- , index: "pso"
+ , index: 'pso'
}, {
- subject: v("x")
- , predicate: "friend"
- , object: v("y")
+ subject: v('x')
+ , predicate: 'friend'
+ , object: v('y')
, stream: SortJoinStream
- , index: "pso"
+ , index: 'pso'
}, {
- subject: v("y")
- , predicate: "friend"
- , object: v("z")
+ subject: v('y')
+ , predicate: 'friend'
+ , object: v('z')
, stream: SortJoinStream
- , index: "pso"
+ , index: 'pso'
}];
stub
- .withArgs("pos::friend::", "pos::friend::\xff", sinon.match.func)
+ .withArgs('pos::friend::', 'pos::friend::\xff', sinon.match.func)
.yields(null, 10);
stub
- .withArgs("pso::friend::matteo::", "pso::friend::matteo::\xff", sinon.match.func)
+ .withArgs('pso::friend::matteo::', 'pso::friend::matteo::\xff', sinon.match.func)
.yields(null, 1);
planner(query, function(err, result) {
@@ -451,47 +451,47 @@ describe("query planner", function() {
});
});
- it("should pick the correct indexes with multiple predicates going out the same subject", function(done) {
+ it('should pick the correct indexes with multiple predicates going out the same subject', function(done) {
query = [{
- subject: v("a")
- , predicate: "friend"
- , object: "marco"
+ subject: v('a')
+ , predicate: 'friend'
+ , object: 'marco'
}, {
- subject: v("a")
- , predicate: "friend"
- , object: v("x1")
+ subject: v('a')
+ , predicate: 'friend'
+ , object: v('x1')
}, {
- subject: v("x1")
- , predicate: "friend"
- , object: v("a")
+ subject: v('x1')
+ , predicate: 'friend'
+ , object: v('a')
}];
expected = [{
- subject: v("a")
- , predicate: "friend"
- , object: "marco"
+ subject: v('a')
+ , predicate: 'friend'
+ , object: 'marco'
, stream: JoinStream
- , index: "ops"
+ , index: 'ops'
}, {
- subject: v("a")
- , predicate: "friend"
- , object: v("x1")
+ subject: v('a')
+ , predicate: 'friend'
+ , object: v('x1')
, stream: SortJoinStream
- , index: "pso"
+ , index: 'pso'
}, {
- subject: v("x1")
- , predicate: "friend"
- , object: v("a")
+ subject: v('x1')
+ , predicate: 'friend'
+ , object: v('a')
, stream: SortJoinStream
- , index: "pos"
+ , index: 'pos'
}];
stub
- .withArgs("pos::friend::", "pos::friend::\xff", sinon.match.func)
+ .withArgs('pos::friend::', 'pos::friend::\xff', sinon.match.func)
.yields(null, 10);
stub
- .withArgs("ops::marco::friend::", "ops::marco::friend::\xff", sinon.match.func)
+ .withArgs('ops::marco::friend::', 'ops::marco::friend::\xff', sinon.match.func)
.yields(null, 1);
planner(query, function(err, result) {
@@ -501,33 +501,33 @@ describe("query planner", function() {
});
});
- describe("without approximateSize", function() {
+ describe('without approximateSize', function() {
beforeEach(function() {
db = {};
planner = queryplanner(db, { joinAlgorithm: 'sort' });
});
- it("should order two conditions based on their size", function(done) {
+ it('should order two conditions based on their size', function(done) {
query = [{
- subject: "matteo"
- , predicate: "friend"
- , object: v("a")
+ subject: 'matteo'
+ , predicate: 'friend'
+ , object: v('a')
}, {
- subject: v("b")
- , predicate: "friend"
- , object: v("c")
+ subject: v('b')
+ , predicate: 'friend'
+ , object: v('c')
}];
expected = [{
- subject: "matteo"
- , predicate: "friend"
- , object: v("a")
+ subject: 'matteo'
+ , predicate: 'friend'
+ , object: v('a')
, stream: JoinStream
}, {
- subject: v("b")
- , predicate: "friend"
- , object: v("c")
+ subject: v('b')
+ , predicate: 'friend'
+ , object: v('c')
, stream: JoinStream
}];
@@ -537,26 +537,26 @@ describe("query planner", function() {
});
});
- it("should order two conditions based on their size (bis)", function(done) {
+ it('should order two conditions based on their size (bis)', function(done) {
query = [{
- subject: v("b")
- , predicate: "friend"
- , object: v("c")
+ subject: v('b')
+ , predicate: 'friend'
+ , object: v('c')
}, {
- subject: "matteo"
- , predicate: "friend"
- , object: v("a")
+ subject: 'matteo'
+ , predicate: 'friend'
+ , object: v('a')
}];
expected = [{
- subject: "matteo"
- , predicate: "friend"
- , object: v("a")
+ subject: 'matteo'
+ , predicate: 'friend'
+ , object: v('a')
, stream: JoinStream
}, {
- subject: v("b")
- , predicate: "friend"
- , object: v("c")
+ subject: v('b')
+ , predicate: 'friend'
+ , object: v('c')
, stream: JoinStream
}];
Please sign in to comment.
Something went wrong with that request. Please try again.