Package com.mongodb

Examples of com.mongodb.DBCursor.sort()


        DBCursor dbCursor = fields == null
                ? collection().find(translateMapToDBObject(selector))
                : collection().find(translateMapToDBObject(selector), translateMapToDBObject(fields));

        if (sort != null)
            dbCursor.sort(translateMapToDBObject(sort));

        if (skip != null)
            dbCursor.skip(skip);

        if (limit != null)
View Full Code Here


    DBCollection collection = provider.getDatabase().getCollection( collectionName );
    DBCursor cursor = collection.find( mongodbQuery, projection );

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

    // apply firstRow/maxRows if present
    if ( queryParameters.getRowSelection().getFirstRow() != null ) {
      cursor.skip( queryParameters.getRowSelection().getFirstRow() );
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

        cursor.limit(limit >= 0 ? limit : 0);

        //Sort by increasing start value
        //Only do this if we have an index, otherwise might be too memory intensive
        if(hasLocusIndex){
            cursor.sort(new BasicDBObject("Start", 1));
        }
        boolean isSorted = true;
        int lastStart = -1;

        List<DBFeature.IGVFeat> features = new ArrayList<DBFeature.IGVFeat>();
View Full Code Here

                @Override
                public Object doRun() {
                    // this does not actually block, may not need dbjob
                    DBCursor cur = col.find(query, fields, skip, batchSize);
                    if (sort != null) {
                        cur.sort(sort);
                    }
                    if (limit > 0) {
                        cur.limit(limit);
                    }
                    if (hint != null) {
View Full Code Here

            @Override
            public Object doRun() {
                // this does not actually block, may not need dbjob
                DBCursor cur = col.find(query, fields).skip(skip).batchSize(batchSize).addOption(options);
                if (sort != null) {
                    cur.sort(sort);
                }
                if (limit > 0) {
                    cur.limit(limit);
                }
                if (hint != null) {
View Full Code Here

                        }
                        if (batchSize != 0) {
                            cur.batchSize(batchSize);
                        }
                        if (sort != null) {
                            cur.sort(sort);
                        }
                        if (limit > 0) {
                            cur.limit(limit);
                        }
                        while (cur.hasNext() && !stopped) {
View Full Code Here

        if (batchSize > 0)
            cursor.batchSize(batchSize);
        if (snapshotted)
            cursor.snapshot();
        if (sort != null)
            cursor.sort(sort);
        if (indexHint != null)
            cursor.hint(indexHint);

        if (null != readPref) {
            cursor.setReadPreference(readPref);
View Full Code Here

        query.put("$lt", stopRow);
        b = b("id", query);
      }
    } else if (stopRow != null) b.put("id", b("$lt", stopRow));
    final DBCursor dbCursor = rows.find(b);
    dbCursor.sort(b("id", 1));
    return new Iterable<Row<T, K>>() {
      @Override
      public Iterator<Row<T, K>> iterator() {
        final Iterator<DBObject> iterator = dbCursor.iterator();
        return new Iterator<Row<T, K>>() {
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.