org.apache.jena.query.ResultSet.getResultVars()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(150)

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

ResultSet.getResultVars介绍

[英]Get the variable names for the projection. Not all query solutions from a result have every variable defined.
[中]获取投影的变量名。并非结果中的所有查询解决方案都定义了每个变量。

代码示例

代码示例来源:origin: com.github.galigator.openllet/openllet-jena

/**
 * {@inheritDoc}
 */
@Override
public List<String> getResultVars()
{
  return _results.getResultVars();
}

代码示例来源:origin: apache/jena

@Override
public List<String> getResultVars() {
  return this.results.getResultVars();
}

代码示例来源:origin: Galigator/openllet

/**
 * {@inheritDoc}
 */
@Override
public List<String> getResultVars()
{
  return _results.getResultVars();
}

代码示例来源:origin: vivo-project/Vitro

/**
 * Helper method to allow an implementation to get the var names from the resultset
 *
 * @return list of result set var names
 */
final protected List<String> getResultVars() {
  return resultSet.getResultVars();
}

代码示例来源:origin: Galigator/openllet

/**
 * {@inheritDoc}
 */
@Override
public List<String> getResultVars()
{
  return _results.getResultVars();
}

代码示例来源:origin: apache/jena

static private boolean compareHeader(ResultSet rs1, ResultSet rs2) {
  if ( rs1 == null && rs2 == null ) 
    return true ;
  if ( rs1 == null ) 
    return false ;
  if ( rs2 == null ) 
    return false ;
  Set<String> names1 = new HashSet<>(rs1.getResultVars()) ;
  Set<String> names2 = new HashSet<>(rs2.getResultVars()) ;
  return names1.equals(names2) ;
}

代码示例来源:origin: apache/jena

@Override
public List<String> getResultVars() {
  check() ;
  return other.getResultVars() ;
}

代码示例来源:origin: apache/jena

@Override
public List<String> getResultVars() {
  return get().getResultVars() ;
}

代码示例来源:origin: Galigator/openllet

public SortedResultSet(final ResultSet results, final List<SortCondition> sortConditions)
{
  resultVars = results.getResultVars();
  sortedRows = new ArrayList<>();
  while (results.hasNext())
    sortedRows.add(results.nextBinding());
  final BindingComparator cmp = new BindingComparator(sortConditions);
  Collections.sort(sortedRows, cmp);
  iterator = sortedRows.iterator();
  row = 0;
}

代码示例来源:origin: com.github.galigator.openllet/openllet-jena

public SortedResultSet(final ResultSet results, final List<SortCondition> sortConditions)
{
  resultVars = results.getResultVars();
  sortedRows = new ArrayList<>();
  while (results.hasNext())
    sortedRows.add(results.nextBinding());
  final BindingComparator cmp = new BindingComparator(sortConditions);
  Collections.sort(sortedRows, cmp);
  iterator = sortedRows.iterator();
  row = 0;
}

代码示例来源:origin: Galigator/openllet

public SortedResultSet(final ResultSet results, final List<SortCondition> sortConditions)
{
  resultVars = results.getResultVars();
  sortedRows = new ArrayList<>();
  while (results.hasNext())
    sortedRows.add(results.nextBinding());
  final BindingComparator cmp = new BindingComparator(sortConditions);
  Collections.sort(sortedRows, cmp);
  iterator = sortedRows.iterator();
  row = 0;
}

代码示例来源:origin: SmartDataAnalytics/DL-Learner

public int getIndividualsCount(OWLClass cls){
  String query = String.format("SELECT (COUNT(?s) AS ?cnt) WHERE {?s a <%s>.}", cls.toStringID());
  ResultSet rs = executeSelectQuery(query);
  int cnt = rs.next().get(rs.getResultVars().get(0)).asLiteral().getInt();
  return cnt;
}

代码示例来源:origin: SmartDataAnalytics/DL-Learner

