当前位置: 首页>>代码示例>>Java>>正文


Java BasicPattern类代码示例

本文整理汇总了Java中com.hp.hpl.jena.sparql.core.BasicPattern的典型用法代码示例。如果您正苦于以下问题:Java BasicPattern类的具体用法?Java BasicPattern怎么用?Java BasicPattern使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BasicPattern类属于com.hp.hpl.jena.sparql.core包,在下文中一共展示了BasicPattern类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reorder

import com.hp.hpl.jena.sparql.core.BasicPattern; //导入依赖的package包/类
public BasicPattern reorder(BasicPattern pattern) {
    inputPattern = pattern;
    List<Triple> triples = inputPattern.getList();

    int idx = chooseFirst();
    Triple triple = triples.get(idx);
    outputPattern.add(triple);
    joinSchema.addAll(getVarsOfTriple(triple));
    triples.remove(idx);

    while (!triples.isEmpty()) {
        idx = chooseNext();
        triple = triples.get(idx);
        outputPattern.add(triple);
        joinSchema.addAll(getVarsOfTriple(triple));
        triples.remove(idx);
    }

    return outputPattern;
}
 
开发者ID:aschaetzle,项目名称:S2RDF,代码行数:21,代码来源:ReorderNoCross.java

示例2: visit

import com.hp.hpl.jena.sparql.core.BasicPattern; //导入依赖的package包/类
/**
 * Visitor for the property path
 * @author Simon Skilevic
 */
@Override
public void visit(OpPath opPath) {
	// Path subject
	Node subject = opPath.getTriplePath().getSubject();
	// Path object
	Node object = opPath.getTriplePath().getObject();
	// Property path 
	Path tPath = opPath.getTriplePath().getPath();
	
	String stringPath = tPath.toString();
	ArrayList<String> pathsStr = TransformerHelper.findAllPossiblePathes(stringPath);
	int id=0;
	for (String path:pathsStr){
		BasicPattern pt = TransformerHelper.transformPathToBasicPattern(subject, path, object);
		OpBGP opBGP = new OpBGP(pt);
    	stack.push(new SqlBGP(opBGP, prefixes));
		id++;
		if (id>1) {
			 SqlOp rightOp = stack.pop();
		     SqlOp leftOp = stack.pop();
		     stack.push(new SQLUnion(null, leftOp, rightOp, prefixes));
		}
	}
	
}
 
开发者ID:aschaetzle,项目名称:S2RDF,代码行数:30,代码来源:AlgebraTransformer.java

示例3: transform

import com.hp.hpl.jena.sparql.core.BasicPattern; //导入依赖的package包/类
@Override
public Op transform(OpBGP opBGP) {
    // if there are no more than 2 Triples -> reordering is useless
    if (opBGP.getPattern().size() <= 2) {
        return opBGP;
    }

    // Reorder by Selectivity
    ReorderFixed optimizer1 = (ReorderFixed) ReorderLib.fixed();
    BasicPattern optimizedPattern1 = optimizer1.reorder(opBGP.getPattern());

    // Reorder to avoid cross products and reduce the number of joins, if possible
    ReorderNoCross optimizer2 = new ReorderNoCross();
    BasicPattern optimizedPattern2 = optimizer2.reorder(optimizedPattern1);

    OpBGP optimizedBGP = new OpBGP(optimizedPattern2);
    return optimizedBGP;

    /*
    Heuristic variableCountingUnbound = new VariableCountingUnbound();
    BasicPatternGraph graph = new BasicPatternGraph(opBGP.getPattern(), variableCountingUnbound);
    BasicPattern optimizedPattern2 = graph.optimize();
    OpBGP optimizedBGP2 = new OpBGP(optimizedPattern2);
    return optimizedBGP2;
     */
}
 
开发者ID:aschaetzle,项目名称:S2RDF,代码行数:27,代码来源:BGPOptimizerNoStats.java

示例4: reorder

import com.hp.hpl.jena.sparql.core.BasicPattern; //导入依赖的package包/类
public BasicPattern reorder(BasicPattern pattern) {
	inputPattern = pattern;
	List<Triple> triples = inputPattern.getList();

	int idx = chooseFirst();
	Triple triple = triples.get(idx);
	outputPattern.add(triple);
	addToJoinVars(getVarsOfTriple(triple));
	triples.remove(idx);

	while (!triples.isEmpty()) {
		idx = chooseNext();
		triple = triples.get(idx);
		outputPattern.add(triple);
		addToJoinVars(getVarsOfTriple(triple));		
		triples.remove(idx);
	}

	return outputPattern;
}
 
