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

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

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

Query.setOffset介绍

暂无

代码示例

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

  1. /**
  2. * Set the offset for the results to return.
  3. * Setting the offset to zero (0) or removes the offset.
  4. * @param offset The offset to set.
  5. */
  6. public void setOffset(int offset) {
  7. query.setOffset(offset < 1 ? Query.NOLIMIT : offset);
  8. }

代码示例来源:origin: org.apache.jena/jena-querybuilder

  1. /**
  2. * Set the offset for the results to return.
  3. * Setting the offset to zero (0) or removes the offset.
  4. * @param offset The offset to set.
  5. */
  6. public void setOffset(int offset) {
  7. query.setOffset(offset < 1 ? Query.NOLIMIT : offset);
  8. }

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

  1. @Override
  2. public void visitOffset(Query query) {
  3. newQuery.setOffset(query.getOffset());
  4. }

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

  1. @Override
  2. public void visitOffset(Query query) {
  3. newQuery.setOffset(query.getOffset()) ;
  4. }

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

  1. query.setOffset(Query.NOLIMIT);
  2. } else {
  3. query.setOffset(nextOffset);

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

  1. public static void applyRange(Query query, Range<Long> range) {
  2. long offset = rangeToOffset(range);
  3. long limit = rangeToLimit(range);
  4. query.setOffset(offset);
  5. query.setLimit(limit);
  6. }

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

  1. final public void OffsetClause() throws ParseException {
  2. Token t ;
  3. jj_consume_token(OFFSET);
  4. t = jj_consume_token(INTEGER);
  5. getQuery().setOffset(integerValue(t.image)) ;
  6. }

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

  1. final public void OffsetClause() throws ParseException {
  2. Token t ;
  3. jj_consume_token(OFFSET);
  4. t = jj_consume_token(INTEGER);
  5. getQuery().setOffset(integerValue(t.image)) ;
  6. }

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

  1. final public void OffsetClause() throws ParseException {
  2. Token t ;
  3. jj_consume_token(OFFSET);
  4. t = jj_consume_token(INTEGER);
  5. getQuery().setOffset(integerValue(t.image)) ;
  6. }

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

  1. @Override
  2. public Model extractFragment(OWLClass cls, int maxFragmentDepth) {
  3. startTime = System.currentTimeMillis();
  4. Model fragment = ModelFactory.createDefaultModel();
  5. Query query = buildConstructQuery(cls, maxFragmentDepth);
  6. long pageSize = PaginationUtils.adjustPageSize(qef, 10000);
  7. query.setLimit(pageSize);
  8. int offset = 0;
  9. while(getRemainingRuntime() > 0){
  10. query.setOffset(offset);System.out.println(query);
  11. Model model = qef.createQueryExecution(query).execConstruct();
  12. fragment.add(model);
  13. offset += pageSize;
  14. }
  15. return fragment;
  16. }

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

  1. @Override
  2. public QueryExecutionCompare createQueryExecution(Query query) {
  3. if(removeSlices) {
  4. query = (Query)query.clone();
  5. query.setLimit(Query.NOLIMIT);
  6. query.setOffset(Query.NOLIMIT);
  7. }
  8. //boolean isOrdered = !query.getOrderBy().isEmpty();
  9. QueryExecution qea = a.createQueryExecution(query);
  10. QueryExecution qeb = b.createQueryExecution(query);
  11. QueryExecutionCompare result = new QueryExecutionCompare(query, qea, qeb, false);
  12. //QueryExecution result = QueryExecutionWrapper.wrap(tmp);
  13. return result;
  14. }

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

  1. public PaginationQueryIterator createQueryIterator(Long offset, Long limit) {
  2. long o = offset == null ? 0 : offset;
  3. long l = limit == null ? Long.MAX_VALUE : limit;
  4. long queryOffset = proto.getOffset() == Query.NOLIMIT ? 0 : proto.getOffset();
  5. long itemOffset = queryOffset + o;
  6. long queryLimit = proto.getLimit() == Query.NOLIMIT ? Long.MAX_VALUE : proto.getLimit() - o;
  7. long itemLimit = Math.min(queryLimit, l);
  8. itemLimit = itemLimit == Long.MAX_VALUE ? Query.NOLIMIT : itemLimit;
  9. Query clone = proto.cloneQuery();
  10. clone.setOffset(itemOffset);
  11. clone.setLimit(itemLimit);
  12. PaginationQueryIterator result = new PaginationQueryIterator(clone, pageSize);
  13. return result;
  14. }
  15. }

