本文整理汇总了Java中com.hp.hpl.jena.sparql.algebra.op.OpBGP类的典型用法代码示例。如果您正苦于以下问题:Java OpBGP类的具体用法?Java OpBGP怎么用?Java OpBGP使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OpBGP类属于com.hp.hpl.jena.sparql.algebra.op包,在下文中一共展示了OpBGP类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildBGP
import com.hp.hpl.jena.sparql.algebra.op.OpBGP; //导入依赖的package包/类
private void buildBGP(OpBGP op) {
final List<Triple> triples = op.getPattern().getList();
for (final Triple triple : triples) {
final Node subjectNode = triple.getSubject();
final Node predicateNode = triple.getPredicate();
final Node objectNode = triple.getObject();
final String subject = PrefixUtil.collapsePrefix(FmtUtils
.stringForNode(subjectNode, prefixes));
final String object = PrefixUtil.collapsePrefix(FmtUtils
.stringForNode(objectNode, prefixes));
final String predicate = PrefixUtil.collapsePrefix(FmtUtils
.stringForNode(predicateNode, prefixes));
if (bgp == null) {
bgp = new ArrayList<TriplePattern>();
}
bgp.add(new TriplePattern(subject, predicate, object));
}
}
示例2: visit
import com.hp.hpl.jena.sparql.algebra.op.OpBGP; //导入依赖的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.algebra.op.OpBGP; //导入依赖的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: transform
import com.hp.hpl.jena.sparql.algebra.op.OpBGP; //导入依赖的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;
*/
}
示例5: visit
import com.hp.hpl.jena.sparql.algebra.op.OpBGP; //导入依赖的package包/类
@Override
public void visit(OpBGP opBGP) {
switch (format) {
case PROPERTYTABLE:
stack.push(new ImpalaBgpPropertyTable(opBGP, prefixes));
break;
case COMPLEX_PROPERTY_TABLE:
stack.push(new ImpalaBgpComplexPropertyTable(opBGP, prefixes));
break;
case COMPLEX_PROPERTY_TABLE_SPARK:
stack.push(new SparkBgpComplexPropertyTable(opBGP, prefixes));
break;
case SINGLETABLE:
stack.push(new ImpalaBgpExtVPSingleTable(opBGP, prefixes));
break;
case EXTVP:
stack.push(new ImpalaBgpExtVPMultiTable(opBGP, prefixes));
break;
}
}
示例6: transform
import com.hp.hpl.jena.sparql.algebra.op.OpBGP; //导入依赖的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;
*/
}
示例7: prepareBindings
import com.hp.hpl.jena.sparql.algebra.op.OpBGP; //导入依赖的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;
}
};
}
示例8: createOpD2RQ
import com.hp.hpl.jena.sparql.algebra.op.OpBGP; //导入依赖的package包/类
public Op createOpD2RQ(OpBGP opBGP, ExprList filters) {
List<NodeRelation> tables = new GraphPatternTranslator(
opBGP.getPattern().getList(), mapping.compiledPropertyBridges(),
useAllOptimizations).translate();
if (useAllOptimizations) {
log.debug("NodeRelations before applying filters: " + tables.size());
ExprList copy = new ExprList(filters);
for (Expr filter: copy) {
tables = applyFilter(tables, filter, filters);
}
if (log.isDebugEnabled()) {
log.debug("NodeRelations after applying filters: " + tables.size());
}
}
Op op = OpUnionTableSQL.create(tables);
if (!filters.isEmpty()) {
op = OpFilter.filter(filters, op);
}
return op;
}
示例9: prepareBindings
import com.hp.hpl.jena.sparql.algebra.op.OpBGP; //导入依赖的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: transform
import com.hp.hpl.jena.sparql.algebra.op.OpBGP; //导入依赖的package包/类
public Op transform(RemediatorQuery remediatorQuery) {
if (OpBGP.isBGP(remediatorQuery.getSimplifiedOperations())) {
{
DatasetQueryVarLinksets linksetOpServices;
originalClause = BGPToClause((OpBGP) remediatorQuery.getSimplifiedOperations());
rewriteBGP(originalClause);
voidModel.InferVariableClasses(globalQueryVars);
globalQueryVars.locateDatasetClauses(datasets);
linksetOpServices=linksets.createLinksetQueryClauses(globalQueryVars);
if (optimize && ! voidModel.getPartitionStatisticsAvailable()){
Log.warn(this, "Statistics not queried nor read so optimization of query plan not avaiable. Heuristic will be used instead");
this.optimize=false;
}
queryPlan = new QueryPlan(globalQueryVars, optimize);
//datasets.createDatasetQueryClauses(remediatorQuery, globalQueryVars);
return createOpSequence(linksetOpServices);
}
} else {
Log.warn(this, "Can only transform BGPs " + remediatorQuery.getSimplifiedOperations().toString());
return null;
}
}
示例11: transform
import com.hp.hpl.jena.sparql.algebra.op.OpBGP; //导入依赖的package包/类
@Override
public Op transform(OpBGP opBGP) {
OpBGP substitutedOp = new OpBGP();
for (Triple triple : opBGP.getPattern().getList()) {
if (simplifiedTriples.containsKey(triple.hashCode())) {
Term rewrittenTerm = queryClause.getRewrittenTriple(triple
.hashCode());
if (rewrittenTerm != null) {
Triple rewrittenTriple = queryClause.getDataset()
.termToTriple(queryVars, rewrittenTerm);
substitutedOp.getPattern().add(rewrittenTriple);
}
}
}
if(substitutedOp.getPattern().size()==0){
return OpLabel.create(PRUNED ,null);
}else
{
return substitutedOp;
}
}
示例12: mergeToBGP
import com.hp.hpl.jena.sparql.algebra.op.OpBGP; //导入依赖的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);
}
示例13: execute
import com.hp.hpl.jena.sparql.algebra.op.OpBGP; //导入依赖的package包/类
@Override
protected QueryIterator execute(OpFilter opFilter, QueryIterator input)
{
if ( ! isForThisExecutor )
return super.execute(opFilter, input) ;
Op sub = opFilter.getSubOp() ;
// (filter (bgp ...))
if ( OpBGP.isBGP(sub) )
{
OpBGP opBGP = (OpBGP)sub ;
return evaluateBlockFilter(execCxt.getActiveGraph(), opBGP.getPattern(), opFilter.getExprs(), input) ;
}
// (filter (quadpattern ...))
if ( sub instanceof OpQuadPattern )
{
OpQuadPattern quadPattern = (OpQuadPattern)sub ;
return evaluateBlockFilter(quadPattern.getGraphNode(), quadPattern.getBasicPattern(), opFilter.getExprs(), input) ;
}
// TODO OpTable.
return super.execute(opFilter, input) ;
}
示例14: prepareBindings
import com.hp.hpl.jena.sparql.algebra.op.OpBGP; //导入依赖的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: visit
import com.hp.hpl.jena.sparql.algebra.op.OpBGP; //导入依赖的package包/类
@Override
public void visit(OpBGP opBGP) {
SparkBGP bgp = new SparkBGP(opBGP, prefixes);
/*
* Add it twice. The first run will match the BGP and the second run
* will build the result. This is done for the exact time measuring and
* could basically done with one object but then without exact time
* measuring.
*/
executionQueue.add(bgp);
executionQueue.add(bgp);
}