本文整理汇总了Java中com.hp.hpl.jena.sparql.algebra.Op类的典型用法代码示例。如果您正苦于以下问题:Java Op类的具体用法?Java Op怎么用?Java Op使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Op类属于com.hp.hpl.jena.sparql.algebra包,在下文中一共展示了Op类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transform
import com.hp.hpl.jena.sparql.algebra.Op; //导入依赖的package包/类
@Override
public Op transform(OpFilter opFilter, Op subOp) {
if ( ! (subOp instanceof OpBGP) )
return super.transform(opFilter, subOp);
ExprList exprs = opFilter.getExprs();
Op op = subOp;
// Variables set
Set<Var> patternVars = OpVars.visibleVars(op);
// Any assignments must go inside filters so the filters see the assignments.
ExprList exprs2 = new ExprList();
for ( Expr e : exprs.getList() ) {
Op op2 = processFilterWorker(e, op, patternVars);
if ( op2 == null )
exprs2.add(e);
else
op = op2;
}
// Place any filter expressions around the processed sub op.
if ( exprs2.size() > 0 )
op = OpFilter.filter(exprs2, op);
return op;
}
示例2: transform
import com.hp.hpl.jena.sparql.algebra.Op; //导入依赖的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;
*/
}
示例3: transform
import com.hp.hpl.jena.sparql.algebra.Op; //导入依赖的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;
*/
}
示例4: transform
import com.hp.hpl.jena.sparql.algebra.Op; //导入依赖的package包/类
@Override
public Op transform(OpFilter opFilter, Op subOp) {
if ( ! (subOp instanceof OpBGP) )
return super.transform(opFilter, subOp);
ExprList exprs = opFilter.getExprs();
Op op = subOp;
// Variables set
Set<Var> patternVars = OpVars.visibleVars(op);
// Any assignments must go inside filters so the filters see the assignments.
ExprList exprs2 = new ExprList();
for ( Expr e : exprs.getList() ) {
Op op2 = processFilterWorker(e, op, patternVars);
if ( op2 == null )
exprs2.add(e);
else
op = op2;
}
// Place any filter expressions around the processed sub op.
if ( exprs2.size() > 0 )
op = OpFilter.filter(exprs2, op);
return op;
}
示例5: transform
import com.hp.hpl.jena.sparql.algebra.Op; //导入依赖的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;
*/
}
示例6: visit
import com.hp.hpl.jena.sparql.algebra.Op; //导入依赖的package包/类
/**
* When visiting an OpFilter, all its filterconditions are collected during
* the top-down-stepping. During the bottom-up-stepping all filterconditions
* which were moved down, are removed
*/
public void visit(final OpFilter opFilter) {
filterExpr.addAll(opFilter.getExprs().getList());
Op subOp = null;
if (opFilter.getSubOp() != null) {
opFilter.getSubOp().visit(this);
subOp = stack.pop();
}
opFilter.getExprs().getList().removeAll(filterExpr);
// remove the filter if it has no expressions
if (opFilter.getExprs().isEmpty()) {
stack.push(subOp);
} else {
stack.push(opFilter);
}
}
示例7: wrapInCurrentFilterAndRecurse
import com.hp.hpl.jena.sparql.algebra.Op; //导入依赖的package包/类
private void wrapInCurrentFilterAndRecurse(Op2 op2) {
List<Expr> retainedFilterExpr = new ArrayList<Expr>(filterExpr);
filterExpr.clear();
Op left = null;
if (op2.getLeft() != null) {
op2.getLeft().visit(this);
left = stack.pop();
}
Op right = null;
if (op2.getRight() != null) {
op2.getRight().visit(this);
right = stack.pop();
}
wrapInFilter(op2.apply(copy, left, right), retainedFilterExpr);
filterExpr = retainedFilterExpr;
}
示例8: createOpD2RQ
import com.hp.hpl.jena.sparql.algebra.Op; //导入依赖的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: translate
import com.hp.hpl.jena.sparql.algebra.Op; //导入依赖的package包/类
/**
* Method for translating an operator-tree. Move filter conditions as far as
* possible down in the tree. In the optimal way, the filter conditions is
* the parent of an OpBGP.
*/
private Op translate(Op op) {
if (log.isDebugEnabled()) {
log.debug("Before translation:\n" + PrintUtils.toString(op));
}
// Shape filter expressions to maximize opportunities for pushing them
// down
op = Transformer.transform(new TransformFilterCNF(), op);
// Try to move any filters as far down as possible
op = PushDownOpFilterVisitor.transform(op);
// Translate BGPs that have a filter immediately above them
op = Transformer.transform(new TransformOpBGP(mapping, true), op);
// Translate BGPs that don't have a filter
op = Transformer.transform(new TransformOpBGP(mapping, false), op);
if (log.isDebugEnabled()) {
log.debug("After translation:\n" + PrintUtils.toString(op));
}
return op;
}
示例10: executeQuery
import com.hp.hpl.jena.sparql.algebra.Op; //导入依赖的package包/类
public String executeQuery() {
Query query = QueryFactory.create(this.getQuery(), Syntax.syntaxARQ);
Op op = Algebra.compile(query);
try {
if(new String("internal").equals(this.service)) {
this.results = jenaService.runLocalOp(op);
} else if (new String("external").equals(this.service)) {
this.results = jenaService.runExternalOp(op);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
}
return ("success");
}
示例11: visit
import com.hp.hpl.jena.sparql.algebra.Op; //导入依赖的package包/类
@Override
public void visit(OpService opService) {
Table input = pop();
if (!input.isEmpty()) {
TableFactory tableFactory = new TableFactory();
ArrayList<Var> vars= new ArrayList<Var>( OpVars.mentionedVars(opService));
//Table inputVars = TableFactory.create(input,vars);
Table inputVars = new TableFiltered(input,vars);
Op op1 = OpSequence.create(opService.getSubOp(),
OpTable.create(inputVars));
opService = new OpService(opService.getService(), op1,
opService.getSilent());
}
QueryIterator qIter = Service.exec(opService, ARQ.getContext());
Table table = TableFactory.create(qIter);
push(table);
}
示例12: transform
import com.hp.hpl.jena.sparql.algebra.Op; //导入依赖的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;
}
}
示例13: transform
import com.hp.hpl.jena.sparql.algebra.Op; //导入依赖的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;
}
}
示例14: compileElementOptional
import com.hp.hpl.jena.sparql.algebra.Op; //导入依赖的package包/类
protected Op compileElementOptional(ElementOptional eltOpt, Op current) {
Element subElt = eltOpt.getOptionalElement();
Op op = compileElement(subElt);
ExprList exprs = null;
if (op instanceof OpFilter) {
OpFilter f = (OpFilter)op;
//f = OpFilter.tidy(f) ; // Collapse filter(filter(..))
Op sub = f.getSubOp();
if (sub instanceof OpFilter)
broken("compile/Optional/nested filters - unfinished") ;
exprs = f.getExprs();
op = sub;
}
current = OpLeftJoin.create(current, op, exprs);
return current;
}
示例15: compileElementGroup
import com.hp.hpl.jena.sparql.algebra.Op; //导入依赖的package包/类
protected Op compileElementGroup(ElementGroup groupElt) {
Op current = OpTable.unit();
// First: get all filters, merge adjacent BGPs. This includes BGP-FILTER-BGP
// This is done in finalizeSyntax after which the new ElementGroup is in
// the right order w.r.t. BGPs and filters.
// This is a delay from parsing time so a printed query
// keeps filters where the query author put them.
List<Element> groupElts = finalizeSyntax(groupElt);
// Second: compile the consolidated group elements.
// Assumes that filters moved to end.
for (Iterator<Element> iter = groupElts.listIterator(); iter.hasNext(); ) {
Element elt = iter.next();
current = compileOneInGroup(elt, current);
}
return current;
}