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


Java TupleExpr.visit方法代码示例

本文整理汇总了Java中org.openrdf.query.algebra.TupleExpr.visit方法的典型用法代码示例。如果您正苦于以下问题:Java TupleExpr.visit方法的具体用法?Java TupleExpr.visit怎么用?Java TupleExpr.visit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openrdf.query.algebra.TupleExpr的用法示例。


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

示例1: rewrite

import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
/**
 * Rewrite a given query to add inference.
 *
 * @param ql the query language used for the query
 * @param query the query to rewrite
 * @param baseuri a base URI to use for the query
 * @return rewritten query that includes inference
 * @throws MalformedQueryException if the query is malformed
 * @throws RepositoryException if there was a problem while rewriting
 */
public Query rewrite(QueryLanguage ql, String query, String baseuri)
		throws MalformedQueryException, RepositoryException {
	// parse query using Sesame
	QueryParserFactory f = QueryParserRegistry.getInstance().get(ql);
	QueryParser parser = f.getParser();
	ParsedQuery parsed = parser.parseQuery(query, baseuri);
	// get SPARQL algebra expression from parsed query
	TupleExpr expr = parsed.getTupleExpr();
	// rewrite query using visitor pattern
	RuleTransformationVisitor visitor
			= new RuleTransformationVisitor(rules);
	expr.visit(visitor);
	// return new query based on rewritten algebra expression
	return getExprQuery(parsed, expr);
}
 
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:26,代码来源:QueryRewriter.java

示例2: getJoinSelect

import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
public double getJoinSelect(RdfCloudTripleStoreConfiguration conf, TupleExpr te1, TupleExpr te2) throws TableNotFoundException {

      SpExternalCollector spe = new SpExternalCollector();
      te2.visit(spe);
      List<QueryModelNode> espList = spe.getSpExtTup();  
      
      double min = Double.MAX_VALUE;

      for (QueryModelNode node : espList) {
        double select = getSelectivity(conf, te1, node);
        if (min > select) {
          min = select;
        }
      }

      return min;
    }
 
开发者ID:apache,项目名称:incubator-rya,代码行数:18,代码来源:AccumuloSelectivityEvalDAO.java

示例3: meet

