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


Java Var類代碼示例

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


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

示例1: constructStatementCheckId

import org.eclipse.rdf4j.query.algebra.Var; //導入依賴的package包/類
/**
 * Construct the statement string, i.e. "s p ?o_varID FILTER ?o_N=o ". This kind of statement
 * pattern is necessary to later on identify available results.
 * 
 * @param stmt
 * @param varID
 * @param varNames
 * @param bindings
 * @return
 */
protected static TupleExpr constructStatementCheckId(StatementPattern stmt, int varID, Set<String> varNames, BindingSet bindings) {
	
	String _varID = Integer.toString(varID);
	Var subj = appendVarId(stmt.getSubjectVar(), _varID, varNames, bindings);
	Var pred = appendVarId(stmt.getPredicateVar(), _varID, varNames, bindings);
	
	Var obj = new Var("o_" + _varID);
	varNames.add("o_" + _varID);
			
	Value objValue;
	if (stmt.getObjectVar().hasValue()) {
		objValue = stmt.getObjectVar().getValue();
	} else if (bindings.hasBinding(stmt.getObjectVar().getName())){
		objValue = bindings.getBinding(stmt.getObjectVar().getName()).getValue();
	} else {
		// just to make sure that we see an error, will be deleted soon
		throw new RuntimeException("Unexpected.");
	}
	
	Compare cmp = new Compare(obj, new ValueConstant(objValue));
	cmp.setOperator(CompareOp.EQ);
	Filter filter = new Filter( new StatementPattern(subj, pred, obj), cmp);
			
	return filter;
}
 
開發者ID:dice-group,項目名稱:CostFed,代碼行數:36,代碼來源:QueryAlgebraUtil.java

示例2: evaluateZeroLengthPath

import org.eclipse.rdf4j.query.algebra.Var; //導入依賴的package包/類
/**
 * Evaluate {@link ZeroLengthPath} query model nodes
 * @param parent
 * @param zlp
 * @param bindings
 */
private void evaluateZeroLengthPath(BindingSetPipe parent, ZeroLengthPath zlp, BindingSet bindings) {
    final Var subjectVar = zlp.getSubjectVar();
    final Var objVar = zlp.getObjectVar();
    final Var contextVar = zlp.getContextVar();
    Value subj = subjectVar.getValue() == null ? bindings.getValue(subjectVar.getName()) : subjectVar.getValue();
    Value obj = objVar.getValue() == null ? bindings.getValue(objVar.getName()) : objVar.getValue();
    if (subj != null && obj != null) {
        if (!subj.equals(obj)) {
            try {
                parent.push(null);
            } catch (InterruptedException e) {
                parent.handleException(e);
            }
            return;
        }
    }
    //temporary solution using copy of the original iterator
    //re-writing this to push model is a bit more complex task
    HalyardStatementPatternEvaluation.enqueue(parent, new ZeroLengthPathIteration(parentStrategy, subjectVar, objVar, subj, obj, contextVar, bindings), zlp);
}
 
開發者ID:Merck,項目名稱:Halyard,代碼行數:27,代碼來源:HalyardTupleExprEvaluation.java

示例3: renderTupleExpr

import org.eclipse.rdf4j.query.algebra.Var; //導入依賴的package包/類
/**
 * Renders the tuple expression as a query string. It creates a new
 * SparqlTupleExprRenderer rather than reusing this one.
 *
 * @param theExpr
 *        the expr to render
 * @return the rendered expression
 * @throws Exception
 *         if there is an error while rendering
 */
private String renderTupleExpr(TupleExpr theExpr)
        throws Exception
{
    SPARQLTupleExprRenderer aRenderer = new SPARQLTupleExprRenderer();

    // aRenderer.mProjection = new ArrayList<ProjectionElemList>(mProjection);
    // aRenderer.mDistinct = mDistinct;
    // aRenderer.mReduced = mReduced;
    // aRenderer.mExtensions = new HashMap<String, ValueExpr>(mExtensions);
    // aRenderer.mOrdering = new ArrayList<OrderElem>(mOrdering);
    // aRenderer.mLimit = mLimit;
    // aRenderer.mOffset = mOffset;

    aRenderer.mIndent = mIndent;
    aRenderer.mContexts = new HashMap<TupleExpr, Var>(mContexts);

    return aRenderer.render(theExpr);
}
 
開發者ID:semagrow,項目名稱:semagrow,代碼行數:29,代碼來源:SPARQLTupleExprRenderer.java

示例4: computeVars

import org.eclipse.rdf4j.query.algebra.Var; //導入依賴的package包/類
/**
 * Compute the variable names occurring in the service expression using tree
 * traversal, since these are necessary for building the SPARQL query.
 *
 * @return the set of variable names in the given service expression
 */
