How to use @comunica/bus-rdf-resolve-quad-pattern - 3 common examples

To help you get started, we’ve selected a few @comunica/bus-rdf-resolve-quad-pattern 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-hypermedia / lib / ActorRdfResolveQuadPatternHypermedia.ts View on Github external
protected getSource(context: ActionContext, operation: Algebra.Pattern): Promise {
    const contextSource = this.getContextSource(context);
    const url = this.getContextSourceUrl(contextSource);
    let source: MediatedQuadSource;

    // Try to read from cache
    if (this.cacheSize && this.cache.has(url)) {
      source = this.cache.get(url);
    } else {
      // If not in cache, create a new source
      source = new MediatedQuadSource(this.cacheSize, context, url, getDataSourceType(contextSource), {
        mediatorMetadata: this.mediatorMetadata,
        mediatorMetadataExtract: this.mediatorMetadataExtract,
        mediatorRdfDereference: this.mediatorRdfDereference,
        mediatorRdfResolveHypermedia: this.mediatorRdfResolveHypermedia,
        mediatorRdfResolveHypermediaLinks: this.mediatorRdfResolveHypermediaLinks,
      });

      // Set in cache
      if (this.cacheSize) {
        this.cache.set(url, source);
      }
    }

    return Promise.resolve(source);
  }
github comunica / comunica / packages / actor-rdf-resolve-quad-pattern-federated / lib / FederatedQuadSource.ts View on Github external
const proxyIt: AsyncIterator> = sourcesIt.map((source) => {
      remainingSources++;
      sourcesCount++;

      // If we can predict that the given source will have no bindings for the given pattern,
      // return an empty iterator.
      const pattern: Algebra.Pattern = this.algebraFactory.createPattern(
        FederatedQuadSource.nullToVariable(subject, 's'),
        FederatedQuadSource.nullToVariable(predicate, 'p'),
        FederatedQuadSource.nullToVariable(object, 'o'),
        FederatedQuadSource.nullToVariable(graph, 'g'),
      );

      // Prepare the context for this specific source
      const context: ActionContext = this.contextDefault.set(KEY_CONTEXT_SOURCE,
        { type: getDataSourceType(source), value: getDataSourceValue(source) });

      return new PromiseProxyIterator(async () => {
        let output: IActorRdfResolveQuadPatternOutput;
        if (this.isSourceEmpty(source, pattern)) {
          output = { data: new EmptyIterator(), metadata: () => Promise.resolve({ totalItems: 0 }) };
        } else {
          output = await this.mediatorResolveQuadPattern.mediate({ pattern, context });
        }
        if (output.metadata) {
          output.metadata().then((subMetadata: {[id: string]: any}) => {
            if ((!subMetadata.totalItems && subMetadata.totalItems !== 0) || !isFinite(subMetadata.totalItems)) {
              metadata.totalItems = Infinity;
              remainingSources = 0; // We're already at infinite, so ignore any later metadata
              checkEmitMetadata(Infinity, source, pattern, subMetadata);
            } else {
              metadata.totalItems += subMetadata.totalItems;
github comunica / comunica / packages / utils-datasource / lib / DataSourceUtils.ts View on Github external
public static async getSingleSourceType(context: ActionContext): Promise {
    const source = await this.getSingleSource(context);
    return source ? getDataSourceType(source) : null;
  }

@comunica/bus-rdf-resolve-quad-pattern

A comunica bus for resolving quad patterns to quad streams.

MIT
Latest version published 1 year ago

Package Health Score

70 / 100
Full package analysis