@comunica/bus-query-operation 3.2.0 → 3.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,108 @@
1
+ {
2
+ "@context": [
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-query-operation/^3.0.0/components/context.jsonld"
4
+ ],
5
+ "@id": "npmd:@comunica/bus-query-operation",
6
+ "components": [
7
+ {
8
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator",
9
+ "@type": "Class",
10
+ "requireElement": "ClosableIterator",
11
+ "extends": [
12
+ {
13
+ "@type": "GenericComponentExtension",
14
+ "component": "urn:npm:asynciterator:AsyncIterator",
15
+ "genericTypeInstances": [
16
+ {
17
+ "@type": "ParameterRangeGenericTypeReference",
18
+ "parameterRangeGenericType": "cbqo:components/ClosableIterator.jsonld#ClosableIterator__generic_S"
19
+ }
20
+ ]
21
+ }
22
+ ],
23
+ "comment": "An AsyncIterator with a callback for when this iterator is closed in any way. In contrast to ClosableTransformIterator, this does not add the overhead of a TransformIterator.",
24
+ "genericTypeParameters": [
25
+ {
26
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator__generic_S"
27
+ }
28
+ ],
29
+ "parameters": [
30
+ {
31
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator_options_onClose",
32
+ "range": {
33
+ "@type": "ParameterRangeWildcard"
34
+ }
35
+ },
36
+ {
37
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator_source",
38
+ "range": {
39
+ "@type": "ParameterRangeGenericComponent",
40
+ "component": "urn:npm:asynciterator:AsyncIterator",
41
+ "genericTypeInstances": [
42
+ {
43
+ "@type": "ParameterRangeGenericTypeReference",
44
+ "parameterRangeGenericType": "cbqo:components/ClosableIterator.jsonld#ClosableIterator__generic_S"
45
+ }
46
+ ]
47
+ }
48
+ }
49
+ ],
50
+ "memberFields": [
51
+ {
52
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator__member__source",
53
+ "memberFieldName": "_source",
54
+ "range": {
55
+ "@type": "ParameterRangeIntersection",
56
+ "parameterRangeElements": [
57
+ {
58
+ "@type": "ParameterRangeGenericComponent",
59
+ "component": "urn:npm:asynciterator:AsyncIterator",
60
+ "genericTypeInstances": [
61
+ {
62
+ "@type": "ParameterRangeGenericTypeReference",
63
+ "parameterRangeGenericType": "cbqo:components/ClosableIterator.jsonld#InternalSource__generic_T"
64
+ }
65
+ ]
66
+ },
67
+ {
68
+ "@type": "ParameterRangeWildcard"
69
+ }
70
+ ]
71
+ }
72
+ },
73
+ {
74
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator__member_onClose",
75
+ "memberFieldName": "onClose"
76
+ },
77
+ {
78
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator__member_constructor",
79
+ "memberFieldName": "constructor"
80
+ },
81
+ {
82
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator__member_read",
83
+ "memberFieldName": "read"
84
+ },
85
+ {
86
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator__member__end",
87
+ "memberFieldName": "_end"
88
+ }
89
+ ],
90
+ "constructorArguments": [
91
+ {
92
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator_source"
93
+ },
94
+ {
95
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator_options__constructorArgument",
96
+ "fields": [
97
+ {
98
+ "keyRaw": "onClose",
99
+ "value": {
100
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator_options_onClose"
101
+ }
102
+ }
103
+ ]
104
+ }
105
+ ]
106
+ }
107
+ ]
108
+ }
package/lib/Bindings.d.ts CHANGED
@@ -17,17 +17,22 @@ import type { Algebra } from 'sparqlalgebrajs';
17
17
  export declare function materializeTerm(term: RDF.Term, bindings: Bindings): RDF.Term;
18
18
  /**
19
19
  * Materialize the given operation (recursively) with the given bindings.
20
- * Essentially, all variables in the given operation will be replaced
20
+ * Essentially, the variables in the given operation
21
+ * which don't appear in the projection operation will be replaced
21
22
  * by the terms bound to the variables in the given bindings.
22
23
  * @param {Algebra.Operation} operation SPARQL algebra operation.
24
+ * And the variables that appear in the projection operation
25
+ * will be added to a new values operation.
23
26
  * @param {Bindings} bindings A bindings object.
24
27
  * @param bindingsFactory The bindings factory.
25
28
  * @param options Options for materializations.
26
29
  * @param options.strictTargetVariables If target variable bindings (such as on SELECT or BIND) should not be allowed.
27
- * @param options.bindFilter If filter expressions should be materialized
30
+ * @param options.bindFilter If filter expressions should be materialized.
31
+ * @param options.originalBindings The bindings object as it was at the top level call of materializeOperation.
28
32
  * @return Algebra.Operation A new operation materialized with the given bindings.
29
33
  */
30
34
  export declare function materializeOperation(operation: Algebra.Operation, bindings: Bindings, bindingsFactory: BindingsFactory, options?: {
31
35
  strictTargetVariables?: boolean;
32
36
  bindFilter?: boolean;
37
+ originalBindings?: Bindings;
33
38
  }): Algebra.Operation;
