sparqlalgebrajs
Advanced tools
Comparing version 0.7.3 to 0.7.4
import * as rdfjs from "rdf-js"; | ||
export declare const types: Readonly<{ | ||
AGGREGATE: string; | ||
ALT: string; | ||
@@ -14,3 +13,2 @@ ASK: string; | ||
FILTER: string; | ||
FN_NOT: string; | ||
GRAPH: string; | ||
@@ -30,11 +28,6 @@ GROUP: string; | ||
REDUCED: string; | ||
ROW: string; | ||
SEQ: string; | ||
SEQUENCE: string; | ||
SERVICE: string; | ||
SLICE: string; | ||
TABLE: string; | ||
TO_MULTISET: string; | ||
UNION: string; | ||
UNIT: string; | ||
VARS: string; | ||
VALUES: string; | ||
@@ -184,2 +177,7 @@ ZERO_OR_MORE_PATH: string; | ||
} | ||
export interface Service extends Single { | ||
type: 'service'; | ||
name: rdfjs.Term; | ||
silent: boolean; | ||
} | ||
export interface Slice extends Single { | ||
@@ -186,0 +184,0 @@ type: 'slice'; |
@@ -6,3 +6,2 @@ "use strict"; | ||
exports.types = Object.freeze({ | ||
AGGREGATE: 'aggregate', | ||
ALT: 'alt', | ||
@@ -18,3 +17,2 @@ ASK: 'ask', | ||
FILTER: 'filter', | ||
FN_NOT: 'fn:not', | ||
GRAPH: 'graph', | ||
@@ -34,11 +32,6 @@ GROUP: 'group', | ||
REDUCED: 'reduced', | ||
ROW: 'row', | ||
SEQ: 'seq', | ||
SEQUENCE: 'sequence', | ||
SERVICE: 'service', | ||
SLICE: 'slice', | ||
TABLE: 'table', | ||
TO_MULTISET: 'tomultiset', | ||
UNION: 'union', | ||
UNIT: 'unit', | ||
VARS: 'vars', | ||
VALUES: 'values', | ||
@@ -45,0 +38,0 @@ ZERO_OR_MORE_PATH: 'ZeroOrMorePath', |
@@ -31,2 +31,3 @@ import * as A from './algebra'; | ||
createSeq(left: A.Operation, right: A.Operation): A.Seq; | ||
createService(input: A.Operation, name: RDF.Term, silent?: boolean): A.Service; | ||
createSlice(input: A.Operation, start: number, length?: number): A.Slice; | ||
@@ -33,0 +34,0 @@ createUnion(left: A.Operation, right: A.Operation): A.Union; |
@@ -56,2 +56,3 @@ "use strict"; | ||
createSeq(left, right) { return { type: 'seq', left, right }; } | ||
createService(input, name, silent) { return { type: 'service', input, name, silent }; } | ||
createSlice(input, start, length) { | ||
@@ -58,0 +59,0 @@ if (length !== undefined) |
@@ -51,2 +51,3 @@ "use strict"; | ||
case types.REDUCED: return translateReduced(op); | ||
case types.SERVICE: return translateService(op); | ||
case types.SLICE: return translateSlice(op); | ||
@@ -389,2 +390,15 @@ case types.UNION: return translateUnion(op); | ||
} | ||
function translateService(op) { | ||
let patterns = translateOperation(op.input); | ||
if (patterns.type === 'group') | ||
patterns = patterns.patterns; | ||
if (!Array.isArray(patterns)) | ||
patterns = [patterns]; | ||
return { | ||
type: 'service', | ||
name: translateTerm(op.name), | ||
silent: op.silent, | ||
patterns | ||
}; | ||
} | ||
function translateSlice(op) { | ||
@@ -391,0 +405,0 @@ let result = translateOperation(op.input); |
@@ -293,13 +293,23 @@ "use strict"; | ||
G = factory.createExtend(G, factory.createTerm(E.variable), translateExpression(E.expression)); | ||
else if (E.type === 'service') { | ||
// transform to group so childnodes get parsed correctly | ||
E.type = 'group'; | ||
let A = factory.createService(translateGroupGraphPattern(E), factory.createTerm(E.name), E.silent); | ||
G = simplifiedJoin(G, A); | ||
} | ||
else { | ||
// 18.2.2.8 (simplification) | ||
let A = translateGroupGraphPattern(E); | ||
if (G.type === types.BGP && G.patterns.length === 0) | ||
G = A; | ||
else if (A.type === types.BGP && A.patterns.length === 0) { } // do nothing | ||
else | ||
G = factory.createJoin(G, translateGroupGraphPattern(E)); | ||
G = simplifiedJoin(G, A); | ||
} | ||
return G; | ||
} | ||
function simplifiedJoin(G, A) { | ||
// 18.2.2.8 (simplification) | ||
if (G.type === types.BGP && G.patterns.length === 0) | ||
G = A; | ||
else if (A.type === types.BGP && A.patterns.length === 0) { } // do nothing | ||
else | ||
G = factory.createJoin(G, A); | ||
return G; | ||
} | ||
function translateInlineData(values) { | ||
@@ -306,0 +316,0 @@ let variables = (values.values.length === 0 ? [] : Object.keys(values.values[0])).map(factory.createTerm.bind(factory)); |
{ | ||
"name": "sparqlalgebrajs", | ||
"version": "0.7.3", | ||
"version": "0.7.4", | ||
"description": "Convert SPARQL to SPARL algebra", | ||
@@ -5,0 +5,0 @@ "author": "Joachim Van Herwegen", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57974
1436