當前位置: 首頁>>代碼示例>>Java>>正文


Java EmptyIteration類代碼示例

本文整理匯總了Java中org.eclipse.rdf4j.common.iteration.EmptyIteration的典型用法代碼示例。如果您正苦於以下問題:Java EmptyIteration類的具體用法?Java EmptyIteration怎麽用?Java EmptyIteration使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EmptyIteration類屬於org.eclipse.rdf4j.common.iteration包,在下文中一共展示了EmptyIteration類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: evaluateExclusiveGroup

import org.eclipse.rdf4j.common.iteration.EmptyIteration; //導入依賴的package包/類
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> evaluateExclusiveGroup(
		ExclusiveGroup group, RepositoryConnection conn,
		TripleSource tripleSource, BindingSet bindings)
{
	
	Boolean isEvaluated = false;
		
	try  {
		String preparedQuery = QueryStringUtil.selectQueryString(group, bindings, group.getFilterExpr(), isEvaluated);
		// in order to avoid licking http route while iteration
		return new BufferedCloseableIterator<BindingSet, QueryEvaluationException>(
			tripleSource.getStatements(preparedQuery, conn, bindings, (isEvaluated ? null : group.getFilterExpr()))
		);
	} catch (IllegalQueryException e) {
		/* no projection vars, e.g. local vars only, can occur in joins */
		if (tripleSource.hasStatements(group, conn, bindings))
			return new SingleBindingSetIteration(bindings);
		return new EmptyIteration<BindingSet, QueryEvaluationException>();
	}		
	
}
 
開發者ID:dice-group,項目名稱:CostFed,代碼行數:23,代碼來源:SparqlFederationEvalStrategy.java

示例2: getStatements

import org.eclipse.rdf4j.common.iteration.EmptyIteration; //導入依賴的package包/類
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> getStatements(
		String preparedQuery, RepositoryConnection conn, final BindingSet bindings, final FilterValueExpr filterExpr)
		throws RepositoryException, MalformedQueryException,
		QueryEvaluationException {
	
	TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, preparedQuery, null);
	disableInference(query);		
	
	// evaluate the query
	CloseableIteration<BindingSet, QueryEvaluationException> res = query.evaluate();
	
	// apply filter and/or insert original bindings
	if (filterExpr!=null) {
		if (bindings.size()>0) 
			res = new FilteringInsertBindingsIteration(strategy, filterExpr, bindings, res);
		else
			res = new FilteringIteration(strategy, filterExpr, res);
		if (!res.hasNext())
			return new EmptyIteration<BindingSet, QueryEvaluationException>();
	} else if (bindings.size()>0) {
		res = new InsertBindingsIteration(res, bindings);
	}
	
	return res;
}
 
開發者ID:dice-group,項目名稱:CostFed,代碼行數:27,代碼來源:SailTripleSource.java

示例3: callAsync

import org.eclipse.rdf4j.common.iteration.EmptyIteration; //導入依賴的package包/類
@Override
public void callAsync(CloseableIteration<T, QueryEvaluationException> res) {
	/* optimization: avoid adding empty results */
	if (res instanceof EmptyIteration<?,?>) {
		result.onRemoveIterator();
		return;
	}

	//log.info("union: " + res.getClass().toString());
	if (res instanceof org.eclipse.rdf4j.query.resultio.helpers.BackgroundTupleResult) {
		result.add_release(new BufferedCloseableIterator<T, QueryEvaluationException>(res));
	} else {
		result.add_release(res);
	}
}
 
開發者ID:dice-group,項目名稱:CostFed,代碼行數:16,代碼來源:UnionExecutorBase.java

示例4: evaluateBoundJoinStatementPattern

import org.eclipse.rdf4j.common.iteration.EmptyIteration; //導入依賴的package包/類
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> evaluateBoundJoinStatementPattern(
		StatementTupleExpr stmt, List<BindingSet> bindings)
{
	// we can omit the bound join handling
	if (bindings.size()==1)
		return evaluate(stmt, bindings.get(0));
			
	FilterValueExpr filterExpr = null;
	if (stmt instanceof FilterTuple)
		filterExpr = ((FilterTuple)stmt).getFilterExpr();
	
	Boolean isEvaluated = false;
	String preparedQuery = QueryStringUtil.selectQueryStringBoundUnion((StatementPattern)stmt, bindings, filterExpr, isEvaluated);
	
	CloseableIteration<BindingSet, QueryEvaluationException> result = evaluateAtStatementSources(preparedQuery, stmt.getStatementSources(), stmt.getQueryInfo());
					
	// apply filter and/or convert to original bindings
	if (filterExpr!=null && !isEvaluated) {
		result = new BoundJoinConversionIteration(result, bindings);		// apply conversion
		result = new FilteringIteration(this, filterExpr, result);				// apply filter
		if (!result.hasNext()) {
			result.close();
			return new EmptyIteration<BindingSet, QueryEvaluationException>();
		}
	} else {
		result = new BoundJoinConversionIteration(result, bindings);
	}
		
	// in order to avoid leakage of http route during the iteration
	return new BufferedCloseableIterator<BindingSet, QueryEvaluationException>(result);		
}
 