开发者ID:aschaetzle,项目名称:PigSPARQL,代码行数:21,代码来源:ReorderNoCross.java

示例5: transform

import com.hp.hpl.jena.sparql.core.BasicPattern; //导入依赖的package包/类
@Override
public Op transform(OpBGP opBGP) {
    // if there are no more than 2 Triples -> reordering is useless
    if (opBGP.getPattern().size() <= 2) {
        return opBGP;
    }

    // Reorder by Selectivity
    ReorderFixed optimizer1 = (ReorderFixed) ReorderLib.fixed();
    BasicPattern optimizedPattern1 = optimizer1.reorder(opBGP.getPattern());

    // Reorder to avoid cross products and reduce the number of joins, if possible -> Multijoins
    ReorderNoCross optimizer2 = new ReorderNoCross();
    BasicPattern optimizedPattern2 = optimizer2.reorder(optimizedPattern1);

    OpBGP optimizedBGP = new OpBGP(optimizedPattern2);
    return optimizedBGP;

    /*
    Heuristic variableCountingUnbound = new VariableCountingUnbound();
    BasicPatternGraph graph = new BasicPatternGraph(opBGP.getPattern(), variableCountingUnbound);
    BasicPattern optimizedPattern2 = graph.optimize();
    OpBGP optimizedBGP2 = new OpBGP(optimizedPattern2);
    return optimizedBGP2;
     */
}
 
开发者ID:aschaetzle,项目名称:PigSPARQL,代码行数:27,代码来源:BGPOptimizerNoStats.java

示例6: reorder

import com.hp.hpl.jena.sparql.core.BasicPattern; //导入依赖的package包/类
public BasicPattern reorder(BasicPattern pattern) {
	inputPattern = pattern;
	List<Triple> triples = inputPattern.getList();

	int idx = chooseFirst();
	Triple triple = triples.get(idx);
	outputPattern.add(triple);
	joinSchema.addAll(getVarsOfTriple(triple));
	triples.remove(idx);

	while (!triples.isEmpty()) {
		idx = chooseNext();
		triple = triples.get(idx);
		outputPattern.add(triple);
		joinSchema.addAll(getVarsOfTriple(triple));
		triples.remove(idx);
	}

	return outputPattern;
}
 
开发者ID:aschaetzle,项目名称:Sempala,代码行数:21,代码来源:ReorderNoCross.java

示例7: transform

import com.hp.hpl.jena.sparql.core.BasicPattern; //导入依赖的package包/类
@Override
public Op transform(OpBGP opBGP) {
	// if there are no more than 2 Triples -> reordering is useless
	if (opBGP.getPattern().size() <= 2) {
		return opBGP;
	}

	// Reorder by Selectivity
	ReorderFixed optimizer1 = (ReorderFixed) ReorderLib.fixed();
	BasicPattern optimizedPattern1 = optimizer1.reorder(opBGP.getPattern());

	// Reorder to avoid cross products and reduce the number of joins, if possible
	ReorderNoCross optimizer2 = new ReorderNoCross();
	BasicPattern optimizedPattern2 = optimizer2.reorder(optimizedPattern1);

	OpBGP optimizedBGP = new OpBGP(optimizedPattern2);
	return optimizedBGP;

	/*
	Heuristic variableCountingUnbound = new VariableCountingUnbound();
	BasicPatternGraph graph = new BasicPatternGraph(opBGP.getPattern(), variableCountingUnbound);
	BasicPattern optimizedPattern2 = graph.optimize();
	OpBGP optimizedBGP2 = new OpBGP(optimizedPattern2);
	return optimizedBGP2;
	 */
}
 
开发者ID:aschaetzle,项目名称:Sempala,代码行数:27,代码来源:BGPOptimizerNoStats.java

示例8: prepareBindings

