-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Hi,
first of all, I would like to express my enthusiasm for the very elegant implementation: This could serve as a perfect textbook example of Functional Programming.
I would have one small suggestion for improvement: In the function "relevantTriples" already bound variables are not considered. This can have big disadvantages in performance in practice, because the optimal index is not chosen. This could be solved by passing the context to the function:
function relevantTriples(pattern, db, context) {
const [id, attribute, value] = pattern;
if (!isVariable(id))
return db.entityIndex[id];
if (context[id])
return db.entityIndex[context[id]];
if (!isVariable(value))
return db.valueIndex[value];
if (context[value])
return db.entityIndex[context[value]];
if (!isVariable(attribute))
return db.attrIndex[attribute];
if (context[attribute])
return db.entityIndex[context[attribute]];
return db.triples;
}Also the sequence plays a role: First the id, as second value and last attribute, since in practice this sequence might have the largest influence on the performance.
Greetings
Bernd
TechplexEngineer
Metadata
Metadata
Assignees
Labels
No labels