本文整理汇总了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;
}
示例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));
}
}
}
示例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;
*/
}
示例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;
}
示例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;
*/
}
示例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;
}
示例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;
*/
}
示例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;
}
};
}
示例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;
}
};
}
示例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);
}
示例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);
}
示例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) ;
}
示例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) ;
}
示例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; }
};
}
示例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;
}