import com.hp.hpl.jena.sparql.core.BasicPattern; //导入依赖的package包/类
public BindingQueryPlan prepareBindings(GraphQuery q, Node[] variables) {   
	this.variables = variables;
	this.indexes = new HashMap<Node,Integer>();
	for (int i = 0; i < variables.length; i++) {
		indexes.put(variables[i], new Integer(i));
	}
	BasicPattern pattern = new BasicPattern();
	for (Triple t: q.getPattern()) {
		pattern.add(t);
	}
	Plan plan = QueryEngineD2RQ.getFactory().create(new OpBGP(pattern), dataset, null, null);
	final ExtendedIterator<Domain> queryIterator = new Map1Iterator<Binding,Domain>(new BindingToDomain(), plan.iterator());
	return new BindingQueryPlan() {
		public ExtendedIterator<Domain> executeBindings() {
			return queryIterator;
		}
	};
}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:19,代码来源:D2RQQueryHandler.java

示例9: prepareBindings

import com.hp.hpl.jena.sparql.core.BasicPattern; //导入依赖的package包/类
public BindingQueryPlan prepareBindings(Query q, Node[] variables) {   
	this.variables = variables;
	this.indexes = new HashMap<Node,Integer>();
	for (int i = 0; i < variables.length; i++) {
		indexes.put(variables[i], new Integer(i));
	}
	BasicPattern pattern = new BasicPattern();
	for (Triple t: q.getPattern()) {
		pattern.add(t);
	}
	Plan plan = QueryEngineD2RQ.getFactory().create(new OpBGP(pattern), dataset, null, null);
	final ExtendedIterator<Domain> queryIterator = new Map1Iterator<Binding,Domain>(new BindingToDomain(), plan.iterator());
	return new BindingQueryPlan() {
		public ExtendedIterator<Domain> executeBindings() {
			return queryIterator;
		}
	};
}
 
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:19,代码来源:D2RQQueryHandler.java

示例10: mergeToBGP

