All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.rdf4j.federated.evaluation.join.ParallelServiceJoinTask Maven / Gradle / Ivy

There is a newer version: 5.1.0
Show newest version
/*******************************************************************************
 * Copyright (c) 2019 Eclipse RDF4J contributors.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Distribution License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 *******************************************************************************/
package org.eclipse.rdf4j.federated.evaluation.join;

import java.util.List;

import org.eclipse.rdf4j.common.iteration.CloseableIteration;
import org.eclipse.rdf4j.common.iteration.Iterations;
import org.eclipse.rdf4j.federated.algebra.FedXService;
import org.eclipse.rdf4j.federated.evaluation.FederationEvalStrategy;
import org.eclipse.rdf4j.federated.evaluation.concurrent.ParallelExecutor;
import org.eclipse.rdf4j.federated.evaluation.concurrent.ParallelTaskBase;
import org.eclipse.rdf4j.query.BindingSet;
import org.eclipse.rdf4j.repository.sparql.federation.CollectionIteration;

/**
 * A task implementation representing the evaluation of a SERVICE which is to be evaluated using block input. See
 * {@link FederationEvalStrategy#evaluateService(FedXService, List)} for details.
 *
 * @author Andreas Schwarte
 */
public class ParallelServiceJoinTask extends ParallelTaskBase {

	protected final FederationEvalStrategy strategy;
	protected final FedXService expr;
	protected final List bindings;
	protected final ParallelExecutor joinControl;

	public ParallelServiceJoinTask(ParallelExecutor joinControl, FederationEvalStrategy strategy,
			FedXService expr, List bindings) {
		this.strategy = strategy;
		this.expr = expr;
		this.bindings = bindings;
		this.joinControl = joinControl;
	}

	@Override
	protected CloseableIteration performTaskInternal() throws Exception {

		// Note: in order two avoid deadlocks we consume the SERVICE result.
		// This is basically required to avoid processing background tuple
		// request (i.e. HTTP slots) in the correct order.
		try (var iter = strategy.evaluateService(expr, bindings)) {
			return new CollectionIteration<>(Iterations.asList(iter));
		}
	}

	@Override
	public ParallelExecutor getControl() {
		return joinControl;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy