com.mongodb.client.model.Aggregates.skip()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(237)

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

Aggregates.skip介绍

[英]Creates a $skip pipeline stage
[中]创建$skip管道阶段

代码示例

代码示例来源:origin: eclipse/ditto

private static void addSkipAndLimit(final Collection<Bson> pipeline,
    final int skip,
    final int limit,
    final boolean isCount) {
  if (!isCount) {
    pipeline.add(Aggregates.skip(skip));
    pipeline.add(Aggregates.limit(limit + 1));
  }
}

代码示例来源:origin: org.eclipse.ditto/ditto-services-thingsearch-persistence

private static void addSkipAndLimit(final Collection<Bson> pipeline,
    final int skip,
    final int limit,
    final boolean isCount) {
  if (!isCount) {
    pipeline.add(Aggregates.skip(skip));
    pipeline.add(Aggregates.limit(limit + 1));
  }
}

代码示例来源:origin: org.opencb.commons/commons-datastore-mongodb

public static Bson getSkip(QueryOptions options) {
  if (options.getInt(QueryOptions.SKIP) > 0) {
    return Aggregates.skip(options.getInt(QueryOptions.SKIP));
  }
  return null;
}

代码示例来源:origin: T-baby/MongoDB-Plugin

public MongoAggregation(MongoQuery query) {
  /*复用MongoQuery*/
  this.query = query;
  if (query.getQuery() != null && !query.getQuery().isEmpty()) {
    pipeline.add(Aggregates.match(Filters.and(query.getQuery())));
  }
  if (query.getSort() != null) {
    pipeline.add(Aggregates.sort(query.getSort()));
  }
  if (query.getSkip() > 0) {
    pipeline.add(Aggregates.skip(query.getSkip()));
  }
  if (query.getLimit() > 0) {
    pipeline.add(Aggregates.limit(query.getLimit()));
  }
}

代码示例来源:origin: ozlerhakan/mongolastic

/**
   * Get the MongoDB cursor.
   */
  private MongoCursor<Document> getCursor(int skip) {
    if (cursor == null && cursorId == 0) {
      Document query = Document.parse(config.getMongo().getQuery());
      List<Bson> pipes = new ArrayList<>(3);
      pipes.add(match(query));
      pipes.add(skip(skip));

      Optional.ofNullable(config.getMongo().getProject()).ifPresent(p -> pipes.add(project(Document.parse(p))));

      AggregateIterable<Document> aggregate = collection.aggregate(pipes)
          .allowDiskUse(true)
          .useCursor(true);

      cursor = aggregate.iterator();

      // TODO: Persist cursor ID somewhere to allow restarts.
      Optional.ofNullable(cursor.getServerCursor()).ifPresent(serverCursor -> cursorId = serverCursor.getId());
    } else if (cursor == null && cursorId != 0) {
      // TODO: Lookup cursor ID for resume.
      // Open existing cursor in case of restart??
    }

    return cursor;
  }
}

代码示例来源:origin: com.cybermkd/MongodbPlugin

public MongoAggregation(MongoQuery query) {
  /*复用MongoQuery*/
  this.query = query;
  if (query.getQuery() != null && !query.getQuery().isEmpty()) {
    pipeline.add(Aggregates.match(Filters.and(query.getQuery())));
  }
  if (query.getSort() != null) {
    pipeline.add(Aggregates.sort(query.getSort()));
  }
  if (query.getSkip() > 0) {
    pipeline.add(Aggregates.skip(query.getSkip()));
  }
  if (query.getLimit() > 0) {
    pipeline.add(Aggregates.limit(query.getLimit()));
  }
}

代码示例来源:origin: com.holon-platform.mongo/holon-datastore-mongo-core

definition.getOffset().ifPresent(o -> pipeline.add(Aggregates.skip(o)));

相关文章