import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
@Override
public void meet(Join node) {

    List<TupleExpr> reOrder = reOrderMap.get(node);
    if (reOrder != null) {
        List<Filter> filterList = Lists.newArrayList(filterArgs.get(node));
        node.replaceWith(getNewJoin(reOrder, getFilterChain(filterList)));

        for (TupleExpr te : reOrder) {
            if (!(te instanceof StatementPattern) && !(te instanceof ExternalTupleSet)) {
                te.visit(this);
            }
        }
    }
    super.meet(node);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:17,代码来源:TupleReArranger.java

示例4: evaluate

import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
static CloseableIteration<BindingSet, QueryEvaluationException> evaluate(
        final TripleTransaction transaction, final TupleExpr expr,
        @Nullable final Dataset dataset, @Nullable final BindingSet bindings,
        @Nullable final Long timeout) throws QueryEvaluationException {

    Preconditions.checkNotNull(transaction);

    final AtomicBoolean delegate = new AtomicBoolean(false);
    expr.visit(new QueryModelVisitorBase<RuntimeException>() {

        @Override
        public void meet(final StatementPattern node) throws RuntimeException {
            delegate.set(true);
        }

    });

    final EvaluationStrategy strategy = delegate.get() ? new DelegatingEvaluationStrategy(
            transaction, dataset, timeout, false) : new LocalEvaluationStrategy(transaction,
            dataset, timeout);

    return strategy
            .evaluate(expr, bindings != null ? bindings : EmptyBindingSet.getInstance());
}
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:25,代码来源:SparqlHelper.java

示例5: meet

import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
@Override
public void meet(Join node) {
    try {
        if (node.getLeftArg() instanceof FixedStatementPattern && node.getRightArg() instanceof DoNotExpandSP) {
            return;
        }
        List<TupleExpr> joinArgs = getJoinArgs(node, new ArrayList<TupleExpr>());
        HashMultimap<String, StatementPattern> varMap = getVarBins(joinArgs);
        while (!varMap.keySet().isEmpty()) {
            String s = getHighestPriorityKey(varMap);
            constructTuple(varMap, joinArgs, s);
        }
        List<TupleExpr> filterChain = getFilterChain(joinArgs);

        for (TupleExpr te : joinArgs) {
            if (!(te instanceof StatementPattern) || !(te instanceof EntityTupleSet)) {
                te.visit(this);
            }
        }
        // Replace old join hierarchy
        node.replaceWith(getNewJoin(joinArgs, filterChain));

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:27,代码来源:EntityOptimizer.java

示例6: optimize

import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
@Override
public void optimize(final TupleExpr tupleExpr, final Dataset dataset, final BindingSet bindings) {
	// use native support for range queries
	if (_ranges_indexed) {
		tupleExpr.visit(new RangeQueryVisitor(tupleExpr));
		tupleExpr.visit(new OrderByVisitor(tupleExpr));
	}

	// use native cumulus model
	tupleExpr.visit(new CumulusNativeModelVisitor());
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:12,代码来源:CumulusQueryOptimizer.java

示例7: setVarOrderAndQueryType

import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
private void setVarOrderAndQueryType(final QueryMetadata.Builder builder, final TupleExpr te) {
    final QueryMetadataLocator locator = new QueryMetadataLocator();
    try {
        te.visit(locator);
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }

    builder.setVarOrder(locator.getVarOrder());
    builder.setQueryType(locator.getQueryType());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:12,代码来源:SparqlFluoQueryBuilder.java

示例8: processPropertySearches

import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
private void processPropertySearches(final TupleExpr tupleExpr, final Collection<Var> searchProperties) {
    final MatchStatementVisitor matchStatements = new MatchStatementVisitor(searchProperties);
    tupleExpr.visit(matchStatements);
    for (final StatementPattern matchStatement: matchStatements.matchStatements) {
        final Var subject = matchStatement.getSubjectVar();
        if (subject.hasValue() && !(subject.getValue() instanceof Resource)) {
            throw new IllegalArgumentException("Query error: Found " + subject.getValue() + ", expected an URI or BNode");
        }
        Validate.isTrue(subject.hasValue() || subject.getName() != null);
        Validate.isTrue(!matchStatement.getObjectVar().hasValue() && matchStatement.getObjectVar().getName() != null);
        buildQuery(tupleExpr, matchStatement);
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:14,代码来源:FilterFunctionOptimizer.java

示例9: testPeriodicNodeLocation

import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
@Test
public void testPeriodicNodeLocation() throws MalformedQueryException {
     String query = "prefix function: <http://org.apache.rya/function#> " //n
            + "prefix time: <http://www.w3.org/2006/time#> " //n
            + "prefix fn: <http://www.w3.org/2006/fn#> " //n
            + "select ?obs ?time ?lat where {" //n
            + "Filter(function:periodic(?time, 1,.5,time:hours)) " //n
            + "Filter(fn:test(?lat, 25)) " //n
            + "?obs <uri:hasTime> ?time. " //n
            + "?obs <uri:hasLattitude> ?lat }"; //n
     
     SPARQLParser parser = new SPARQLParser();
     ParsedQuery pq = parser.parseQuery(query, null);
     TupleExpr te = pq.getTupleExpr();
     te.visit(new PeriodicQueryNodeVisitor());
    
     PeriodicNodeCollector collector = new PeriodicNodeCollector();
     te.visit(collector);
     Assert.assertEquals(2, collector.getPos());
     
     te.visit(new PeriodicQueryNodeRelocator());
     collector.resetCount();
     te.visit(collector);
     Assert.assertEquals(1, collector.getPos());
     
     double window = 1*60*60*1000;
     double period = .5*3600*1000;
     PeriodicQueryNode node2 = new PeriodicQueryNode((long) window, (long) period, TimeUnit.MILLISECONDS, "time", new Join());
     Assert.assertEquals(true, periodicNodesEqualIgnoreArg(node2, collector.getPeriodicQueryNode()));
     
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:32,代码来源:PeriodicQueryUtilTest.java

示例10: moveFiltersToTop

import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
/**
 *
 * This method moves the Filters of a specified {@link TupleExpr} to the top
 * of the TupleExpr.
 *
 * @param query
 *            - query whose filters will be relocated
 * @return - TupleExpr with filters relocated to top
 */
public static TupleExpr moveFiltersToTop(TupleExpr query) {

    ProjectionAndFilterGatherer fg = new ProjectionAndFilterGatherer();
    query.visit(fg);
    List<ValueExpr> filterCond = new ArrayList<>(fg.filterCond);
    Projection projection = fg.projection;

    if (filterCond.size() == 0) {
        return query;
    }

    Filter first = new Filter();
    first.setCondition(filterCond.remove(0));
    Filter current = first;
    for (ValueExpr cond : filterCond) {
        Filter filter = new Filter(null, cond);
        current.setArg(filter);
        current = filter;
    }

    TupleExpr te = projection.getArg();
    projection.setArg(first);
    current.setArg(te);

    return query;

}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:37,代码来源:TopOfQueryFilterRelocator.java

示例11: process

import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
@Override
public Double process(TupleExpr expr) {
	synchronized (this) {
		expr.visit(this);
		return cardIndex.get(expr);
	}
}
 
开发者ID:goerlitz,项目名称:rdffederator,代码行数:8,代码来源:AbstractCardinalityEstimator.java

示例12: optimize

import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
public void optimize(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings) {
  parent = null;
  tupleExpr.visit(this);
}
 
开发者ID:esarbanis,项目名称:strabon,代码行数:5,代码来源:GeneralDBVarColumnLookupOptimizer.java

示例13: optimize

import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
public void optimize(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings) {
  tupleExpr.visit(this);
}
 
开发者ID:esarbanis,项目名称:strabon,代码行数:4,代码来源:GeneralDBRegexFlagsInliner.java

示例14: getCost

import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
public Double getCost(TupleExpr expr) {
	cost = 0;
	expr.visit(this);
	return cost;
}
 
开发者ID:goerlitz,项目名称:rdffederator,代码行数:6,代码来源:AbstractCostEstimator.java

示例15: tupleContainsLeftJoins

import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
public static boolean tupleContainsLeftJoins(final TupleExpr node) {
 final LeftJoinVisitor lj = new LeftJoinVisitor();
 node.visit(lj);
    return lj.containsLeftJoin;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:6,代码来源:PCJOptimizerUtilities.java


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