本文整理汇总了Java中org.eclipse.rdf4j.query.TupleQueryResult类的典型用法代码示例。如果您正苦于以下问题:Java TupleQueryResult类的具体用法?Java TupleQueryResult怎么用?Java TupleQueryResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TupleQueryResult类属于org.eclipse.rdf4j.query包,在下文中一共展示了TupleQueryResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: mapCollection
import org.eclipse.rdf4j.query.TupleQueryResult; //导入依赖的package包/类
private Object mapCollection(TupleEntity entity, ArrayProperty schema,
ValueContext valueContext) {
Property itemSchema = schema.getItems();
if (itemSchema == null) {
throw new EntityMapperRuntimeException("Array schemas must have an 'items' property.");
}
if (!(itemSchema instanceof ObjectProperty)) {
throw new EntityMapperRuntimeException(
"Only array items of type 'object' are supported for now.");
}
TupleQueryResult result = entity.getResult();
ImmutableList.Builder<Map<String, Object>> collectionBuilder = new ImmutableList.Builder<>();
Map<String, Property> itemProperties = ((ObjectProperty) itemSchema).getProperties();
while (result.hasNext()) {
collectionBuilder.add(mapBindingSet(result.next(), itemProperties, valueContext));
}
return collectionBuilder.build();
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:25,代码来源:TupleEntityMapper.java
示例2: aroundWriteTo_MapsEntity_ForTupleEntity
import org.eclipse.rdf4j.query.TupleQueryResult; //导入依赖的package包/类
@Test
public void aroundWriteTo_MapsEntity_ForTupleEntity() throws IOException {
// Arrange
TupleEntity entity = new TupleEntity(ImmutableMap.of(), mock(TupleQueryResult.class));
Object mappedEntity = ImmutableList.of();
when(contextMock.getEntity()).thenReturn(entity);
when(contextMock.getMediaType()).thenReturn(MediaType.APPLICATION_JSON_TYPE);
when(tupleEntityMapperMock.map(entity, MediaType.APPLICATION_JSON_TYPE)).thenReturn(
mappedEntity);
// Act
entityWriterInterceptor.aroundWriteTo(contextMock);
// Assert
verify(contextMock).setEntity(entityCaptor.capture());
verify(contextMock).proceed();
assertThat(entityCaptor.getValue(), equalTo(mappedEntity));
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:19,代码来源:EntityWriterInterceptorTest.java
示例3: apply_ReturnsOkResponseWithEntityObject_ForTupleResult
import org.eclipse.rdf4j.query.TupleQueryResult; //导入依赖的package包/类
@Test
public void apply_ReturnsOkResponseWithEntityObject_ForTupleResult() {
// Arrange
UriInfo uriInfo = mock(UriInfo.class);
when(uriInfo.getPath()).thenReturn("/");
when(containerRequestContextMock.getUriInfo()).thenReturn(uriInfo);
TupleQueryResult result = mock(TupleQueryResult.class);
final Map<String, Property> schemaMap = ImmutableMap.of();
when(informationProductMock.getResult(ImmutableMap.of())).thenReturn(result);
when(informationProductMock.getResultType()).thenReturn(ResultType.TUPLE);
// Act
Response response = getRequestHandler.apply(containerRequestContextMock);
// Assert
assertThat(response.getStatus(), equalTo(Status.OK.getStatusCode()));
assertThat(response.getEntity(), instanceOf(TupleEntity.class));
assertThat(((TupleEntity) response.getEntity()).getResult(), equalTo(result));
assertThat(((TupleEntity) response.getEntity()).getSchemaMap(), equalTo(schemaMap));
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:21,代码来源:GetRequestHandlerTest.java
示例4: serialize
import org.eclipse.rdf4j.query.TupleQueryResult; //导入依赖的package包/类
@Override
public void serialize(@NonNull TupleQueryResult tupleQueryResult,
@NonNull JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
throws IOException {
writeStart(jsonGenerator);
while (tupleQueryResult.hasNext()) {
writeStartItem(jsonGenerator);
BindingSet bindingSet = tupleQueryResult.next();
for (Binding binding : bindingSet) {
jsonGenerator.writeObjectField(binding.getName(), serializeValue(binding.getValue()));
}
writeEndItem(jsonGenerator);
}
writeEnd(jsonGenerator);
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:21,代码来源:AbstractTupleQueryResultSerializer.java
示例5: apply
import org.eclipse.rdf4j.query.TupleQueryResult; //导入依赖的package包/类
@Override
public Response apply(ContainerRequestContext containerRequestContext) {
String path = containerRequestContext.getUriInfo().getPath();
LOG.debug("Handling GET request for path {}", path);
InformationProduct informationProduct = representation.getInformationProduct();
Map<String, String> parameterValues =
representationRequestParameterMapper.map(informationProduct, containerRequestContext);
representation.getParameterMappers().forEach(
parameterMapper -> parameterValues.putAll(parameterMapper.map(containerRequestContext)));
Object result = informationProduct.getResult(parameterValues);
if (ResultType.GRAPH.equals(informationProduct.getResultType())) {
return Response.ok(new GraphEntity((GraphQueryResult) result, representation)).build();
}
if (ResultType.TUPLE.equals(informationProduct.getResultType())) {
return Response.ok(new TupleEntity((TupleQueryResult) result, representation)).build();
}
throw new ConfigurationException(
String.format("Result type %s not supported for information product %s",
informationProduct.getResultType(), informationProduct.getIdentifier()));
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:27,代码来源:RepresentationRequestHandler.java
示例6: apply_ReturnQueryRepresentation_WhenTupleQueryResult
import org.eclipse.rdf4j.query.TupleQueryResult; //导入依赖的package包/类
@Test
public void apply_ReturnQueryRepresentation_WhenTupleQueryResult() {
// Arrange
when(representation.getInformationProduct()).thenReturn(informationProduct);
TupleQueryResult queryResult = mock(TupleQueryResult.class);
when(informationProduct.getResult(ImmutableMap.of())).thenReturn(queryResult);
when(informationProduct.getResultType()).thenReturn(ResultType.TUPLE);
UriInfo uriInfo = mock(UriInfo.class);
when(containerRequestContext.getUriInfo()).thenReturn(uriInfo);
when(uriInfo.getPath()).thenReturn("/");
// Act
Response response = getRequestHandler.apply(containerRequestContext);
// Assert
assertThat(response.getStatus(), equalTo(200));
assertThat(response.getEntity(), instanceOf(TupleEntity.class));
TupleEntity entity = (TupleEntity) response.getEntity();
assertThat(entity.getQueryResult(), equalTo(queryResult));
assertThat(entity.getRepresentation(), equalTo(representation));
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:23,代码来源:RepresentationRequestHandlerTest.java
示例7: size
import org.eclipse.rdf4j.query.TupleQueryResult; //导入依赖的package包/类
/**
* Returns number of triples in the entire triple store.
*
* @return long
* @throws RepositoryException
*/
@Override
public long size() throws RepositoryException{
try {
MarkLogicTupleQuery tupleQuery = prepareTupleQuery(COUNT_EVERYTHING);
tupleQuery.setIncludeInferred(false);
tupleQuery.setRulesets((SPARQLRuleset)null);
tupleQuery.setConstrainingQueryDefinition((QueryDefinition)null);
TupleQueryResult qRes = tupleQuery.evaluate();
// just one answer
BindingSet result = qRes.next();
qRes.close();
return ((Literal) result.getBinding("ct").getValue()).longValue();
} catch (QueryEvaluationException | MalformedQueryException e) {
throw new RepositoryException(e);
}
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:23,代码来源:MarkLogicRepositoryConnection.java
示例8: testSPARQLQueryCloseWait
import org.eclipse.rdf4j.query.TupleQueryResult; //导入依赖的package包/类
@Test
public void testSPARQLQueryCloseWait()
throws Exception {
try{
String queryString = "select ?s ?p ?o { ?s ?p ?o } limit 100";
MarkLogicTupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
for(int i=0; i<101; i++){
TupleQueryResult results = tupleQuery.evaluate(3,1);
// must close query result
results.close();
}
}
catch(Exception ex)
{
throw ex;
}
finally {
conn.close();
Thread.sleep(1000);
}
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:25,代码来源:MarkLogicTupleQueryTest.java
示例9: testSPARQLQueryWithRuleset
import org.eclipse.rdf4j.query.TupleQueryResult; //导入依赖的package包/类
@Test
public void testSPARQLQueryWithRuleset()
throws Exception {
String queryString = "select ?s ?p ?o { ?s ?p ?o } limit 100 ";
MarkLogicTupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
tupleQuery.setRulesets(SPARQLRuleset.RDFS_FULL);
TupleQueryResult results = tupleQuery.evaluate();
Assert.assertEquals(results.getBindingNames().get(0), "s");
Assert.assertEquals(results.getBindingNames().get(1), "p");
Assert.assertEquals(results.getBindingNames().get(2), "o");
BindingSet bindingSet = results.next();
Value sV = bindingSet.getValue("s");
Value pV = bindingSet.getValue("p");
Value oV = bindingSet.getValue("o");
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#AttaliaGeodata", sV.stringValue());
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#altitude", pV.stringValue());
Assert.assertEquals("0", oV.stringValue());
results.close();
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:25,代码来源:MarkLogicTupleQueryTest.java
示例10: testSPARQLQueryWithMultipleRulesets
import org.eclipse.rdf4j.query.TupleQueryResult; //导入依赖的package包/类
@Test
public void testSPARQLQueryWithMultipleRulesets()
throws Exception {
String queryString = "select ?s ?p ?o { ?s ?p ?o } limit 100 ";
MarkLogicTupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
tupleQuery.setRulesets(SPARQLRuleset.RDFS_FULL,SPARQLRuleset.DOMAIN);
TupleQueryResult results = tupleQuery.evaluate();
Assert.assertEquals(results.getBindingNames().get(0), "s");
Assert.assertEquals(results.getBindingNames().get(1), "p");
Assert.assertEquals(results.getBindingNames().get(2), "o");
BindingSet bindingSet = results.next();
Value sV = bindingSet.getValue("s");
Value pV = bindingSet.getValue("p");
Value oV = bindingSet.getValue("o");
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#AttaliaGeodata", sV.stringValue());
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#altitude", pV.stringValue());
Assert.assertEquals("0", oV.stringValue());
results.close();
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:25,代码来源:MarkLogicTupleQueryTest.java
示例11: select
import org.eclipse.rdf4j.query.TupleQueryResult; //导入依赖的package包/类
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> select(Service service, Set<String> projectionVars, BindingSet bindings, String baseUri) throws QueryEvaluationException {
RepositoryConnection conn = endpoint.getConn();
try {
TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, service.getSelectQueryString(projectionVars), baseUri);
Iterator<Binding> bIter = bindings.iterator();
while (bIter.hasNext()) {
Binding b = bIter.next();
if (service.getServiceVars().contains(b.getName()))
query.setBinding(b.getName(), b.getValue());
}
TupleQueryResult qRes = query.evaluate();
return new InsertBindingsIteration(qRes, bindings);
} catch(Throwable e) {
throw new QueryEvaluationException(e);
} finally {
conn.close();
}
}
开发者ID:dice-group,项目名称:CostFed,代码行数:20,代码来源:SAILFederatedService.java
示例12: FedSumClassLookup
import org.eclipse.rdf4j.query.TupleQueryResult; //导入依赖的package包/类
/**
* Index lookup for rdf:type and its its corresponding values
* @param p Predicate i.e. rdf:type
* @param o Predicate value
* @param stmt Statement Pattern
* @throws RepositoryException
* @throws MalformedQueryException
* @throws QueryEvaluationException
*/
public void FedSumClassLookup(StatementPattern stmt, String p, String o) throws RepositoryException, MalformedQueryException, QueryEvaluationException {
String queryString = "Prefix ds:<http://aksw.org/fedsum/> "
+ "SELECT Distinct ?url "
+ " WHERE {?s ds:url ?url. "
+ " ?s ds:capability ?cap. "
+ " ?cap ds:predicate <" + p + ">."
+ "?cap ds:objAuthority <" + o + "> }" ;
TupleQuery tupleQuery = FedSumConfig.con.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
TupleQueryResult result = tupleQuery.evaluate();
while(result.hasNext())
{
String endpoint = result.next().getValue("url").stringValue();
String id = "sparql_" + endpoint.replace("http://", "").replace("/", "_");
addSource(stmt, new StatementSource(id, StatementSourceType.REMOTE));
}
}
开发者ID:dice-group,项目名称:CostFed,代码行数:27,代码来源:FedSumSourceSelection.java
示例13: FedSumD_getMatchingSbjAuthorities
import org.eclipse.rdf4j.query.TupleQueryResult; //导入依赖的package包/类
/**
* Get matching Subject authorities from a specific source for a triple pattern
* @param stmt Triple pattern
* @param src Capable source
* @return List of authorities
* @throws RepositoryException
* @throws MalformedQueryException
* @throws QueryEvaluationException
*/
public ArrayList<String> FedSumD_getMatchingSbjAuthorities(StatementPattern stmt, StatementSource src) throws RepositoryException, MalformedQueryException, QueryEvaluationException
{
String endPointUrl = "http://"+src.getEndpointID().replace("sparql_", "");
endPointUrl = endPointUrl.replace("_", "/");
ArrayList<String> sbjAuthorities = new ArrayList<String>();
String queryString = getFedSumSbjAuthLookupQuery(stmt, endPointUrl) ;
TupleQuery tupleQuery = FedSumConfig.con.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
TupleQueryResult result = tupleQuery.evaluate();
while(result.hasNext())
sbjAuthorities.add(result.next().getValue("sbjAuth").stringValue());
return sbjAuthorities;
}
开发者ID:dice-group,项目名称:CostFed,代码行数:26,代码来源:FedSumSourceSelection.java
示例14: executeQuery
import org.eclipse.rdf4j.query.TupleQueryResult; //导入依赖的package包/类
/**
* Execute query and return the number of results
* @param query SPARQL query
* @param bgpGroups BGPs
* @param stmtToSources Triple Pattern to sources
* @param repo repository
* @return Number of results
* @throws RepositoryException
* @throws MalformedQueryException
* @throws QueryEvaluationException
*/
public static int executeQuery(String query, HashMap<Integer, List<StatementPattern>> bgpGroups, Map<StatementPattern, List<StatementSource>> stmtToSources, SPARQLRepository repo) throws RepositoryException, MalformedQueryException, QueryEvaluationException {
String newQuery = QueryRewriting.doQueryRewriting(query,bgpGroups,stmtToSources);
System.out.println(newQuery);
TupleQuery tupleQuery = repo.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, newQuery);
int count = 0;
TupleQueryResult result = tupleQuery.evaluate();
while(result.hasNext())
{
//System.out.println(result.next());
result.next();
count++;
}
return count;
}
开发者ID:dice-group,项目名称:CostFed,代码行数:27,代码来源:ExecuteTBSSQuery.java
示例15: executeQuery
import org.eclipse.rdf4j.query.TupleQueryResult; //导入依赖的package包/类
/**
* Execute query and return the number of results
* @param query SPARQL query
* @param bgpGroups BGPs
* @param stmtToSources Triple Pattern to sources
* @param repo repository
* @return Number of results
* @throws RepositoryException
* @throws MalformedQueryException
* @throws QueryEvaluationException
*/
public static int executeQuery(String query, HashMap<Integer, List<StatementPattern>> bgpGroups, Map<StatementPattern, List<StatementSource>> stmtToSources, SPARQLRepository repo) throws RepositoryException, MalformedQueryException, QueryEvaluationException {
String newQuery = QueryRewriting.doQueryRewriting(query,bgpGroups,stmtToSources);
// System.out.println(newQuery);
TupleQuery tupleQuery = repo.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, newQuery);
int count = 0;
TupleQueryResult result = tupleQuery.evaluate();
while(result.hasNext())
{
//System.out.println(result.next());
result.next();
count++;
}
return count;
}
开发者ID:dice-group,项目名称:CostFed,代码行数:27,代码来源:ExecuteHibiscusQuery.java
示例16: buildPrefixes
import org.eclipse.rdf4j.query.TupleQueryResult; //导入依赖的package包/类
void buildPrefixes(RepositoryConnection conn, String query, SortedMap<KeyTuple, ValueTuple> prefixMap, boolean isSbjPrefix) {
TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query);
TupleQueryResult result = tupleQuery.evaluate();
while (result.hasNext())
{
BindingSet row = result.next();
String endpoint = row.getValue("url").stringValue();
String predicate = row.getValue("p").stringValue();
String prefix = row.getValue("prefix").stringValue();
long unique = Long.parseLong(row.getValue("unique").stringValue());
long card = Long.parseLong(row.getValue("card").stringValue());
//log.info(predicate + " : " + prefix + " : " + card);
String eid = getEID(endpoint);
KeyTuple kt = new KeyTuple(predicate, prefix);
updateMap(prefixMap, kt, eid);
KeyTuple kt0 = new KeyTuple(null, prefix);
updateMap(prefixMap, kt0, eid);
updateCapabilityPrefix(eid, predicate, prefix, unique, card, isSbjPrefix);
}
result.close();
}
开发者ID:dice-group,项目名称:CostFed,代码行数:26,代码来源:CostFedSummary.java
示例17: getObj
import org.eclipse.rdf4j.query.TupleQueryResult; //导入依赖的package包/类
/**
* Get total number of triple for a predicate
* @param pred Predicate
* @param m model
* @return triples
* @throws RepositoryException
* @throws MalformedQueryException
* @throws QueryEvaluationException
*/
public static double getObj(String pred, String endpoint) throws RepositoryException, MalformedQueryException, QueryEvaluationException {
String strQuery = "SELECT (COUNT(DISTINCT ?o) AS ?objs) " + //
"WHERE " +
"{" +
"?s <"+pred+"> ?o " +
"} " ;
SPARQLRepository repo = createSPARQLRepository(endpoint);
RepositoryConnection conn = repo.getConnection();
try {
TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, strQuery);
TupleQueryResult rs = query.evaluate();
return Long.parseLong(rs.next().getValue("objs").stringValue());
} finally {
conn.close();
}
}
开发者ID:dice-group,项目名称:CostFed,代码行数:26,代码来源:TBSSSummariesGenerator.java
示例18: getSubjectsCount
import org.eclipse.rdf4j.query.TupleQueryResult; //导入依赖的package包/类
/**
* Get total number of distinct subjects of a dataset
* @return count
*/
public static Long getSubjectsCount(String endpoint) {
String strQuery = "SELECT (COUNT(DISTINCT ?s) AS ?sbjts) " + //
"WHERE " +
"{" +
"?s ?p ?o " +
"} " ;
SPARQLRepository repo = createSPARQLRepository(endpoint);
RepositoryConnection conn = repo.getConnection();
try {
TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, strQuery);
TupleQueryResult rs = query.evaluate();
return Long.parseLong(rs.next().getValue("sbjts").stringValue());
} finally {
conn.close();
}
}
开发者ID:dice-group,项目名称:CostFed,代码行数:21,代码来源:TBSSSummariesGenerator.java
示例19: getTripleCount
import org.eclipse.rdf4j.query.TupleQueryResult; //导入依赖的package包/类
/**
* Get total number of triple for a predicate
* @param pred Predicate
* @param m model
* @return triples
*/
public static Long getTripleCount(String pred, String endpoint) {
String strQuery = "SELECT (COUNT(*) AS ?triples) " + //
"WHERE " +
"{" +
"?s <"+pred+"> ?o " +
"} " ;
SPARQLRepository repo = createSPARQLRepository(endpoint);
RepositoryConnection conn = repo.getConnection();
try {
TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, strQuery);
TupleQueryResult rs = query.evaluate();
String v = rs.next().getValue("triples").stringValue();
rs.close();
return Long.parseLong(v);
} finally {
conn.close();
}
}
开发者ID:dice-group,项目名称:CostFed,代码行数:25,代码来源:TBSSSummariesGenerator.java
示例20: getDistinctSubjectCount
import org.eclipse.rdf4j.query.TupleQueryResult; //导入依赖的package包/类
public static Long getDistinctSubjectCount(String endpoint) {
String strQuery = "SELECT (COUNT(distinct ?s) AS ?triples) " + //
"WHERE " +
"{" +
"?s ?p ?o " +
"} " ;
SPARQLRepository repo = createSPARQLRepository(endpoint);
RepositoryConnection conn = repo.getConnection();
try {
TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, strQuery);
TupleQueryResult rs = query.evaluate();
String v = rs.next().getValue("triples").stringValue();
rs.close();
return Long.parseLong(v);
} finally {
conn.close();
}
}
开发者ID:dice-group,项目名称:CostFed,代码行数:19,代码来源:TBSSSummariesGenerator.java
注:本文中的org.eclipse.rdf4j.query.TupleQueryResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论