public int getPropertyCount(OWLObjectProperty property){
  String query = String.format("SELECT (COUNT(*) AS ?cnt) WHERE {?s <%s> ?o.}", property.toStringID());
  ResultSet rs = executeSelectQuery(query);
  int cnt = rs.next().get(rs.getResultVars().get(0)).asLiteral().getInt();
  return cnt;
}

代码示例来源:origin: vivo-project/Vitro

private void serialize(OutputStream outputStream, String query) throws RDFServiceException {
  InputStream resultStream = sparqlSelectQuery(query, RDFService.ResultFormat.JSON);
  ResultSet resultSet = ResultSetFactory.fromJSON(resultStream);
  if (resultSet.getResultVars().contains("g")) {
    Iterator<Quad> quads = new ResultSetQuadsIterator(resultSet);
    RDFDataMgr.writeQuads(outputStream, quads);
  } else {
    Iterator<Triple> triples = new ResultSetTriplesIterator(resultSet);
    RDFDataMgr.writeTriples(outputStream, triples);
  }
}

代码示例来源:origin: apache/jena

public static void writeResultSet(TProtocol protocol, ResultSet resultSet, boolean encodeValues) {
  List<Var> vars = Var.varList(resultSet.getResultVars()) ;
  try ( Binding2Thrift b2t = new Binding2Thrift(protocol, vars, encodeValues) ) {
    for ( ; resultSet.hasNext() ; ) {
      Binding b = resultSet.nextBinding() ;
      b2t.output(b) ;
    }
  }
  //Done by Binding2Thrift.close() -- LibThriftRDF.flush(protocol) ;
}

代码示例来源:origin: SmartDataAnalytics/jena-sparql-api

@Override
  public ResultSet execSelect() {
    ResultSet rs = super.execSelect();

    List<String> varNames = rs.getResultVars();
    Iterator<Binding> it = ResultSetUtils.toIteratorBinding(rs);
    Iterator<Binding> iu = Iterators.transform(it, b -> BindingUtils.rename(b, varMap));

    ResultSet result = ResultSetUtils.create(varNames, iu);
    return result;
  }
}

代码示例来源:origin: org.aksw.jena-sparql-api/jena-sparql-api-cache

public static Table createTable(ResultSet rs) {
  List<Var> vars = VarUtils.toList(rs.getResultVars());
  Table result = TableFactory.create(vars);
  while(rs.hasNext()) {
    Binding binding = rs.nextBinding();
    result.addBinding(binding);
  }
  return result;
}

代码示例来源:origin: SmartDataAnalytics/jena-sparql-api

public static Table createTable(ResultSet rs) {
  List<Var> vars = VarUtils.toList(rs.getResultVars());
  Table result = TableFactory.create(vars);
  while(rs.hasNext()) {
    Binding binding = rs.nextBinding();
    result.addBinding(binding);
  }
  return result;
}

代码示例来源:origin: apache/jena

private void testErr(String qsAgg, DatasetGraph ds, Syntax syntax) {
  Query query = buildGroupBy(qsAgg, syntax) ;
  try ( QueryExecution qExec = QueryExecutionFactory.create(query, DatasetFactory.wrap(ds)) ) {
    ResultSet rs = qExec.execSelect() ;
    assertTrue(rs.getResultVars().contains("X")) ;
    Binding b = rs.nextBinding() ;
    assertFalse(b.contains(Var.alloc("X"))) ;
  }
}

代码示例来源:origin: apache/jena

private void testEmptyNoGroupBy(String qsAgg, DatasetGraph ds, Syntax syntax) {
  Query query = buildNoGroupBy(qsAgg, syntax) ;
  try ( QueryExecution qExec = QueryExecutionFactory.create(query, DatasetFactory.wrap(ds)) ) {
    ResultSet rs = qExec.execSelect() ;
    assertTrue(rs.hasNext()) ;
    assertTrue(rs.getResultVars().contains("X")) ;
    Binding b = rs.nextBinding() ;
    assertFalse(b.contains(Var.alloc("X"))) ;
  }
}

相关文章