import com.hp.hpl.jena.sparql.core.BasicPattern; //导入依赖的package包/类
private Op mergeToBGP(Op left, Op right) {
	BasicPattern bgp = new BasicPattern();
	if (OpBGP.isBGP(left)) {
		bgp.addAll(((OpBGP) left).getPattern());
	} else {
		if (!(left instanceof OpTable))
		Log.warn(this, "mergeToBGP left not valid BGP " + left.toString());
	}
	if (OpBGP.isBGP(right)) {
		bgp.addAll(((OpBGP) right).getPattern());
		;
	} else {
		if (!(right instanceof OpTable))
		Log.warn(this, "mergeToBGP right not valid BGP"+ right.toString());
	}
	return new OpBGP(bgp);
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.remediator,代码行数:18,代码来源:Simplifier.java

示例11: evaluateBlockFilter

import com.hp.hpl.jena.sparql.core.BasicPattern; //导入依赖的package包/类
@Override
protected QueryIterator evaluateBlockFilter(Node graphNode, BasicPattern bgp, ExprList exprs, QueryIterator input) {
    // XXX Do as quads.
    Graph graph ;
    // chooseGraph
    if ( graphNode == null ) 
        graph = dataset.getDefaultGraph() ;
    else if ( Var.isVar(graphNode) )
        throw new NotImplemented("OpExecutorMain.executeBlockFilter[Variable]") ;
    else if ( graphNode == Node.ANY )
        throw new NotImplemented("OpExecutorMain.executeBlockFilter[Node.ANY]") ;
    else
        graph = dataset.getGraph(graphNode) ;
    
    return evaluateBlockFilter(graph, bgp, exprs, input);
}
 
开发者ID:afs,项目名称:quack,代码行数:17,代码来源:OpExecutorRowsMain.java

示例12: evaluateBlockFilterSub

import com.hp.hpl.jena.sparql.core.BasicPattern; //导入依赖的package包/类
/** Execute for one input binding */  
protected QueryIterator evaluateBlockFilterSub(DatasetGraphTDB dsgtdb, Node graphNode, BasicPattern bgp, ExprList exprs, Binding input1) {
    Explain2.explain(Quack.quackExec, "%s, BGP =\n%s", graphNode, bgp) ;  
    PhysicalPlan<NodeId> plan = new PhysicalPlan<>() ;
    bgp = Substitute.substitute(bgp, input1) ;
    
    if ( exprs != null ) {
        Op op ;
        if ( graphNode == null )
            op = TransformFilterPlacement.transform(exprs, bgp) ;
        else
            op = TransformFilterPlacement.transform(exprs, graphNode, bgp) ;
        accumulatePlan(plan, graphNode, op);
    } else {
        accumulatePlan(plan, graphNode, bgp) ;
    }
    
    return executePlan$(plan, input1) ;
}
 
开发者ID:afs,项目名称:quack,代码行数:20,代码来源:OpExecutorQuackTDB.java

示例13: accumulatePlan

import com.hp.hpl.jena.sparql.core.BasicPattern; //导入依赖的package包/类
private void accumulatePlan(PhysicalPlan<NodeId> plan, Node graphNode, BasicPattern basicPattern) {
    List<Triple> triples = basicPattern.getList() ;
    int N = OpExecLib.isDefaultGraph(graphNode) ? 3 : 4 ;
    List<Tuple<Slot<NodeId>>> tuples ;
    if ( OpExecLib.isDefaultGraph(graphNode) ) 
        tuples = ELibTDB.convertTriples(triples, accessor.getNodeTable()) ;
    else 
        tuples = ELibTDB.convertQuads(graphNode, triples, accessor.getNodeTable()) ;
    
    // Some concrete term was not found so this pattern can not match. 
    if ( tuples == null ) {
        plan.add(new StepNothing<NodeId>()) ;
        return ;
    }
    // accumulate would be clearer
    PhysicalPlan<NodeId> p = generateAccessPlan(tuples) ;
    plan.append(p) ;
}
 
开发者ID:afs,项目名称:quack,代码行数:19,代码来源:OpExecutorQuackTDB.java

示例14: prepareBindings

import com.hp.hpl.jena.sparql.core.BasicPattern; //导入依赖的package包/类
/**
 * <p>Method that prepares the bindings for a query plan</p>
 * @param q - the input query
 * @param variables - the variables in the given query
 * @return a binding query plan
 * 
 * @see de.fuberlin.wiwiss.d2rq.D2RQQueryHandler#prepareBindings(Query, Node[])
 */
@SuppressWarnings("unchecked")
public BindingQueryPlan prepareBindings(Query q, Node[] variables) 
{   
	this.variables = variables;
	this.indexes = new HashMap();
	for (int i = 0; i < variables.length; i++) { indexes.put(variables[i], new Integer(i)); }
	BasicPattern pattern = new BasicPattern();
	Iterator it = q.getPattern().iterator();
	while (it.hasNext()) 
	{
		Triple t = (Triple) it.next();
		pattern.add(t);
	}
	Plan plan = QueryEngineD2RQ.getFactory().create(new OpBGP(pattern), dataset, null, null);
	final ExtendedIterator queryIterator = new Map1Iterator(new BindingToDomain(), plan.iterator());
	return new BindingQueryPlan() 
	{
		public ExtendedIterator executeBindings() { return queryIterator; }
	};
}
 
开发者ID:vaibhavkhadilkar,项目名称:D2RQ-Update,代码行数:29,代码来源:D2RQRWQueryHandler.java

示例15: transformPathToBasicPattern

import com.hp.hpl.jena.sparql.core.BasicPattern; //导入依赖的package包/类
public static BasicPattern transformPathToBasicPattern(Node subject, String sPath, Node object){
	BasicPattern res= new BasicPattern();
	boolean inverse = checkInverse(sPath);
	if (inverse)
	{
		sPath = sPath.substring(1);
		Node temp = subject;
		subject = object;
		object = temp;
	}
	sPath = TransformerHelper.removeScopes(sPath);
	int operatorPos = TransformerHelper.getPosOfNextOperator(sPath);
	if (operatorPos < 0)
	{
		Triple triple = new Triple(subject, NodeFactory.createURI(sPath.substring(1, sPath.length()-1)), object);
		res.add(triple);
		return res;
	}
   	String leftStringPath = sPath.substring(0, operatorPos);
   	String rightStringPath = sPath.substring(operatorPos+1);
   	Node newConection = NodeFactory.createVariable(getNextVaribleName());
   	BasicPattern leftPattern = transformPathToBasicPattern(subject, leftStringPath, newConection);
   	BasicPattern rightPattern = transformPathToBasicPattern(newConection, rightStringPath, object);
   	res.addAll(leftPattern);
   	res.addAll(rightPattern);
	return res;
}
 
开发者ID:aschaetzle,项目名称:S2RDF,代码行数:28,代码来源:TransformerHelper.java


注:本文中的com.hp.hpl.jena.sparql.core.BasicPattern类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。