当前位置: 首页>>代码示例>>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;未经允许,请勿转载。