How to use sparqlalgebrajs - 7 common examples

To help you get started, we’ve selected a few sparqlalgebrajs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github comunica / comunica / packages / actor-rdf-resolve-quad-pattern-federated / lib / FederatedQuadSource.ts View on Github external
constructor(mediatorResolveQuadPattern: Mediator, IActionRdfResolveQuadPattern, IActorTest, IActorRdfResolveQuadPatternOutput>,
              context: ActionContext, emptyPatterns: Map,
              skipEmptyPatterns: boolean) {
    this.mediatorResolveQuadPattern = mediatorResolveQuadPattern;
    this.sources = context.get(KEY_CONTEXT_SOURCES);
    this.contextDefault = context.delete(KEY_CONTEXT_SOURCES);
    this.emptyPatterns = emptyPatterns;
    this.skipEmptyPatterns = skipEmptyPatterns;
    this.algebraFactory = new Factory();

    // Initialize sources in the emptyPatterns datastructure
    if (this.skipEmptyPatterns) {
      this.sources.iterator().on('data', (source: IDataSource) => {
        if (!this.emptyPatterns.has(source)) {
          this.emptyPatterns.set(source, []);
        }
      });
    }
  }
github comunica / comunica / packages / actor-rdf-resolve-quad-pattern-sparql-json / lib / ActorRdfResolveQuadPatternSparqlJson.ts View on Github external
public static patternToCountQuery(pattern: RDF.Quad): string {
    return toSparql(ActorRdfResolveQuadPatternSparqlJson.FACTORY.createProject(
      ActorRdfResolveQuadPatternSparqlJson.FACTORY.createExtend(
        ActorRdfResolveQuadPatternSparqlJson.FACTORY.createGroup(
          ActorRdfResolveQuadPatternSparqlJson.patternToBgp(pattern),
          [],
          [ActorRdfResolveQuadPatternSparqlJson.FACTORY.createBoundAggregate(
            variable('var0'),
            'count',
            ActorRdfResolveQuadPatternSparqlJson.FACTORY.createTermExpression(namedNode('*')),
            false,
          )],
        ),
        variable('count'),
        ActorRdfResolveQuadPatternSparqlJson.FACTORY.createTermExpression(variable('var0')),
      ),
      [ variable('count') ],
    ));
github rubensworks / graphql-to-sparql.js / bin / graphql-to-sparql.ts View on Github external
async function run() {
  process.stdout.write(toSparql(await new Converter().graphqlToSparqlAlgebra(query, context)) + '\n');
}
run();
github comunica / comunica / packages / actor-rdf-resolve-quad-pattern-sparql-json / lib / ActorRdfResolveQuadPatternSparqlJson.ts View on Github external
public static patternToSelectQuery(pattern: RDF.Quad): string {
    const variables: RDF.Variable[] = getVariables(getTerms(pattern));
    return toSparql(ActorRdfResolveQuadPatternSparqlJson.FACTORY.createProject(
      ActorRdfResolveQuadPatternSparqlJson.patternToBgp(pattern),
      variables,
    ));
  }
github comunica / comunica / packages / actor-query-operation-orderby-sparqlee / lib / ActorQueryOperationOrderBySparqlee.ts View on Github external
private extractSortExpression(expr: Algebra.Expression): Algebra.Expression {
    const { expressionType, operator } = expr;
    if (expressionType !== Algebra.expressionTypes.OPERATOR) { return expr; }
    return (operator === 'desc')
      ? expr.args[0]
      : expr;
  }
github comunica / comunica / packages / actor-query-operation-filter-sparqlee / lib / ActorQueryOperationFilterSparqlee.ts View on Github external
private substitute(operation: Algebra.Operation, bindings: Bindings): Algebra.Operation {
    return Util.mapOperation(operation, {
      path: (op: Algebra.Path, factory: Factory) => {
        return {
          recurse: false,
          result: factory.createPath(
            this.substituteSingle(op.subject, bindings),
            op.predicate,
            this.substituteSingle(op.object, bindings),
            this.substituteSingle(op.graph, bindings),
          ),
        };
      },
      pattern: (op: Algebra.Pattern, factory: Factory) => {
        return {
          recurse: false,
          result: factory.createPattern(
            this.substituteSingle(op.subject, bindings),
github comunica / comunica / packages / actor-sparql-parse-algebra / lib / ActorSparqlParseAlgebra.ts View on Github external
public async run(action: IActionSparqlParse): Promise {
    return { operation: translate(action.query,
        { quads: true, prefixes: this.prefixes, blankToVariable: true, baseIRI: action.baseIRI }) };
  }

sparqlalgebrajs

Convert SPARQL to SPARQL algebra

MIT
Latest version published 1 month ago

Package Health Score

69 / 100
Full package analysis