本文整理汇总了Java中org.eclipse.rdf4j.query.parser.ParsedTupleQuery类的典型用法代码示例。如果您正苦于以下问题:Java ParsedTupleQuery类的具体用法?Java ParsedTupleQuery怎么用?Java ParsedTupleQuery使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParsedTupleQuery类属于org.eclipse.rdf4j.query.parser包,在下文中一共展示了ParsedTupleQuery类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRelation
import org.eclipse.rdf4j.query.parser.ParsedTupleQuery; //导入依赖的package包/类
@Override
public SparkRDF4JSparqlRelation createRelation(SQLContext sqlContext,
scala.collection.immutable.Map<String, String> scalaParameters, StructType schema) {
Map<String, String> parameters = JavaConversions.asJavaMap(scalaParameters);
String service = Optional.ofNullable(parameters.get("service")).orElseThrow(() -> new RuntimeException(
"Spark RDF4J Sparql requires a SPARQL 'service' to be specified in the parameters"));
String query = Optional.ofNullable(parameters.get("query")).orElseThrow(() -> new RuntimeException(
"Spark RDF4J Sparql requires a 'query' to be specified in the parameters"));
try {
ParsedQuery parsedQuery = QueryParserUtil.parseQuery(QueryLanguage.SPARQL, query, null);
if(!(parsedQuery instanceof ParsedTupleQuery)) {
throw new RuntimeException("Spark RDF4J can only be used with Tuple (Select) queries right now.");
}
return new SparkRDF4JSparqlRelation(service, parsedQuery, schema, sqlContext);
} catch (MalformedQueryException e) {
throw new RuntimeException("Query was not valid SPARQL", e);
}
}
示例2: buildSelectSPARQLQuery
import org.eclipse.rdf4j.query.parser.ParsedTupleQuery; //导入依赖的package包/类
private static String buildSelectSPARQLQuery(TupleExpr expr, Collection<String> projection)
throws Exception
{
TupleExpr body = expr.clone();
if (projection != null) {
Projection proj = new Projection();
ProjectionElemList elemList = new ProjectionElemList();
for (String var : projection)
elemList.addElement(new ProjectionElem(var));
proj.setProjectionElemList(elemList);
proj.setArg(body);
body = proj;
}
ParsedTupleQuery query = new ParsedTupleQuery(body);
String queryString = new SPARQLQueryRenderer().render(new ParsedTupleQuery(expr));
queryString = updateFunctionCallsSELECT(expr, queryString, computeVars(expr));
return queryString;
}
示例3: createSparqlQueryValidator
import org.eclipse.rdf4j.query.parser.ParsedTupleQuery; //导入依赖的package包/类
private Validator createSparqlQueryValidator() {
Validator validator = new Validator() {
private static final long serialVersionUID = 1L;
@Override
public void validate(Object value) throws InvalidValueException {
final String valueStr = (String) value;
if (value == null || valueStr.isEmpty()) {
throw new InvalidValueException(ctx.tr("sparqlvalidator.emptyQuery"));
}
try {
ParsedQuery parsedQuery = QueryParserUtil.parseQuery(QueryLanguage.SPARQL, valueStr, null);
if (!(parsedQuery instanceof ParsedBooleanQuery)&&!(parsedQuery instanceof ParsedTupleQuery)) {
throw new InvalidValueException(ctx.tr("error.unsupported.query.type"));
}
} catch (MalformedQueryException ex) {
throw new InvalidValueException(ctx.tr("sparqlvalidator.invalidQuery") + " " + ex.getMessage());
}
}
};
return validator;
}
示例4: tupleExpr2Str
import org.eclipse.rdf4j.query.parser.ParsedTupleQuery; //导入依赖的package包/类
public static String tupleExpr2Str(TupleExpr expr) {
try {
return new SPARQLQueryRenderer().render(new ParsedTupleQuery(expr)).substring(15).replace('\n',' ');
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
示例5: SemagrowSailTupleQuery
import org.eclipse.rdf4j.query.parser.ParsedTupleQuery; //导入依赖的package包/类
public SemagrowSailTupleQuery( ParsedTupleQuery query, String queryString, SailRepositoryConnection connection )
{
super(query, connection );
this.queryString = queryString;
}