protected Set<String> computeVars(TupleExpr serviceExpression) {
    final Set<String> res = new HashSet<String>();
    serviceExpression.visit(new AbstractQueryModelVisitor<RuntimeException>() {

        @Override
        public void meet(Var node)
                throws RuntimeException {
            // take only real vars, i.e. ignore blank nodes
            if (!node.hasValue() && !node.isAnonymous())
                res.add(node.getName());
        }
        // TODO maybe stop tree traversal in nested SERVICE?
        // TODO special case handling for BIND
    });
    return res;
}
 
開發者ID:semagrow,項目名稱:semagrow,代碼行數:23,代碼來源:SPARQLQueryExecutor.java

示例5: transformPattern

import org.eclipse.rdf4j.query.algebra.Var; //導入依賴的package包/類
private Collection<FuzzyEntry<StatementPattern>> transformPattern(StatementPattern pattern)
{
    Set<FuzzyEntry<StatementPattern>> transformedPatterns = new HashSet<FuzzyEntry<StatementPattern>>();

    //queryTransformation.retrieveEquivalentURIs(pattern)
    Var sVar = pattern.getSubjectVar();
    Var pVar = pattern.getPredicateVar();
    Var oVar = pattern.getObjectVar();

    double patternProximity = 1.0;

    for (FuzzyEntry<Var> sVar1 : transformVar(sVar)) {
        for (FuzzyEntry<Var> pVar1 : transformVar(pVar)) {
            for (FuzzyEntry<Var> oVar1 : transformVar(oVar)) {
                StatementPattern p = new StatementPattern(sVar1.getElem(), pVar1.getElem(), oVar1.getElem());
                if (!p.equals(pattern)) {

                    double prox = Math.min(Math.min(sVar1.getProximity(), pVar1.getProximity()), oVar1.getProximity());
                    transformedPatterns.add(new FuzzyEntry<StatementPattern>(p, prox));
                }
            }
        }
    }

    return transformedPatterns;
}
 
開發者ID:semagrow,項目名稱:semagrow,代碼行數:27,代碼來源:SourceSelectorWithQueryTransform.java

示例6: transformVar

import org.eclipse.rdf4j.query.algebra.Var; //導入依賴的package包/類
private Collection<FuzzyEntry<Var>> transformVar(Var v) {
    Set<FuzzyEntry<Var>> vars = new HashSet<FuzzyEntry<Var>>();

    Value val = v.getValue();
    if (val != null && val instanceof IRI) {
        Collection<EquivalentIRI> uris =  getEquivalentURI(v);
        for(EquivalentIRI uri : uris)
        {
            Var v1 = transformVar(v,uri);
            vars.add(new FuzzyEntry<Var>(v1, uri.getProximity()));
        }
    }
    else {
        vars.add(new FuzzyEntry<Var>(v));
    }
    return vars;
}
 
開發者ID:semagrow,項目名稱:semagrow,代碼行數:18,代碼來源:SourceSelectorWithQueryTransform.java

示例7: enforceDataProps

import org.eclipse.rdf4j.query.algebra.Var; //導入依賴的package包/類
protected Collection<Plan> enforceDataProps(Plan plan, RequestedDataProperties dataProps) {
    if (!dataProps.isCoveredBy(plan.getProperties().getDataProperties()))
    {
        if (dataProps.ordering.isPresent()) {
            org.eclipse.rdf4j.query.algebra.Order o = new org.eclipse.rdf4j.query.algebra.Order(plan);
            Iterator<Ordering.OrderedVariable> vars = dataProps.ordering.get().getOrderedVariables();
            while (vars.hasNext()) {
                Ordering.OrderedVariable v = vars.next();
                boolean asc = v.getOrder() == Order.ASCENDING;
                // FIXME: if v.getOrder() == ANY then produce all possible orders (i.e. ASC and DESC)
                o.addElement(new OrderElem(new Var(v.getVariable()),asc));
            }

            return Collections.singleton(asPlan(o));
        }
    }
    return Collections.singleton(plan);
}
 
開發者ID:semagrow,項目名稱:semagrow,代碼行數:19,代碼來源:DefaultCompilerContext.java

示例8: hasStatements

import org.eclipse.rdf4j.query.algebra.Var; //導入依賴的package包/類
@Override
public boolean hasStatements(RepositoryConnection conn, Resource subj,
		IRI pred, Value obj, Resource... contexts)
		throws RepositoryException {
	
	if (!useASKQueries) {
		StatementPattern st = new StatementPattern(new Var("s", subj), new Var("p", pred), new Var("o", obj));
		try {
			return hasStatements(st, conn, EmptyBindingSet.getInstance());
		} catch (Exception e) {
			throw new RepositoryException(e);
		}
	}		
	return super.hasStatements(conn, subj, pred, obj, contexts);
}
 
