org.modeshape.jcr.api.query.Query.explain()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中org.modeshape.jcr.api.query.Query.explain方法的一些代码示例,展示了Query.explain的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.explain方法的具体详情如下:
包路径:org.modeshape.jcr.api.query.Query
类名称:Query
方法名:explain

Query.explain介绍

[英]Generates a plan for the this query and returns a QueryResult object that contains no results (nodes or rows) but does have a query plan.

If this Query contains a variable (see javax.jcr.query.qom.BindVariableValue) which has not been bound to a value (see Query#bindValue) then this method throws an InvalidQueryException.
[中]为此查询生成一个计划,并返回一个QueryResult对象,该对象不包含任何结果(节点或行),但有一个查询计划。
如果这个Query包含一个变量(请参见javax.jcr.query.qom.BindVariableValue),该变量尚未绑定到一个值(请参见query#bindValue),那么这个方法会抛出一个InvalidQueryException

代码示例

代码示例来源:origin: com.thinkbiganalytics.kylo/kylo-metadata-modeshape

public static String explainPlain(Session session, String queryExpression) throws RepositoryException {
  Query query = session.getWorkspace().getQueryManager().createQuery(queryExpression, "JCR-SQL2");
  org.modeshape.jcr.api.query.Query msQuery = (org.modeshape.jcr.api.query.Query)query;
  // Get the query plan without executing it ...
  org.modeshape.jcr.api.query.QueryResult result = msQuery.explain();
  String plan = result.getPlan();
  return plan;
}

代码示例来源:origin: com.thinkbiganalytics.kylo/kylo-metadata-modeshape

public List<T> findWithExplainPlan(String queryExpression) {
  try {
    org.modeshape.jcr.api.query.Query query = (org.modeshape.jcr.api.query.Query) getSession().getWorkspace().getQueryManager().createQuery(queryExpression, "JCR-SQL2");
    org.modeshape.jcr.api.query.QueryResult result = query.explain();
    String plan = result.getPlan();
    log.info(plan);
    return find(queryExpression);
  } catch (RepositoryException e) {
    throw new MetadataRepositoryException("Failure while finding entity ", e);
  }
}

代码示例来源:origin: org.modeshape/modeshape-jdbc-local

@Override
public String explain( String query,
            String language ) throws RepositoryException {
  logger.trace("Explaining query: {0}", query);
  // Create the query ...
  final org.modeshape.jcr.api.query.Query jcrQuery = (org.modeshape.jcr.api.query.Query)getLocalSession().getSession().getWorkspace().getQueryManager().createQuery(query,
                                                                                   language);
  return jcrQuery.explain().getPlan();
}

代码示例来源:origin: ModeShape/modeshape

@Override
public String explain( String query,
            String language ) throws RepositoryException {
  logger.trace("Explaining query: {0}", query);
  // Create the query ...
  final org.modeshape.jcr.api.query.Query jcrQuery = (org.modeshape.jcr.api.query.Query)getLocalSession().getSession().getWorkspace().getQueryManager().createQuery(query,
                                                                                   language);
  return jcrQuery.explain().getPlan();
}

代码示例来源:origin: ModeShape/modeshape

bindExtraVariables(uriInfo, session.getValueFactory(), query);
org.modeshape.jcr.api.query.QueryResult result = query.explain();
String plan = result.getPlan();
return new RestQueryPlanResult(plan, statement, language, query.getAbstractQueryModelRepresentation());

代码示例来源:origin: ModeShape/modeshape

@FixFor( "MODE-1901" )
@Test
public void shouldExplainQueryWithoutExecutingQuery() throws RepositoryException {
  String sql = "SELECT * FROM [nt:file]";
  org.modeshape.jcr.api.query.Query query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
  org.modeshape.jcr.api.query.QueryResult result = query.explain();
  validateQuery().rowCount(0).warnings(0).onlyQueryPlan().validate(query, result);
}

相关文章

微信公众号

最新文章

更多

Query类方法