開發者ID:dice-group,項目名稱:CostFed,代碼行數:33,代碼來源:SparqlFederationEvalStrategy.java

示例5: evaluateBoundJoinStatementPattern

import org.eclipse.rdf4j.common.iteration.EmptyIteration; //導入依賴的package包/類
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> evaluateBoundJoinStatementPattern(
		StatementTupleExpr stmt, List<BindingSet> bindings)
		throws QueryEvaluationException {
			
	// we can omit the bound join handling
	if (bindings.size()==1)
		return evaluate(stmt, bindings.get(0));
			
	FilterValueExpr filterExpr = null;
	if (stmt instanceof FilterTuple)
		filterExpr = ((FilterTuple)stmt).getFilterExpr();
	
	Boolean isEvaluated = false;
	TupleExpr preparedQuery = QueryAlgebraUtil.selectQueryBoundUnion((StatementPattern)stmt, bindings, filterExpr, isEvaluated);
	
	CloseableIteration<BindingSet, QueryEvaluationException> result = evaluateAtStatementSources(preparedQuery, stmt.getStatementSources(), stmt.getQueryInfo());
					
	// apply filter and/or convert to original bindings
	if (filterExpr!=null && !isEvaluated) {
		result = new BoundJoinConversionIteration(result, bindings);		// apply conversion
		result = new FilteringIteration(this, filterExpr, result);				// apply filter
		if (!result.hasNext())	
			return new EmptyIteration<BindingSet, QueryEvaluationException>();
	} else {
		result = new BoundJoinConversionIteration(result, bindings);
	}
		
	return result;		
}
 
開發者ID:dice-group,項目名稱:CostFed,代碼行數:31,代碼來源:SailFederationEvalStrategy.java

示例6: callAsync

import org.eclipse.rdf4j.common.iteration.EmptyIteration; //導入依賴的package包/類
@Override
public void callAsync(CloseableIteration<T, QueryEvaluationException> res) {
	/* optimization: avoid adding empty results */
	if (res instanceof EmptyIteration<?,?>) {
		rightQueue.onRemoveIterator();
		return;
	}
	//log.info("join: " + res.getClass().toString());
	if (res instanceof org.eclipse.rdf4j.query.resultio.helpers.BackgroundTupleResult) {
		rightQueue.add_release(new BufferedCloseableIterator<T, QueryEvaluationException>(res));
	} else {
		rightQueue.add_release(res);
	}
}
 
開發者ID:dice-group,項目名稱:CostFed,代碼行數:15,代碼來源:JoinExecutorBase.java

示例7: getStatements

import org.eclipse.rdf4j.common.iteration.EmptyIteration; //導入依賴的package包/類
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> getStatements(
		String preparedQuery, RepositoryConnection conn, BindingSet bindings, FilterValueExpr filterExpr)
{
	
	TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, preparedQuery, null);
	//query.setMaxExecutionTime(10);
	disableInference(query);
	
	CloseableIteration<BindingSet, QueryEvaluationException> res=null;
	try {			
		
		// evaluate the query
		monitorRemoteRequest();
		res = query.evaluate();
		
		// apply filter and/or insert original bindings
		if (filterExpr!=null) {
			if (bindings.size()>0) 
				res = new FilteringInsertBindingsIteration(strategy, filterExpr, bindings, res);
			else
				res = new FilteringIteration(strategy, filterExpr, res);
			if (!res.hasNext()) {
				Iterations.closeCloseable(res);
				return new EmptyIteration<BindingSet, QueryEvaluationException>();
			}
		} else if (bindings.size()>0) {
			res = new InsertBindingsIteration(res, bindings);
		}

		// in order to avoid licking http route while iteration
		return new BufferedCloseableIterator<BindingSet, QueryEvaluationException>(res);
		
	} catch (QueryEvaluationException ex) {
		Iterations.closeCloseable(res);
		throw ExceptionUtil.traceExceptionSourceAndRepair(strategy.getFedXConnection().getEndpointManager(), conn, ex, "Subquery: " + preparedQuery);			
	}
}
 
開發者ID:dice-group,項目名稱:CostFed,代碼行數:39,代碼來源:SparqlTripleSource.java

示例8: evaluateBoundJoinStatementPattern

import org.eclipse.rdf4j.common.iteration.EmptyIteration; //導入依賴的package包/類
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> evaluateBoundJoinStatementPattern(
		StatementTupleExpr stmt, List<BindingSet> bindings)
		throws QueryEvaluationException {
	
	// we can omit the bound join handling
	if (bindings.size()==1)
		return evaluate(stmt, bindings.get(0));
			
	FilterValueExpr filterExpr = null;
	if (stmt instanceof FilterTuple)
		filterExpr = ((FilterTuple)stmt).getFilterExpr();
	
	Boolean isEvaluated = false;
	String preparedQuery = QueryStringUtil.selectQueryStringBoundJoinVALUES((StatementPattern)stmt, bindings, filterExpr, isEvaluated);
	
	CloseableIteration<BindingSet, QueryEvaluationException> result = evaluateAtStatementSources(preparedQuery, stmt.getStatementSources(), stmt.getQueryInfo());
					
	// apply filter and/or convert to original bindings
	if (filterExpr!=null && !isEvaluated) {
		result = new BoundJoinVALUESConversionIteration(result, bindings);		// apply conversion
		result = new FilteringIteration(this, filterExpr, result);				// apply filter
		if (!result.hasNext())	
			return new EmptyIteration<BindingSet, QueryEvaluationException>();
	} else {
		result = new BoundJoinVALUESConversionIteration(result, bindings);
	}
		
	return result;		
}
 
開發者ID:dice-group,項目名稱:CostFed,代碼行數:31,代碼來源:SparqlFederationEvalStrategyWithValues.java

示例9: callAsync

import org.eclipse.rdf4j.common.iteration.EmptyIteration; //導入依賴的package包/類
@Override
public void callAsync(CloseableIteration<E, QueryEvaluationException> res) {
	/* optimization: avoid adding empty results */
	if (res instanceof EmptyIteration<?,?>) {
		resultQueue.onRemoveIterator();
		return;
	}
	//log.info("queue: " + res.getClass().toString());
	if (res instanceof org.eclipse.rdf4j.query.resultio.helpers.BackgroundTupleResult) {
		resultQueue.add_release(new BufferedCloseableIterator<E, QueryEvaluationException>(res));
	} else {
		resultQueue.add_release(res);
	}
}
 
開發者ID:dice-group,項目名稱:CostFed,代碼行數:15,代碼來源:QueueIteration.java

示例10: evaluate

import org.eclipse.rdf4j.common.iteration.EmptyIteration; //導入依賴的package包/類
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(BindingSet bindings) {
	if (bindings == null) return new EmptyIteration<BindingSet, QueryEvaluationException>();
	
	Endpoint ownedEndpoint = getQueryInfo().getFedXConnection().getEndpointManager().getEndpoint(getOwner().getEndpointID());
	RepositoryConnection ownedConnection = ownedEndpoint.getConn();
	TripleSource t = ownedEndpoint.getTripleSource();
	
	/*
	 * Implementation note: for some endpoint types it is much more efficient to use prepared queries
	 * as there might be some overhead (obsolete optimization) in the native implementation. This
	 * is for instance the case for SPARQL connections. In contrast for NativeRepositories it is
	 * much more efficient to use getStatements(subj, pred, obj) instead of evaluating a prepared query.
	 */			

	if (t.usePreparedQuery()) {
		
		Boolean isEvaluated = false;	// is filter evaluated
		String preparedQuery;
		try {
			preparedQuery = QueryStringUtil.selectQueryString(this, bindings, filterExpr, isEvaluated);
		} catch (IllegalQueryException e1) {
			// TODO there might be an issue with filters being evaluated => investigate
			/* all vars are bound, this must be handled as a check query, can occur in joins */
			if (t.hasStatements(this, ownedConnection, bindings))
				return new SingleBindingSetIteration(bindings);
			return new EmptyIteration<BindingSet, QueryEvaluationException>();
		}
				
		return t.getStatements(preparedQuery, ownedConnection, bindings, (isEvaluated ? null : filterExpr) );
	} else {
		return t.getStatements(this, ownedConnection, bindings, filterExpr);
	}
}
 
開發者ID:dice-group,項目名稱:CostFed,代碼行數:35,代碼來源:ExclusiveStatement.java

示例11: handleStatementSourcePatternCheck

import org.eclipse.rdf4j.common.iteration.EmptyIteration; //導入依賴的package包/類
protected CloseableIteration<BindingSet, QueryEvaluationException> handleStatementSourcePatternCheck(BindingSet bindings, List<StatementSource> sources)
{
	// if at least one source has statements, we can return this binding set as result
	
	// XXX do this in parallel for the number of endpoints ?
	for (StatementSource source : sources) {
		Endpoint ownedEndpoint = queryInfo.getFedXConnection().getEndpointManager().getEndpoint(source.getEndpointID());
		RepositoryConnection ownedConnection = ownedEndpoint.getConn();
		TripleSource t = ownedEndpoint.getTripleSource();
		if (t.hasStatements(this, ownedConnection, bindings))
			return new SingleBindingSetIteration(bindings);
	}
	
	return new EmptyIteration<BindingSet, QueryEvaluationException>();
}
 
開發者ID:dice-group,項目名稱:CostFed,代碼行數:16,代碼來源:StatementSourcePattern.java

示例12: getStatementsForSubject

import org.eclipse.rdf4j.common.iteration.EmptyIteration; //導入依賴的package包/類
private CloseableIteration<Statement, QueryEvaluationException> getStatementsForSubject(Resource subj)
        throws IOException {
    try (LuceneIndex.Reader reader = index.getReader()) {
        return reader.getDocumentForTerm(new Term("@id", Namespaces.reduce(subj.stringValue()))).map(document ->
                (CloseableIteration<Statement, QueryEvaluationException>) new CloseableIteratorIteration<Statement, QueryEvaluationException>(
                        document.getFields().stream()
                                .filter(field -> !field.name().equals("@id"))
                                .flatMap(field -> formatField(subj, field))
                                .iterator()
                )
        ).orElse(new EmptyIteration<>());
    }
}
 
開發者ID:askplatypus,項目名稱:platypus-kb-lucene,代碼行數:14,代碼來源:LuceneTripleSource.java

示例13: getStatementsForSubjectPredicate

import org.eclipse.rdf4j.common.iteration.EmptyIteration; //導入依賴的package包/類
private CloseableIteration<Statement, QueryEvaluationException> getStatementsForSubjectPredicate(Resource subj, IRI pred)
        throws IOException {
    try (LuceneIndex.Reader reader = index.getReader()) {
        //TODO: selective load
        return reader.getDocumentForTerm(new Term("@id", Namespaces.reduce(subj.stringValue()))).map(document ->
                (CloseableIteration<Statement, QueryEvaluationException>) new CloseableIteratorIteration<Statement, QueryEvaluationException>(
                        statementFromDocumentSubjectProperty(document, subj, pred).iterator()
                )
        ).orElse(new EmptyIteration<>());
    }
}
 
開發者ID:askplatypus,項目名稱:platypus-kb-lucene,代碼行數:12,代碼來源:LuceneTripleSource.java

示例14: getStatementsForSubjectPredicateObject

import org.eclipse.rdf4j.common.iteration.EmptyIteration; //導入依賴的package包/類
private CloseableIteration<Statement, QueryEvaluationException> getStatementsForSubjectPredicateObject(Resource subj, IRI pred, Value obj)
        throws IOException {
    Statement inputStatement = VALUE_FACTORY.createStatement(subj, pred, obj);
    try (LuceneIndex.Reader reader = index.getReader()) {
        //TODO: selective load
        return reader.getDocumentForTerm(new Term("@id", Namespaces.reduce(subj.stringValue()))).map(document ->
                (CloseableIteration<Statement, QueryEvaluationException>) new CloseableIteratorIteration<Statement, QueryEvaluationException>(
                        statementFromDocumentSubjectProperty(document, subj, pred)
                                .filter(statement -> statement.equals(inputStatement))
                                .iterator()
                )
        ).orElse(new EmptyIteration<>());
    }
}
 
開發者ID:askplatypus,項目名稱:platypus-kb-lucene,代碼行數:15,代碼來源:LuceneTripleSource.java

示例15: meet

import org.eclipse.rdf4j.common.iteration.EmptyIteration; //導入依賴的package包/類
@Override
public void meet(EmptyResult er) {
	result = new EmptyIteration<BindingSet, QueryEvaluationException>();
}
 
開發者ID:dice-group,項目名稱:CostFed,代碼行數:5,代碼來源:FederationEvalStrategy.java


注:本文中的org.eclipse.rdf4j.common.iteration.EmptyIteration類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。