package/lib/Bindings.js CHANGED
@@ -34,20 +34,25 @@ function materializeTerm(term, bindings) {
34
34
  exports.materializeTerm = materializeTerm;
35
35
  /**
36
36
  * Materialize the given operation (recursively) with the given bindings.
37
- * Essentially, all variables in the given operation will be replaced
37
+ * Essentially, the variables in the given operation
38
+ * which don't appear in the projection operation will be replaced
38
39
  * by the terms bound to the variables in the given bindings.
39
40
  * @param {Algebra.Operation} operation SPARQL algebra operation.
41
+ * And the variables that appear in the projection operation
42
+ * will be added to a new values operation.
40
43
  * @param {Bindings} bindings A bindings object.
41
44
  * @param bindingsFactory The bindings factory.
42
45
  * @param options Options for materializations.
43
46
  * @param options.strictTargetVariables If target variable bindings (such as on SELECT or BIND) should not be allowed.
44
- * @param options.bindFilter If filter expressions should be materialized
47
+ * @param options.bindFilter If filter expressions should be materialized.
48
+ * @param options.originalBindings The bindings object as it was at the top level call of materializeOperation.
45
49
  * @return Algebra.Operation A new operation materialized with the given bindings.
46
50
  */
47
51
  function materializeOperation(operation, bindings, bindingsFactory, options = {}) {
48
52
  options = {
49
53
  strictTargetVariables: 'strictTargetVariables' in options ? options.strictTargetVariables : false,
50
54
  bindFilter: 'bindFilter' in options ? options.bindFilter : true,
55
+ originalBindings: 'originalBindings' in options ? options.originalBindings : bindings,
51
56
  };
52
57
  return sparqlalgebrajs_1.Util.mapOperation(operation, {
53
58
  path(op, factory) {
@@ -109,7 +114,7 @@ function materializeOperation(operation, bindings, bindingsFactory, options = {}
109
114
  project(op, factory) {
110
115
  // Materialize a project operation.
111
116
  // If strictTargetVariables is true, we throw if the project target variable is attempted to be bound.
112
- // Otherwise, we just filter out the bound variables.
117
+ // Otherwise, we make a values clause out of the target variable and its value in InitialBindings.
113
118
  if (options.strictTargetVariables) {
114
119
  for (const variable of op.variables) {
115
120
  if (bindings.has(variable)) {
@@ -121,20 +126,49 @@ function materializeOperation(operation, bindings, bindingsFactory, options = {}
121
126
  result: op,
122
127
  };
123
128
  }
124
- const variables = op.variables.filter(variable => !bindings.has(variable));
125
- // Only include projected variables in the sub-bindings that will be passed down recursively.
126
- // If we don't do this, we may be binding variables that may have the same label, but are not considered equal.
127
- const subBindings = bindingsFactory.bindings(op.variables.map((variable) => {
128
- const binding = bindings.get(variable);
129
- if (binding) {
130
- return [variable, binding];
129
+ // Only include non-projected variables in the bindings that will be passed down recursively.
130
+ // This will result in non-projected variables being replaced with their InitialBindings values.
131
+ for (const bindingKey of bindings.keys()) {
132
+ for (const curVariable of op.variables) {
133
+ if (curVariable.equals(bindingKey)) {
134
+ bindings = bindings.delete(bindingKey);
135
+ break;
136
+ }
131
137
  }
132
- // eslint-disable-next-line no-useless-return,array-callback-return
133
- return;
134
- }).filter(Boolean));
138
+ }
139
+ // Find projected variables which are present in the originalBindings.
140
+ // This will result in projected variables being handled via a values clause.
141
+ const values = createValuesFromBindings(factory, options.originalBindings, op.variables);
142
+ let recursionResult = materializeOperation(op.input, bindings, bindingsFactory, options);
143
+ if (values.length > 0) {
144
+ recursionResult = factory.createJoin([...values, recursionResult]);
145
+ }
135
146
  return {
136
147
  recurse: false,
137
- result: factory.createProject(materializeOperation(op.input, subBindings, bindingsFactory, options), variables),
148
+ result: factory.createProject(recursionResult, op.variables),
149
+ };
150
+ },
151
+ filter(op, factory) {
152
+ const originalBindings = options.originalBindings;
153
+ if (op.expression.expressionType !== 'operator' || originalBindings.size === 0) {
154
+ return {
155
+ recurse: false,
156
+ result: op,
157
+ };
158
+ }
159
+ // Make a values clause using all the variables from originalBindings.
160
+ const values = createValuesFromBindings(factory, originalBindings);
161
+ // Recursively materialize the filter expression
162
+ const recursionResultExpression = materializeOperation(op.expression, bindings, bindingsFactory, options);
163
+ // Recursively materialize the filter input
164
+ let recursionResultInput = materializeOperation(op.input, bindings, bindingsFactory, options);
165
+ if (values.length > 0) {
166
+ recursionResultInput = factory.createJoin([...values, recursionResultInput]);
167
+ }
168
+ return {
169
+ // Recursion already taken care of above.
170
+ recurse: false,
171
+ result: factory.createFilter(recursionResultInput, recursionResultExpression),
138
172
  };
139
173
  },
140
174
  values(op, factory) {
@@ -227,4 +261,23 @@ function materializeOperation(operation, bindings, bindingsFactory, options = {}
227
261
  });
228
262
  }
229
263
  exports.materializeOperation = materializeOperation;
264
+ /**
265
+ * Make a values operation containing the values that are present in `bindings` for variables present in `variables`.
266
+ * If no `variables` argument is given, this method returns a values operation
267
+ * containing every binding from `bindings`.
268
+ * @param {Factory} factory The Factory used to create the values operation.
269
+ * @param {Bindings} bindings A bindings object.
270
+ * @param {Variable[]} variables A list of variables.
271
+ * @returns Algebra.Values A new values operation the given bindings.
272
+ */
273
+ function createValuesFromBindings(factory, bindings, variables) {
274
+ const values = [];
275
+ for (const [variable, binding] of bindings) {
276
+ if (!variables || variables.some(v => v.equals(variable))) {
277
+ const newBinding = { [(0, rdf_string_1.termToString)(variable)]: binding };
278
+ values.push(factory.createValues([variable], [newBinding]));
279
+ }
280
+ }
281
+ return values;
282
+ }
230
283
  //# sourceMappingURL=Bindings.js.map
@@ -1 +1 @@
1
- {"version":3,"file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C,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAA,yBAAY,EAAC,EAAE,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,UAAU,aAAa,CAAC,CAAC;gBACjG,CAAC;qBAAM,CAAC;oBACN,OAAO;wBACL,OAAO,EAAE,IAAI;wBACb,MAAM,EAAE,EAAE;qBACX,CAAC;gBACJ,CAAC;YACH,CAAC;YACD,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,MAAM,EAAE,EAAE;aACX,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAxND,oDAwNC","sourcesContent":["import type { BindingsFactory } from '@comunica/bindings-factory';\nimport type { Bindings } from '@comunica/types';\nimport type * as RDF from '@rdfjs/types';\nimport { DataFactory } from 'rdf-data-factory';\nimport { termToString } from 'rdf-string';\nimport { mapTermsNested, someTermsNested } from 'rdf-terms';\nimport type { Algebra, Factory } from 'sparqlalgebrajs';\nimport { Util } from 'sparqlalgebrajs';\n\nconst DF = new DataFactory();\n\nconst TRUE = DF.literal('true', DF.namedNode('http://www.w3.org/2001/XMLSchema#boolean'));\n\n/**\n * Materialize a term with the given binding.\n *\n * If the given term is a variable,\n * and that variable exist in the given bindings object,\n * the value of that binding is returned.\n * In all other cases, the term itself is returned.\n *\n * @param {RDF.Term} term A term.\n * @param {Bindings} bindings A bindings object.\n * @return {RDF.Term} The materialized term.\n */\nexport function materializeTerm(term: RDF.Term, bindings: Bindings): RDF.Term {\n if (term.termType === 'Variable') {\n const value = bindings.get(term);\n if (value) {\n return value;\n }\n }\n if (term.termType === 'Quad' && someTermsNested(term, value => value.termType === 'Variable')) {\n return mapTermsNested(term, subTerm => materializeTerm(subTerm, bindings));\n }\n return term;\n}\n\n/**\n * Materialize the given operation (recursively) with the given bindings.\n * Essentially, all variables in the given operation will be replaced\n * by the terms bound to the variables in the given bindings.\n * @param {Algebra.Operation} operation SPARQL algebra operation.\n * @param {Bindings} bindings A bindings object.\n * @param bindingsFactory The bindings factory.\n * @param options Options for materializations.\n * @param options.strictTargetVariables If target variable bindings (such as on SELECT or BIND) should not be allowed.\n * @param options.bindFilter If filter expressions should be materialized\n * @return Algebra.Operation A new operation materialized with the given bindings.\n */\nexport function materializeOperation(\n operation: Algebra.Operation,\n bindings: Bindings,\n bindingsFactory: BindingsFactory,\n options: {\n strictTargetVariables?: boolean;\n bindFilter?: boolean;\n } = {},\n): Algebra.Operation {\n options = {\n strictTargetVariables: 'strictTargetVariables' in options ? options.strictTargetVariables : false,\n bindFilter: 'bindFilter' in options ? options.bindFilter : true,\n };\n\n return Util.mapOperation(operation, {\n path(op: Algebra.Path, factory: Factory) {\n // Materialize variables in a path expression.\n // The predicate expression will be recursed.\n return {\n recurse: false,\n result: Object.assign(factory.createPath(\n materializeTerm(op.subject, bindings),\n op.predicate,\n materializeTerm(op.object, bindings),\n materializeTerm(op.graph, bindings),\n ), { metadata: op.metadata }),\n };\n },\n pattern(op: Algebra.Pattern, factory: Factory) {\n // Materialize variables in the quad pattern.\n return {\n recurse: false,\n result: Object.assign(factory.createPattern(\n materializeTerm(op.subject, bindings),\n materializeTerm(op.predicate, bindings),\n materializeTerm(op.object, bindings),\n materializeTerm(op.graph, bindings),\n ), { metadata: op.metadata }),\n };\n },\n extend(op: Algebra.Extend) {\n // Materialize an extend operation.\n // If strictTargetVariables is true, we throw if the extension target variable is attempted to be bound.\n // Otherwise, we remove the extend operation.\n if (bindings.has(op.variable)) {\n if (options.strictTargetVariables) {\n throw new Error(`Tried to bind variable ${termToString(op.variable)} in a BIND operator.`);\n } else {\n return {\n recurse: true,\n result: materializeOperation(op.input, bindings, bindingsFactory, options),\n };\n }\n }\n return {\n recurse: true,\n result: op,\n };\n },\n group(op: Algebra.Group, factory: Factory) {\n // Materialize a group operation.\n // If strictTargetVariables is true, we throw if the group target variable is attempted to be bound.\n // Otherwise, we just filter out the bound variables.\n if (options.strictTargetVariables) {\n for (const variable of op.variables) {\n if (bindings.has(variable)) {\n throw new Error(`Tried to bind variable ${termToString(variable)} in a GROUP BY operator.`);\n }\n }\n return {\n recurse: true,\n result: op,\n };\n }\n const variables = op.variables.filter(variable => !bindings.has(variable));\n return {\n recurse: true,\n result: factory.createGroup(\n op.input,\n variables,\n op.aggregates,\n ),\n };\n },\n project(op: Algebra.Project, factory: Factory) {\n // Materialize a project operation.\n // If strictTargetVariables is true, we throw if the project target variable is attempted to be bound.\n // Otherwise, we just filter out the bound variables.\n if (options.strictTargetVariables) {\n for (const variable of op.variables) {\n if (bindings.has(variable)) {\n throw new Error(`Tried to bind variable ${termToString(variable)} in a SELECT operator.`);\n }\n }\n return {\n recurse: true,\n result: op,\n };\n }\n\n const variables = op.variables.filter(variable => !bindings.has(variable));\n\n // Only include projected variables in the sub-bindings that will be passed down recursively.\n // If we don't do this, we may be binding variables that may have the same label, but are not considered equal.\n const subBindings = bindingsFactory.bindings(<[RDF.Variable, RDF.Term][]> op.variables.map((variable) => {\n const binding = bindings.get(variable);\n if (binding) {\n return [ variable, binding ];\n }\n // eslint-disable-next-line no-useless-return,array-callback-return\n return;\n }).filter(Boolean));\n\n return {\n recurse: false,\n result: factory.createProject(\n materializeOperation(\n op.input,\n subBindings,\n bindingsFactory,\n options,\n ),\n variables,\n ),\n };\n },\n values(op: Algebra.Values, factory: Factory) {\n // Materialize a values operation.\n // If strictTargetVariables is true, we throw if the values target variable is attempted to be bound.\n // Otherwise, we just filter out the bound variables and their bindings.\n if (options.strictTargetVariables) {\n for (const variable of op.variables) {\n if (bindings.has(variable)) {\n throw new Error(`Tried to bind variable ${termToString(variable)} in a VALUES operator.`);\n }\n }\n } else {\n const variables = op.variables.filter(variable => !bindings.has(variable));\n const valueBindings: Record<string, RDF.Literal | RDF.NamedNode>[] = <any> op.bindings.map((binding) => {\n const newBinding = { ...binding };\n let valid = true;\n // eslint-disable-next-line unicorn/no-array-for-each\n bindings.forEach((value: RDF.Term, key: RDF.Variable) => {\n const keyString = termToString(key);\n if (keyString in newBinding) {\n if (!value.equals(newBinding[keyString])) {\n // If the value of the binding is not equal, remove this binding completely from the VALUES clause\n valid = false;\n }\n delete newBinding[keyString];\n }\n });\n return valid ? newBinding : undefined;\n }).filter(Boolean);\n return {\n recurse: true,\n result: factory.createValues(\n variables,\n valueBindings,\n ),\n };\n }\n return {\n recurse: false,\n result: op,\n };\n },\n expression(op: Algebra.Expression, factory: Factory) {\n if (!options.bindFilter) {\n return {\n recurse: false,\n result: op,\n };\n }\n\n if (op.expressionType === 'term') {\n // Materialize a term expression\n return {\n recurse: false,\n result: factory.createTermExpression(materializeTerm(op.term, bindings)),\n };\n }\n if (op.expressionType === 'operator') {\n if (op.operator === 'bound' && op.args.length === 1 && op.args[0].expressionType === 'term' &&\n [ ...bindings.keys() ].some(variable => op.args[0].term.equals(variable))) {\n return {\n recurse: false,\n result: factory.createTermExpression(TRUE),\n };\n }\n return {\n recurse: true,\n result: op,\n };\n }\n if (op.expressionType === 'aggregate' &&\n 'variable' in op &&\n bindings.has(<RDF.Variable> op.variable)) {\n // Materialize a bound aggregate operation.\n // If strictTargetVariables is true, we throw if the expression target variable is attempted to be bound.\n // Otherwise, we ignore this operation.\n if (options.strictTargetVariables) {\n throw new Error(`Tried to bind ${termToString(op.variable)} in a ${op.aggregator} aggregate.`);\n } else {\n return {\n recurse: true,\n result: op,\n };\n }\n }\n return {\n recurse: true,\n result: op,\n };\n },\n });\n}\n"]}
1
+ {"version":3,"file":"Bindings.js","sourceRoot":"","sources":["Bindings.ts"],"names":[],"mappings":";;;AAIA,uDAA+C;AAC/C,2CAA0C;AAC1C,yCAA4D;AAE5D,qDAAuC;AAEvC,MAAM,EAAE,GAAG,IAAI,8BAAW,EAAE,CAAC;AAE7B,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,0CAA0C,CAAC,CAAC,CAAC;AAE1F;;;;;;;;;;;GAWG;AACH,SAAgB,eAAe,CAAC,IAAc,EAAE,QAAkB;IAChE,IAAI,IAAI,CAAC,QAAQ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,SAAsB;IAC5F,MAAM,MAAM,GAAqB,EAAE,CAAC;IAEpC,KAAK,MAAM,CAAE,QAAQ,EAAE,OAAO,CAAE,IAAI,QAAQ,EAAE,CAAC;QAC7C,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;YAC1D,MAAM,UAAU,GAAG,EAAE,CAAC,IAAA,yBAAY,EAAC,QAAQ,CAAC,CAAC,EAAgC,OAAO,EAAE,CAAC;YAEvF,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAE,QAAQ,CAAE,EAAE,CAAE,UAAU,CAAE,CAAC,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { BindingsFactory } from '@comunica/bindings-factory';\nimport type { Bindings } from '@comunica/types';\nimport type * as RDF from '@rdfjs/types';\nimport type { Variable } from 'rdf-data-factory';\nimport { DataFactory } from 'rdf-data-factory';\nimport { termToString } from 'rdf-string';\nimport { mapTermsNested, someTermsNested } from 'rdf-terms';\nimport type { Algebra, Factory } from 'sparqlalgebrajs';\nimport { Util } from 'sparqlalgebrajs';\n\nconst DF = new DataFactory();\n\nconst TRUE = DF.literal('true', DF.namedNode('http://www.w3.org/2001/XMLSchema#boolean'));\n\n/**\n * Materialize a term with the given binding.\n *\n * If the given term is a variable,\n * and that variable exist in the given bindings object,\n * the value of that binding is returned.\n * In all other cases, the term itself is returned.\n *\n * @param {RDF.Term} term A term.\n * @param {Bindings} bindings A bindings object.\n * @return {RDF.Term} The materialized term.\n */\nexport function materializeTerm(term: RDF.Term, bindings: Bindings): RDF.Term {\n if (term.termType === 'Variable') {\n const value = bindings.get(term);\n if (value) {\n return value;\n }\n }\n if (term.termType === 'Quad' && someTermsNested(term, value => value.termType === 'Variable')) {\n return mapTermsNested(term, subTerm => materializeTerm(subTerm, bindings));\n }\n return term;\n}\n\n/**\n * Materialize the given operation (recursively) with the given bindings.\n * Essentially, the variables in the given operation\n * which don't appear in the projection operation will be replaced\n * by the terms bound to the variables in the given bindings.\n * @param {Algebra.Operation} operation SPARQL algebra operation.\n * And the variables that appear in the projection operation\n * will be added to a new values operation.\n * @param {Bindings} bindings A bindings object.\n * @param bindingsFactory The bindings factory.\n * @param options Options for materializations.\n * @param options.strictTargetVariables If target variable bindings (such as on SELECT or BIND) should not be allowed.\n * @param options.bindFilter If filter expressions should be materialized.\n * @param options.originalBindings The bindings object as it was at the top level call of materializeOperation.\n * @return Algebra.Operation A new operation materialized with the given bindings.\n */\nexport function materializeOperation(\n operation: Algebra.Operation,\n bindings: Bindings,\n bindingsFactory: BindingsFactory,\n options: {\n strictTargetVariables?: boolean;\n bindFilter?: boolean;\n originalBindings?: Bindings;\n } = {},\n): Algebra.Operation {\n options = {\n strictTargetVariables: 'strictTargetVariables' in options ? options.strictTargetVariables : false,\n bindFilter: 'bindFilter' in options ? options.bindFilter : true,\n originalBindings: 'originalBindings' in options ? options.originalBindings : bindings,\n };\n\n return Util.mapOperation(operation, {\n path(op: Algebra.Path, factory: Factory) {\n // Materialize variables in a path expression.\n // The predicate expression will be recursed.\n return {\n recurse: false,\n result: Object.assign(factory.createPath(\n materializeTerm(op.subject, bindings),\n op.predicate,\n materializeTerm(op.object, bindings),\n materializeTerm(op.graph, bindings),\n ), { metadata: op.metadata }),\n };\n },\n pattern(op: Algebra.Pattern, factory: Factory) {\n // Materialize variables in the quad pattern.\n return {\n recurse: false,\n result: Object.assign(factory.createPattern(\n materializeTerm(op.subject, bindings),\n materializeTerm(op.predicate, bindings),\n materializeTerm(op.object, bindings),\n materializeTerm(op.graph, bindings),\n ), { metadata: op.metadata }),\n };\n },\n extend(op: Algebra.Extend) {\n // Materialize an extend operation.\n // If strictTargetVariables is true, we throw if the extension target variable is attempted to be bound.\n // Otherwise, we remove the extend operation.\n if (bindings.has(op.variable)) {\n if (options.strictTargetVariables) {\n throw new Error(`Tried to bind variable ${termToString(op.variable)} in a BIND operator.`);\n } else {\n return {\n recurse: true,\n result: materializeOperation(op.input, bindings, bindingsFactory, options),\n };\n }\n }\n return {\n recurse: true,\n result: op,\n };\n },\n group(op: Algebra.Group, factory: Factory) {\n // Materialize a group operation.\n // If strictTargetVariables is true, we throw if the group target variable is attempted to be bound.\n // Otherwise, we just filter out the bound variables.\n if (options.strictTargetVariables) {\n for (const variable of op.variables) {\n if (bindings.has(variable)) {\n throw new Error(`Tried to bind variable ${termToString(variable)} in a GROUP BY operator.`);\n }\n }\n return {\n recurse: true,\n result: op,\n };\n }\n const variables = op.variables.filter(variable => !bindings.has(variable));\n return {\n recurse: true,\n result: factory.createGroup(\n op.input,\n variables,\n op.aggregates,\n ),\n };\n },\n project(op: Algebra.Project, factory: Factory) {\n // Materialize a project operation.\n // If strictTargetVariables is true, we throw if the project target variable is attempted to be bound.\n // Otherwise, we make a values clause out of the target variable and its value in InitialBindings.\n if (options.strictTargetVariables) {\n for (const variable of op.variables) {\n if (bindings.has(variable)) {\n throw new Error(`Tried to bind variable ${termToString(variable)} in a SELECT operator.`);\n }\n }\n return {\n recurse: true,\n result: op,\n };\n }\n\n // Only include non-projected variables in the bindings that will be passed down recursively.\n // This will result in non-projected variables being replaced with their InitialBindings values.\n for (const bindingKey of bindings.keys()) {\n for (const curVariable of op.variables) {\n if (curVariable.equals(bindingKey)) {\n bindings = bindings.delete(bindingKey);\n break;\n }\n }\n }\n\n // Find projected variables which are present in the originalBindings.\n // This will result in projected variables being handled via a values clause.\n const values: Algebra.Operation[] =\n createValuesFromBindings(factory, <Bindings> options.originalBindings, op.variables);\n\n let recursionResult: Algebra.Operation = materializeOperation(\n op.input,\n bindings,\n bindingsFactory,\n options,\n );\n\n if (values.length > 0) {\n recursionResult = factory.createJoin([ ...values, recursionResult ]);\n }\n\n return {\n recurse: false,\n result: factory.createProject(recursionResult, op.variables),\n };\n },\n filter(op: Algebra.Filter, factory: Factory) {\n const originalBindings: Bindings = <Bindings> options.originalBindings;\n if (op.expression.expressionType !== 'operator' || originalBindings.size === 0) {\n return {\n recurse: false,\n result: op,\n };\n }\n\n // Make a values clause using all the variables from originalBindings.\n const values: Algebra.Operation[] = createValuesFromBindings(factory, originalBindings);\n\n // Recursively materialize the filter expression\n const recursionResultExpression: Algebra.Expression = <Algebra.Expression> materializeOperation(\n op.expression,\n bindings,\n bindingsFactory,\n options,\n );\n\n // Recursively materialize the filter input\n let recursionResultInput: Algebra.Operation = materializeOperation(\n op.input,\n bindings,\n bindingsFactory,\n options,\n );\n\n if (values.length > 0) {\n recursionResultInput = factory.createJoin([ ...values, recursionResultInput ]);\n }\n\n return {\n // Recursion already taken care of above.\n recurse: false,\n result: factory.createFilter(recursionResultInput, recursionResultExpression),\n };\n },\n values(op: Algebra.Values, factory: Factory) {\n // Materialize a values operation.\n // If strictTargetVariables is true, we throw if the values target variable is attempted to be bound.\n // Otherwise, we just filter out the bound variables and their bindings.\n if (options.strictTargetVariables) {\n for (const variable of op.variables) {\n if (bindings.has(variable)) {\n throw new Error(`Tried to bind variable ${termToString(variable)} in a VALUES operator.`);\n }\n }\n } else {\n const variables = op.variables.filter(variable => !bindings.has(variable));\n const valueBindings: Record<string, RDF.Literal | RDF.NamedNode>[] = <any> op.bindings.map((binding) => {\n const newBinding = { ...binding };\n let valid = true;\n // eslint-disable-next-line unicorn/no-array-for-each\n bindings.forEach((value: RDF.Term, key: RDF.Variable) => {\n const keyString = termToString(key);\n if (keyString in newBinding) {\n if (!value.equals(newBinding[keyString])) {\n // If the value of the binding is not equal, remove this binding completely from the VALUES clause\n valid = false;\n }\n delete newBinding[keyString];\n }\n });\n return valid ? newBinding : undefined;\n }).filter(Boolean);\n return {\n recurse: true,\n result: factory.createValues(\n variables,\n valueBindings,\n ),\n };\n }\n return {\n recurse: false,\n result: op,\n };\n },\n expression(op: Algebra.Expression, factory: Factory) {\n if (!options.bindFilter) {\n return {\n recurse: false,\n result: op,\n };\n }\n\n if (op.expressionType === 'term') {\n // Materialize a term expression\n return {\n recurse: false,\n result: factory.createTermExpression(materializeTerm(op.term, bindings)),\n };\n }\n if (op.expressionType === 'operator') {\n if (op.operator === 'bound' && op.args.length === 1 && op.args[0].expressionType === 'term' &&\n [ ...bindings.keys() ].some(variable => op.args[0].term.equals(variable))) {\n return {\n recurse: false,\n result: factory.createTermExpression(TRUE),\n };\n }\n return {\n recurse: true,\n result: op,\n };\n }\n if (op.expressionType === 'aggregate' &&\n 'variable' in op &&\n bindings.has(<RDF.Variable> op.variable)) {\n // Materialize a bound aggregate operation.\n // If strictTargetVariables is true, we throw if the expression target variable is attempted to be bound.\n // Otherwise, we ignore this operation.\n if (options.strictTargetVariables) {\n throw new Error(`Tried to bind ${termToString(op.variable)} in a ${op.aggregator} aggregate.`);\n } else {\n return {\n recurse: true,\n result: op,\n };\n }\n }\n return {\n recurse: true,\n result: op,\n };\n },\n });\n}\n\n/**\n * Make a values operation containing the values that are present in `bindings` for variables present in `variables`.\n * If no `variables` argument is given, this method returns a values operation\n * containing every binding from `bindings`.\n * @param {Factory} factory The Factory used to create the values operation.\n * @param {Bindings} bindings A bindings object.\n * @param {Variable[]} variables A list of variables.\n * @returns Algebra.Values A new values operation the given bindings.\n */\nfunction createValuesFromBindings(factory: Factory, bindings: Bindings, variables?: Variable[]): Algebra.Values[] {\n const values: Algebra.Values[] = [];\n\n for (const [ variable, binding ] of bindings) {\n if (!variables || variables.some(v => v.equals(variable))) {\n const newBinding = { [termToString(variable)]: <RDF.NamedNode | RDF.Literal> binding };\n\n values.push(factory.createValues([ variable ], [ newBinding ]));\n }\n }\n\n return values;\n}\n"]}
@@ -0,0 +1,18 @@
1
+ import { AsyncIterator, DESTINATION } from 'asynciterator';
2
+ type InternalSource<T> = AsyncIterator<T> & {
3
+ [DESTINATION]?: AsyncIterator<any>;
4
+ };
5
+ /**
6
+ * An AsyncIterator with a callback for when this iterator is closed in any way.
7
+ * In contrast to ClosableTransformIterator, this does not add the overhead of a TransformIterator.
8
+ */
9
+ export declare class ClosableIterator<S> extends AsyncIterator<S> {
10
+ protected readonly _source: InternalSource<S>;
11
+ private readonly onClose;
12
+ constructor(source: AsyncIterator<S>, options: {
13
+ onClose: () => void;
14
+ });
15
+ read(): S | null;
16
+ protected _end(destroy: boolean): void;
17
+ }
18
+ export {};
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClosableIterator = void 0;
4
+ const asynciterator_1 = require("asynciterator");
5
+ /**
6
+ * An AsyncIterator with a callback for when this iterator is closed in any way.
7
+ * In contrast to ClosableTransformIterator, this does not add the overhead of a TransformIterator.
8
+ */
9
+ class ClosableIterator extends asynciterator_1.AsyncIterator {
10
+ constructor(source, options) {
11
+ super();
12
+ this.onClose = options.onClose;
13
+ this._source = source;
14
+ // Wire up the source for reading
15
+ this._source[asynciterator_1.DESTINATION] = this;
16
+ this._source.on('end', destinationClose);
17
+ this._source.on('error', destinationEmitError);
18
+ this._source.on('readable', destinationSetReadable);
19
+ this.readable = this._source.readable;
20
+ }
21
+ read() {
22
+ const ret = this._source.read();
23
+ if (!ret) {
24
+ // Mark as non-readable if ret was null
25
+ this.readable = false;
26
+ // Close this iterator if the source is empty
27
+ if (this._source.done) {
28
+ this.close();
29
+ }
30
+ }
31
+ return ret;
32
+ }
33
+ _end(destroy) {
34
+ this.onClose();
35
+ this._source.removeListener('end', destinationClose);
36
+ this._source.removeListener('error', destinationEmitError);
37
+ this._source.removeListener('readable', destinationSetReadable);
38
+ delete this._source[asynciterator_1.DESTINATION];
39
+ this._source.destroy();
40
+ super._end(destroy);
41
+ }
42
+ }
43
+ exports.ClosableIterator = ClosableIterator;
44
+ // Helpers below are copied from AsyncIterator, as they are not exported from there.
45
+ function destinationSetReadable() {
46
+ this[asynciterator_1.DESTINATION].readable = true;
47
+ }
48
+ function destinationEmitError(error) {
49
+ this[asynciterator_1.DESTINATION].emit('error', error);
50
+ }
51
+ function destinationClose() {
52
+ this[asynciterator_1.DESTINATION].close();
53
+ }
54
+ //# sourceMappingURL=ClosableIterator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClosableIterator.js","sourceRoot":"","sources":["ClosableIterator.ts"],"names":[],"mappings":";;;AAAA,iDAA2D;AAK3D;;;GAGG;AACH,MAAa,gBAAoB,SAAQ,6BAAgB;IAIvD,YAAmB,MAAwB,EAAE,OAAgC;QAC3E,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAuB,MAAM,CAAC;QAE1C,iCAAiC;QACjC,IAAI,CAAC,OAAO,CAAC,2BAAW,CAAC,GAAG,IAAI,CAAC;QACjC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;QACzC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,sBAAsB,CAAC,CAAC;QACpD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IACxC,CAAC;IAEe,IAAI;QAClB,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAChC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,uCAAuC;YACvC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;YAEtB,6CAA6C;YAC7C,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;gBACtB,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,CAAC;QACH,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAEkB,IAAI,CAAC,OAAgB;QACtC,IAAI,CAAC,OAAO,EAAE,CAAC;QAEf,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;QACrD,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;QAC3D,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,UAAU,EAAE,sBAAsB,CAAC,CAAC;QAChE,OAAO,IAAI,CAAC,OAAO,CAAC,2BAAW,CAAC,CAAC;QACjC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtB,CAAC;CACF;AAzCD,4CAyCC;AAED,oFAAoF;AAEpF,SAAS,sBAAsB;IAC7B,IAAI,CAAC,2BAAW,CAAE,CAAC,QAAQ,GAAG,IAAI,CAAC;AACrC,CAAC;AACD,SAAS,oBAAoB,CAA6B,KAAY;IACpE,IAAI,CAAC,2BAAW,CAAE,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAC1C,CAAC;AACD,SAAS,gBAAgB;IACvB,IAAI,CAAC,2BAAW,CAAE,CAAC,KAAK,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["import { AsyncIterator, DESTINATION } from 'asynciterator';\n\ntype InternalSource<T> =\n AsyncIterator<T> & { [DESTINATION]?: AsyncIterator<any> };\n\n/**\n * An AsyncIterator with a callback for when this iterator is closed in any way.\n * In contrast to ClosableTransformIterator, this does not add the overhead of a TransformIterator.\n */\nexport class ClosableIterator<S> extends AsyncIterator<S> {\n protected readonly _source: InternalSource<S>;\n private readonly onClose: () => void;\n\n public constructor(source: AsyncIterator<S>, options: { onClose: () => void }) {\n super();\n this.onClose = options.onClose;\n this._source = <InternalSource<S>> source;\n\n // Wire up the source for reading\n this._source[DESTINATION] = this;\n this._source.on('end', destinationClose);\n this._source.on('error', destinationEmitError);\n this._source.on('readable', destinationSetReadable);\n this.readable = this._source.readable;\n }\n\n public override read(): S | null {\n const ret = this._source.read();\n if (!ret) {\n // Mark as non-readable if ret was null\n this.readable = false;\n\n // Close this iterator if the source is empty\n if (this._source.done) {\n this.close();\n }\n }\n return ret;\n }\n\n protected override _end(destroy: boolean): void {\n this.onClose();\n\n this._source.removeListener('end', destinationClose);\n this._source.removeListener('error', destinationEmitError);\n this._source.removeListener('readable', destinationSetReadable);\n delete this._source[DESTINATION];\n this._source.destroy();\n super._end(destroy);\n }\n}\n\n// Helpers below are copied from AsyncIterator, as they are not exported from there.\n\nfunction destinationSetReadable<S>(this: InternalSource<S>): void {\n this[DESTINATION]!.readable = true;\n}\nfunction destinationEmitError<S>(this: InternalSource<S>, error: Error): void {\n this[DESTINATION]!.emit('error', error);\n}\nfunction destinationClose<S>(this: InternalSource<S>): void {\n this[DESTINATION]!.close();\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -3,4 +3,5 @@ export * from './ActorQueryOperationTyped';
3
3
  export * from './ActorQueryOperationTypedMediated';
4
4
  export * from './Bindings';
5
5
  export * from './BusQueryOperation';
6
+ export * from './ClosableIterator';
6
7
  export * from './ClosableTransformIterator';
package/lib/index.js CHANGED
@@ -19,5 +19,6 @@ __exportStar(require("./ActorQueryOperationTyped"), exports);
19
19
  __exportStar(require("./ActorQueryOperationTypedMediated"), exports);
20
20
  __exportStar(require("./Bindings"), exports);
21
21
  __exportStar(require("./BusQueryOperation"), exports);
22
+ __exportStar(require("./ClosableIterator"), exports);
22
23
  __exportStar(require("./ClosableTransformIterator"), exports);
23
24
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,6DAA2C;AAC3C,qEAAmD;AACnD,6CAA2B;AAC3B,sDAAoC;AACpC,8DAA4C","sourcesContent":["export * from './ActorQueryOperation';\nexport * from './ActorQueryOperationTyped';\nexport * from './ActorQueryOperationTypedMediated';\nexport * from './Bindings';\nexport * from './BusQueryOperation';\nexport * from './ClosableTransformIterator';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,6DAA2C;AAC3C,qEAAmD;AACnD,6CAA2B;AAC3B,sDAAoC;AACpC,qDAAmC;AACnC,8DAA4C","sourcesContent":["export * from './ActorQueryOperation';\nexport * from './ActorQueryOperationTyped';\nexport * from './ActorQueryOperationTypedMediated';\nexport * from './Bindings';\nexport * from './BusQueryOperation';\nexport * from './ClosableIterator';\nexport * from './ClosableTransformIterator';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comunica/bus-query-operation",
3
- "version": "3.2.0",
3
+ "version": "3.2.2",
4
4
  "description": "A comunica bus for query-operation events.",
5
5
  "lsd:module": true,
6
6
  "license": "MIT",
@@ -36,18 +36,18 @@
36
36
  "build:components": "componentsjs-generator"
37
37
  },
38
38
  "dependencies": {
39
- "@comunica/bindings-factory": "^3.2.0",
40
- "@comunica/context-entries": "^3.2.0",
41
- "@comunica/core": "^3.2.0",
39
+ "@comunica/bindings-factory": "^3.2.1",
40
+ "@comunica/context-entries": "^3.2.1",
41
+ "@comunica/core": "^3.2.1",
42
42
  "@comunica/data-factory": "^3.1.0",
43
- "@comunica/metadata": "^3.2.0",
44
- "@comunica/types": "^3.2.0",
43
+ "@comunica/metadata": "^3.2.1",
44
+ "@comunica/types": "^3.2.1",
45
45
  "@rdfjs/types": "*",
46
46
  "asynciterator": "^3.9.0",
47
47
  "rdf-data-factory": "^1.1.2",
48
48
  "rdf-string": "^1.6.1",
49
49
  "rdf-terms": "^1.11.0",
50
- "sparqlalgebrajs": "^4.3.3"
50
+ "sparqlalgebrajs": "^4.3.7"
51
51
  },
52
- "gitHead": "87baf2afed021a254859e64b92f34d9b51c6a7db"
52
+ "gitHead": "fbcc3a81f87738633ddf69ede5ca504236f7edd9"
53
53
  }