本文整理汇总了Java中org.openrdf.query.parser.ParsedTupleQuery类的典型用法代码示例。如果您正苦于以下问题:Java ParsedTupleQuery类的具体用法?Java ParsedTupleQuery怎么用?Java ParsedTupleQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParsedTupleQuery类属于org.openrdf.query.parser包,在下文中一共展示了ParsedTupleQuery类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AccumuloIndexSet
import org.openrdf.query.parser.ParsedTupleQuery; //导入依赖的package包/类
/**
*
* @param accCon
* - connection to a valid Accumulo instance
* @param tablename
* - name of an existing PCJ table
* @throws MalformedQueryException
* @throws SailException
* @throws QueryEvaluationException
* @throws TableNotFoundException
* @throws AccumuloSecurityException
* @throws AccumuloException
* @throws PCJStorageException
*/
public AccumuloIndexSet(final Configuration conf, final String tablename)
throws MalformedQueryException, SailException,
QueryEvaluationException, TableNotFoundException, AccumuloException, AccumuloSecurityException, PCJStorageException {
this.tablename = tablename;
this.accCon = ConfigUtils.getConnector(conf);
this.auths = getAuthorizations(conf);
PcjMetadata meta = pcj.getPcjMetadata(accCon, tablename);
final SPARQLParser sp = new SPARQLParser();
final ParsedTupleQuery pq = (ParsedTupleQuery) sp.parseQuery(meta.getSparql(), null);
setProjectionExpr((Projection) pq.getTupleExpr());
final Set<VariableOrder> orders = meta.getVarOrders();
varOrder = Lists.newArrayList();
for (final VariableOrder var : orders) {
varOrder.add(var.toString());
}
setLocalityGroups(tablename, accCon, varOrder);
this.setSupportedVariableOrderMap(varOrder);
}
示例2: MongoPcjQueryNode
import org.openrdf.query.parser.ParsedTupleQuery; //导入依赖的package包/类
/**
* Creates a new {@link MongoPcjQueryNode}.
*
* @param sparql - sparql query whose results will be stored in PCJ document. (not empty of null)
* @param pcjId - name of an existing PCJ. (not empty or null)
* @param pcjDocs - {@link MongoPcjDocuments} used to maintain PCJs in mongo. (not null)
*
* @throws MalformedQueryException - The SPARQL query needs to contain a projection.
*/
public MongoPcjQueryNode(final String sparql, final String pcjId, final MongoPcjDocuments pcjDocs) throws MalformedQueryException {
checkArgument(!Strings.isNullOrEmpty(sparql));
checkArgument(!Strings.isNullOrEmpty(pcjId));
this.pcjDocs = checkNotNull(pcjDocs);
this.pcjId = pcjId;
final SPARQLParser sp = new SPARQLParser();
final ParsedTupleQuery pq = (ParsedTupleQuery) sp.parseQuery(sparql, null);
final TupleExpr te = pq.getTupleExpr();
Preconditions.checkArgument(PCJOptimizerUtilities.isPCJValid(te), "TupleExpr is an invalid PCJ.");
final Optional<Projection> projection = new ParsedQueryUtil().findProjection(pq);
if (!projection.isPresent()) {
throw new MalformedQueryException("SPARQL query '" + sparql + "' does not contain a Projection.");
}
setProjectionExpr(projection.get());
}
示例3: getQueryTask
import org.openrdf.query.parser.ParsedTupleQuery; //导入依赖的package包/类
public QueryTask getQueryTask(QueryDefinition query,
WriterConfig config, OutputStream out)
throws MalformedQueryException, RepositoryException {
QueryParser parser = new SPARQLParserFactory().getParser();
ParsedQuery parsedQuery = parser.parseQuery(query.getQuery(),
config.getBaseUri());
RepositoryConnection conn = cf.getConnection();
try {
if (parsedQuery instanceof ParsedTupleQuery) {
return new TupleQueryTask(conn, query, config, out);
} else if (parsedQuery instanceof ParsedBooleanQuery) {
return new AskQueryTask(conn, query, config, out);
} else if (parsedQuery instanceof ParsedGraphQuery) {
return new GraphQueryTask(conn, query, config, out);
}
} finally {
// conn.close();
}
throw new MalformedQueryException("Unknown query type: "
+ ParsedQuery.class.getName());
}
示例4: prepareQuery
import org.openrdf.query.parser.ParsedTupleQuery; //导入依赖的package包/类
@Override
public Query prepareQuery(QueryLanguage ql, String query, String baseURI)
throws RepositoryException, MalformedQueryException
{
validateQueryLanguage(ql);
ParsedQuery parsedQuery = QueryParserUtil.parseQuery(QueryLanguage.SPARQL, query, baseURI);
if (parsedQuery instanceof ParsedTupleQuery) {
return prepareTupleQuery(ql, query, baseURI);
}
else if (parsedQuery instanceof ParsedBooleanQuery) {
return prepareBooleanQuery(ql, query, baseURI);
}
else if (parsedQuery instanceof ParsedGraphQuery) {
return prepareGraphQuery(ql, query, baseURI);
}
throw new MalformedQueryException("Unrecognized query type:\n" + query); //$NON-NLS-1$
}
示例5: getExprQuery
import org.openrdf.query.parser.ParsedTupleQuery; //导入依赖的package包/类
/**
* Creates a new query based on a tuple expression and original query. The
* new query will have the same type null
* ({@link org.openrdf.query.TupleQuery},
* {@link org.openrdf.query.GraphQuery} or
* {@link org.openrdf.query.BooleanQuery}) as the given original query.
*
* @param orig the original query
* @param expr the expression used for the new query
* @return new query based on expression
*/
protected Query getExprQuery(ParsedQuery orig, TupleExpr expr) {
if (orig instanceof ParsedTupleQuery) {
return new SailTupleExprQuery(
new ParsedTupleQuery(expr), conn);
} else if (orig instanceof ParsedGraphQuery) {
return new SailGraphExprQuery(
new ParsedGraphQuery(expr), conn);
} else {
return new SailBooleanExprQuery(
new ParsedBooleanQuery(expr), conn);
}
}
示例6: serialize
import org.openrdf.query.parser.ParsedTupleQuery; //导入依赖的package包/类
/**
* Converts a {@link Filter} to a SPARQL query containing only the SPARQL representation
* of the Filter along with a Select clause that return all variables. The argument of the
* Filter is replaced by a {@link SingletonSet} so that the body of the SPARQL query consists of only a
* single Filter clause.
* @param filter - Filter to be serialized
* @return - SPARQL String containing a single Filter clause that represents the serialized Filter
* @throws FilterParseException
*/
public static String serialize(Filter filter) throws FilterParseException {
Filter clone = filter.clone();
clone.setArg(new SingletonSet());
try {
return removeAngularBracketsFromNonUriFunctions(renderer.render(new ParsedTupleQuery(clone)));
} catch (Exception e) {
throw new FilterParseException("Unable to parse Filter.", e);
}
}
示例7: getQueryType
import org.openrdf.query.parser.ParsedTupleQuery; //导入依赖的package包/类
public QueryType getQueryType(ParsedQuery parsedQuery) {
if (parsedQuery instanceof ParsedTupleQuery) {
return QueryType.SELECT;
} else if (parsedQuery instanceof ParsedBooleanQuery) {
return QueryType.ASK;
} else if (parsedQuery instanceof ParsedGraphQuery) {
return QueryType.CONSTRUCT;
} else {
return null;
}
}
示例8: SailTupleExprQuery
import org.openrdf.query.parser.ParsedTupleQuery; //导入依赖的package包/类
public SailTupleExprQuery(ParsedTupleQuery tupleQuery, SailRepositoryConnection sailConnection) {
super(tupleQuery, sailConnection);
}
示例9: isTupleQuery
import org.openrdf.query.parser.ParsedTupleQuery; //导入依赖的package包/类
public boolean isTupleQuery() {
return query instanceof ParsedTupleQuery;
}