Package com.mongodb

Examples of com.mongodb.DBCursor.sort()


  private ClosableIterator<Tuple> doFind(MongoDBQueryDescriptor query, QueryParameters queryParameters, DBCollection collection,
      EntityKeyMetadata entityKeyMetadata) {
    DBCursor cursor = collection.find( query.getCriteria(), query.getProjection() );

    if ( query.getOrderBy() != null ) {
      cursor.sort( query.getOrderBy() );
    }

    // apply firstRow/maxRows if present
    if ( queryParameters.getRowSelection().getFirstRow() != null ) {
      cursor.skip( queryParameters.getRowSelection().getFirstRow() );
View Full Code Here


            } else {
                ret = dbCol.find(query, fieldFilter);
            }

            if (sortBy != null) {
                ret.sort(sortBy);
            }

            if (batchSize != null) {
                ret.batchSize(batchSize.intValue());
            }
View Full Code Here

                    input.remove("$select");
                }
                DBObject object = buildDBObject(input);
                DBCursor cursor = collection.find(object, select);
                if (sort != null) {
                    cursor.sort(sort);
                }
                try {
                    if (mongoSpec.getSkip() > 0) {
                        cursor.skip(mongoSpec.getSkip());
                    }
View Full Code Here

  private ClosableIterator<Tuple> doFind(MongoDBQueryDescriptor query, QueryParameters queryParameters, DBCollection collection,
      EntityKeyMetadata entityKeyMetadata) {
    DBCursor cursor = collection.find( query.getCriteria(), query.getProjection() );

    if ( query.getOrderBy() != null ) {
      cursor.sort( query.getOrderBy() );
    }

    // apply firstRow/maxRows if present
    if ( queryParameters.getRowSelection().getFirstRow() != null ) {
      cursor.skip( queryParameters.getRowSelection().getFirstRow() );
View Full Code Here

    if (high > 0) {
      filter.append("id", new BasicDBObject("$lte", high));
    }

    DBCursor cursor = collection.find(filter);
    cursor.sort(new BasicDBObject("id", 1));

    List<LogEvent> logevents = new ArrayList<LogEvent>();
    while (cursor.hasNext()) {
      DBObject event = cursor.next();
      String targetId = (String) event.get("targetId");
View Full Code Here

    BasicDBObject filter = new BasicDBObject().append("targetId", targetID)
        .append("logId", logID);

    DBCursor cursor = collection.find(filter);
    cursor.sort(new BasicDBObject("id", -1));

    long high = 1;
    if (cursor.hasNext()) {
      DBObject row = cursor.next();
      high = (Long) row.get("id");
View Full Code Here

                }
            }

            // sort
            if (null != cursor && null != sort) {
                cursor = cursor.sort(sort);
            }

            return cursor;
        }
        return null;
View Full Code Here

    DBCursor cursor = coll.find(jsonToDBObject(matcher));
    if (limit != -1) {
      cursor.limit(limit);
    }
    if (sort != null) {
      cursor.sort(jsonToDBObject(sort));
    }
    sendBatch(message, cursor, batchSize);
  }

  private void sendBatch(Message<JsonObject> message, final DBCursor cursor, final int max) {
View Full Code Here

            } else {
                ret = dbCol.find(query, fieldFilter);
            }
           
            if (sortBy != null) {
                ret.sort(sortBy);
            }
           
            if (batchSize != null) {
                ret.batchSize(batchSize.intValue());
            }
View Full Code Here

    @ExceptionMetered
    @Override
    public QueryResults<T> find(@Nullable C criteria, @Nullable S sortOrder, int startIndex, int maxResults) {
        DBCursor dbCursor = getPrimaryCollection().find(convertCriteriaToDBObject(criteria));
        try {
            dbCursor.sort(convertSortOrderToDBObject(sortOrder)).
                    skip(startIndex).
                    limit(maxResults);

            logQueryDetails(dbCursor);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.