開發者ID:dice-group,項目名稱:CostFed,代碼行數:16,代碼來源:SparqlTripleSource.java

示例9: toStatementPattern

import org.eclipse.rdf4j.query.algebra.Var; //導入依賴的package包/類
public static StatementPattern toStatementPattern(Resource subj, IRI pred, Value obj) {
	Var s = subj==null ? new Var("s") : new Var("const_s", subj);
	Var p = pred==null ? new Var("p") : new Var("const_p", pred);
	Var o = obj==null ? new Var("o") : new Var("const_o", obj);
	// TODO context
	
	return new StatementPattern(s, p, o);
}
 
開發者ID:dice-group,項目名稱:CostFed,代碼行數:9,代碼來源:QueryAlgebraUtil.java

示例10: appendVarId

import org.eclipse.rdf4j.query.algebra.Var; //導入依賴的package包/類
/**
 * Clone the specified variable and attach bindings, moreover change name of variable
 * by appending "_varId" to it.
 * 
 * @param sb
 * @param var
 * @param varNames
 * @param bindings
 * 
 * @return
 */
protected static Var appendVarId(Var var, String varID, Set<String> varNames, BindingSet bindings) {
	Var res = var.clone();
	if (!var.hasValue()) {
		if (bindings.hasBinding(var.getName())) {
			res.setValue( bindings.getValue(var.getName()) );
		} else {
			String newName = var.getName() + "_" + varID;
			varNames.add(newName);
			res.setName(newName);
		}			
	}
	return res;
}
 
開發者ID:dice-group,項目名稱:CostFed,代碼行數:25,代碼來源:QueryAlgebraUtil.java

示例11: append

import org.eclipse.rdf4j.query.algebra.Var; //導入依賴的package包/類
protected static void append(ValueExpr expr, StringBuilder sb) throws FilterConversionException {
	
	if (expr instanceof Compare) {
		append((Compare)expr, sb);
	} else if (expr instanceof Var) {
		append((Var)expr, sb);
	} else if (expr instanceof ValueConstant) {
		append((ValueConstant)expr, sb);
	} else {
		// TODO add more!
		throw new FilterConversionException("Expression type not supported, fallback to sesame evaluation: " + expr.getClass().getCanonicalName());
	}
	
}
 
開發者ID:dice-group,項目名稱:CostFed,代碼行數:15,代碼來源:FilterUtils.java

示例12: toValue

import org.eclipse.rdf4j.query.algebra.Var; //導入依賴的package包/類
protected static Value toValue(Var var, BindingSet bindings) {
	if (var.hasValue())
		return var.getValue();
	
	if (bindings.hasBinding(var.getName()))	
		return bindings.getValue(var.getName());
	
	return null;			
}
 
開發者ID:dice-group,項目名稱:CostFed,代碼行數:10,代碼來源:StatisticsUtil.java

示例13: Vertex

import org.eclipse.rdf4j.query.algebra.Var; //導入依賴的package包/類
/**
 *  Vertex constructor 
 * @param label Label of a vertex
 */
public Vertex(Var val, String label) {
	this.var = val;
	this.label = label;
	inEdges = new HashSet<HyperEdge>();
	outEdges = new HashSet<HyperEdge>();
}
 
開發者ID:dice-group,項目名稱:CostFed,代碼行數:11,代碼來源:HyperGraph.java

示例14: collectVertex

import org.eclipse.rdf4j.query.algebra.Var; //導入依賴的package包/類
private Vertex collectVertex(Var var, String label, Map<String, Vertex> v) {
	Vertex resultVertex = v.get(label);
	if (null == resultVertex) {
		resultVertex = new Vertex(var, label);
		v.put(label, resultVertex);
	}
	return resultVertex;
}
 
開發者ID:dice-group,項目名稱:CostFed,代碼行數:9,代碼來源:TBSSSourceSelection.java

示例15: getVarValue

import org.eclipse.rdf4j.query.algebra.Var; //導入依賴的package包/類
/**
 * Gets a value from a {@code Var} if it has a {@code Value}. If it does not then the method will attempt to get it 
 * from the bindings using the name of the Var
 * @param var
 * @param bindings
 * @return the matching {@code Value} or {@code null} if var is {@code null}
 */
private static Value getVarValue(Var var, BindingSet bindings) {
    if (var == null) {
        return null;
    } else if (var.hasValue()) {
        return var.getValue();
    } else {
        return bindings.getValue(var.getName());
    }
}
 
開發者ID:Merck,項目名稱:Halyard,代碼行數:17,代碼來源:HalyardStatementPatternEvaluation.java


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