本文整理了Java中org.apache.jena.query.Query.getProjectVars
方法的一些代码示例,展示了Query.getProjectVars
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getProjectVars
方法的具体详情如下:
包路径:org.apache.jena.query.Query
类名称:Query
方法名:getProjectVars
[英]Return a list of the variables requested (SELECT)
[中]返回所请求变量的列表(选择)
代码示例来源:origin: org.apache.jena/jena-querybuilder
/**
* Get the list of variables from the query.
*
* @return The list of variables in the query.
*/
public List<Var> getVars() {
return query.getProjectVars();
}
代码示例来源:origin: apache/jena
/**
* Get the list of variables from the query.
*
* @return The list of variables in the query.
*/
public List<Var> getVars() {
return query.getProjectVars();
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public static Var extractProjectVar(Query query) {
List<Var> vars = query.getProjectVars();
if(vars.size() != 1) {
throw new RuntimeException("Exactly 1 var expected");
}
Var result = vars.get(0);
return result;
}
代码示例来源:origin: SmartDataAnalytics/DL-Learner
/**
* Returns triple patterns for each projection variable v such that v is in subject position.
* @param query The SPARQL query.
* @return
*/
public Map<Var,Set<Triple>> extractIncomingTriplePatternsForProjectionVars(Query query){
Map<Var,Set<Triple>> var2TriplePatterns = new HashMap<>();
for (Var var : query.getProjectVars()) {
Set<Triple> triplePatterns = new HashSet<>(extractIncomingTriplePatterns(query, var));
var2TriplePatterns.put(var, triplePatterns);
}
return var2TriplePatterns;
}
代码示例来源:origin: SmartDataAnalytics/DL-Learner
/**
* Returns triple patterns for each projection variable v such that v is in subject position.
* @param query The SPARQL query.
* @return
*/
public Map<Var,Set<Triple>> extractOutgoingTriplePatternsForProjectionVars(Query query){
Map<Var,Set<Triple>> var2TriplePatterns = new HashMap<>();
for (Var var : query.getProjectVars()) {
Set<Triple> triplePatterns = new HashSet<>(extractOutgoingTriplePatterns(query, var));
var2TriplePatterns.put(var, triplePatterns);
}
return var2TriplePatterns;
}
代码示例来源:origin: SmartDataAnalytics/DL-Learner
/**
* Returns triple patterns for each projection variable v such that v is in object position.
* @param query The SPARQL query.
* @return
*/
public Map<Var,Set<Triple>> extractIngoingTriplePatternsForProjectionVars(Query query){
Map<Var,Set<Triple>> var2TriplePatterns = new HashMap<>();
for (Var var : query.getProjectVars()) {
Set<Triple> triplePatterns = new HashSet<>(extractIncomingTriplePatterns(query, var));
var2TriplePatterns.put(var, triplePatterns);
}
return var2TriplePatterns;
}
代码示例来源:origin: org.aksw.jena-sparql-api/jena-sparql-api-cache
@Override
public QueryExecution createQueryExecution(Op indexPattern, Query query) {
ProjectedQuadFilterPattern pqfp = AlgebraUtils.transform(indexPattern);
if(pqfp == null) {
throw new RuntimeException("Query is not indexable: " + query);
}
Set<Var> indexVars = new HashSet<>(query.getProjectVars());
QueryExecution result = new QueryExecutionViewCacheFragment(query, pqfp, decoratee, conceptMap, indexVars, indexResultSetSizeThreshold);
return result;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
@Override
public QueryExecution createQueryExecution(Op indexPattern, Query query) {
ProjectedQuadFilterPattern pqfp = AlgebraUtils.transform(indexPattern);
if(pqfp == null) {
throw new RuntimeException("Query is not indexable: " + query);
}
Set<Var> indexVars = new HashSet<>(query.getProjectVars());
QueryExecution result = new QueryExecutionViewCacheFragment(query, pqfp, decoratee, conceptMap, indexVars, indexResultSetSizeThreshold);
return result;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public static boolean isDistinctConceptVar(Query query, Var conceptVar) {
boolean isDistinct = query.isDistinct();
Collection<Var> projectVars = query.getProjectVars();
boolean hasSingleVar = !query.isQueryResultStar() && projectVars != null && projectVars.size() == 1;
boolean result = isDistinct && hasSingleVar && projectVars.iterator().next().equals(conceptVar);
return result;
}
代码示例来源:origin: SmartDataAnalytics/Sparqlify
private ResultSet createEmptyResultSet() {
List<String> vars = new ArrayList<String>();
for(Var v : query.getProjectVars()) {
vars.add(v.getName());
}
return org.apache.jena.query.ResultSetFactory.create(new QueryIterNullIterator(null), vars);
}
代码示例来源:origin: SmartDataAnalytics/DL-Learner
public static CBDStructureTree getOptimalCBDStructure(Query query) {
CBDStructureTree tree = new CBDStructureTree("root");
Var var = query.getProjectVars().get(0);
getOptimalCBDStructure(query, tree, var.asNode(), null, "");
return tree;
}
代码示例来源:origin: dice-group/NLIWOD
public static void main(final String[] args) throws Exception {
Query q = QueryFactory
.create("prefix dbp: <http://dbpedia.org/resource/> " + "prefix dbp2: <http://dbpedia.org/ontology/> " + "select ?thumbnail where { dbp:total !dbp2:thumbnail ?thumbnail }");
TriplePatternExtractor triplePatternExtractor = new TriplePatternExtractor();
triplePatternExtractor.extractIngoingTriplePatterns(q, q.getProjectVars().get(0));
}
}
代码示例来源:origin: dice-group/NLIWOD
public Set<Triple> extractTriplePattern(final Query query, final boolean ignoreOptionals) {
triplePattern = new HashSet<>();
optionalTriplePattern = new HashSet<>();
query.getQueryPattern().visit(this);
// postprocessing: triplepattern in OPTIONAL clause
if (!ignoreOptionals && query.isSelectType()) {
for (Triple t : optionalTriplePattern) {
if (!ListUtils.intersection(new ArrayList<>(VarUtils.getVars(t)), query.getProjectVars()).isEmpty()) {
triplePattern.add(t);
}
}
}
return triplePattern;
}
代码示例来源:origin: org.aksw.rdfunit/rdfunit-model
private Optional<ResultAnnotation> getPathAnnotation() {
if (query.getResultVars().contains("path")) {
List<Var> vars = query.getProjectVars();
VarExprList vel = query.getProject();
return Optional.of(
createVariableAnnotation(SHACL.resultPath, "path"));
} else {
if (shape.getPath().isPresent()) {
return Optional.of(
createValueAnnotation(SHACL.resultPath, shape.getPath().get().getPathAsRdf()));
}
}
return Optional.empty();
}
代码示例来源:origin: apache/jena
@Override
public void build() {
if (query.getProject().getVars().isEmpty()) {
query.setQueryResultStar(true);
}
aggHandler.build();
// handle the SELECT * case
query.getProjectVars();
}
}
代码示例来源:origin: org.apache.jena/jena-querybuilder
@Override
public void build() {
if (query.getProject().getVars().isEmpty()) {
query.setQueryResultStar(true);
}
aggHandler.build();
// handle the SELECT * case
query.getProjectVars();
}
}
代码示例来源:origin: SmartDataAnalytics/DL-Learner
public static List<String> getResult(QueryExecutionFactory qef, Query query) throws Exception{
return getResult(qef, query, query.getProjectVars().get(0));
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
default Query asQuery() {
Element e = getElement();
List<Var> vs = getVars();
Query result = new Query();
result.setQuerySelectType();
result.setQueryPattern(getElement());
result.setDistinct(true);
for(Var v : vs) {
result.getProjectVars().add(v);
}
return result;
}
代码示例来源:origin: SmartDataAnalytics/DL-Learner
/**
* @return whether the target projection variable is used only in object position of a triple pattern
*/
public static Predicate<Question> isObjectTarget() {
return q -> utils.extractOutgoingTriplePatterns(
QueryFactory.create(q.getQuery().getSparql()),
QueryFactory.create(q.getQuery().getSparql()).getProjectVars().get(0).asNode()
).isEmpty();
}
代码示例来源:origin: SmartDataAnalytics/DL-Learner
/**
* @return whether the target projection variable is used only in subject position of a triple pattern
*/
public static Predicate<Question> isSubjectTarget() {
return q -> utils.extractIncomingTriplePatterns(
QueryFactory.create(q.getQuery().getSparql()),
QueryFactory.create(q.getQuery().getSparql()).getProjectVars().get(0).asNode()
).isEmpty();
}
内容来源于网络,如有侵权,请联系作者删除!