代码示例来源:origin: tarql/tarql

  1. /**
  2. * Sets up a new query execution.
  3. *
  4. * @param source The input CSV file
  5. * @param options Configuration options for the CSV file
  6. * @param query The input query
  7. */
  8. public TarqlQueryExecution(InputStreamSource source, CSVOptions options, TarqlQuery query) {
  9. if (options == null) {
  10. options = new CSVOptions();
  11. }
  12. if (options.hasColumnNamesInFirstRow() == null) {
  13. // Presence or absence of header row was not specified on command line or FROM clause.
  14. // So we fall back to the convention where OFFSET 1 in the query
  15. // indicates that a header is present. To make that work, we
  16. // set the OFFSET to 0 and tell the parser to gobble up the first
  17. // row for column names.
  18. options = new CSVOptions(options);
  19. Query firstQuery = query.getQueries().get(0);
  20. if (firstQuery.getOffset() == 1) {
  21. options.setColumnNamesInFirstRow(true);
  22. firstQuery.setOffset(0);
  23. }
  24. }
  25. table = new CSVTable(source, options);
  26. tq = query;
  27. }

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

  1. @Override
  2. public void visit(OpSlice opSlice)
  3. {
  4. if ( opSlice.getStart() != Query.NOLIMIT )
  5. query.setOffset(opSlice.getStart()) ;
  6. if ( opSlice.getLength() != Query.NOLIMIT )
  7. query.setLimit(opSlice.getLength()) ;
  8. opSlice.getSubOp().visit(this) ;
  9. }

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

  1. /**
  2. * Copy all the modifications from the Solution Modifier argument
  3. * @param solutionModifier The solution modifier to copy from.
  4. */
  5. public void addAll(SolutionModifierHandler solutionModifier) {
  6. List<SortCondition> lst = solutionModifier.query.getOrderBy();
  7. if (lst != null) {
  8. for (SortCondition sc : lst) {
  9. query.addOrderBy(sc);
  10. }
  11. }
  12. query.getGroupBy().addAll(solutionModifier.query.getGroupBy());
  13. query.getHavingExprs().addAll(solutionModifier.query.getHavingExprs());
  14. query.setLimit(solutionModifier.query.getLimit());
  15. query.setOffset(solutionModifier.query.getOffset());
  16. }

代码示例来源:origin: org.apache.jena/jena-querybuilder

  1. /**
  2. * Copy all the modifications from the Solution Modifier argument
  3. * @param solutionModifier The solution modifier to copy from.
  4. */
  5. public void addAll(SolutionModifierHandler solutionModifier) {
  6. List<SortCondition> lst = solutionModifier.query.getOrderBy();
  7. if (lst != null) {
  8. for (SortCondition sc : lst) {
  9. query.addOrderBy(sc);
  10. }
  11. }
  12. query.getGroupBy().addAll(solutionModifier.query.getGroupBy());
  13. query.getHavingExprs().addAll(solutionModifier.query.getHavingExprs());
  14. query.setLimit(solutionModifier.query.getLimit());
  15. query.setOffset(solutionModifier.query.getOffset());
  16. }

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

  1. @Override
  2. public QueryExecution createQueryExecution(Query query) {
  3. Query q = query.cloneQuery();
  4. long offset = q.getOffset() == Query.NOLIMIT ? 0 : q.getOffset();
  5. long limit = q.getLimit();
  6. long o = (offset / pageExpandSize) * pageExpandSize;
  7. long l;
  8. if(limit != Query.NOLIMIT) {
  9. long target = offset + limit;
  10. long t = ((target / pageExpandSize) + 1) * pageExpandSize;
  11. l = t - o;
  12. } else {
  13. l = Query.NOLIMIT;
  14. }
  15. long start = o - offset;
  16. // Align offset and target to pageExpandSize boundaries
  17. q.setOffset(o);
  18. q.setLimit(l);
  19. QueryExecution qe = qef.createQueryExecution(q);
  20. //QueryExecutionRange result = new QueryExecutionRange(qe, start, l);
  21. QueryExecution result = null;
  22. return result;
  23. }

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

  1. query.setOffset(i++ * pageSize);
  2. QueryExecution qe = ksQef.createQueryExecution(query);
  3. Model tmp = qe.execConstruct();

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

  1. public static Query createQueryList(UnaryRelation concept, Long limit, Long offset) {
  2. Query result = new Query();
  3. result.setQuerySelectType();
  4. result.setDistinct(true);
  5. result.setLimit(limit == null ? Query.NOLIMIT : limit);
  6. result.setOffset(offset == null ? Query.NOLIMIT : offset);
  7. result.getProject().add(concept.getVar());
  8. Element e = concept.getElement();
  9. if(e instanceof ElementSubQuery) {
  10. e = ElementUtils.createElementGroup(e);
  11. }
  12. result.setQueryPattern(e);
  13. // String str = result.toString();
  14. // System.out.println(str);
  15. return result;
  16. }

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

  1. @Override
  2. public Model getTriples(RDFNode subject, RDFNode predicate, RDFNode object, long limit, long offset) throws RDFServiceException {
  3. Query query = QueryFactory.create("CONSTRUCT WHERE { ?s ?p ?o }", Syntax.syntaxSPARQL_11);
  4. QuerySolutionMap map = new QuerySolutionMap();
  5. if ( subject != null ) {
  6. map.add("s", subject);
  7. }
  8. if ( predicate != null ) {
  9. map.add("p", predicate);
  10. }
  11. if ( object != null ) {
  12. map.add("o", object);
  13. }
  14. query.setOffset(offset);
  15. query.setLimit(limit);
  16. Model triples = ModelFactory.createDefaultModel();
  17. DatasetWrapper dw = getDatasetWrapper();
  18. try {
  19. Dataset d = dw.getDataset();
  20. try (QueryExecution qexec = QueryExecutionFactory.create(query, d, map)) {
  21. qexec.execConstruct(triples);
  22. }
  23. return triples;
  24. } finally {
  25. dw.close();
  26. }
  27. }

相关文章