Package com.mongodb

Examples of com.mongodb.DBCursor.limit()


        logger.info("Executing MongoDB 'find' query: {}", query);
        DBCursor cursor = collection.find(query);

        if (maxRows > 0) {
            cursor = cursor.limit(maxRows);
        }
        if (firstRow > 1) {
            final int skip = firstRow - 1;
            cursor = cursor.skip(skip);
        }
View Full Code Here


            if (numToSkip != null) {
                ret.skip(numToSkip.intValue());
            }

            if (limit != null) {
                ret.limit(limit.intValue());
            }

            Message resultMessage = prepareResponseMessage(exchange, MongoDbOperation.findAll);
            resultMessage.setBody(ret.toArray());
            resultMessage.setHeader(MongoDbConstants.RESULT_TOTAL_SIZE, ret.count());
View Full Code Here

    if ( queryParameters.getRowSelection().getFirstRow() != null ) {
      cursor.skip( queryParameters.getRowSelection().getFirstRow() );
    }

    if ( queryParameters.getRowSelection().getMaxRows() != null ) {
      cursor.limit( queryParameters.getRowSelection().getMaxRows() );
    }

    return new MongoDBResultsCursor( cursor, entityKeyMetadata );
  }
View Full Code Here

        secondCommit.setAffectedPaths(Arrays.asList(new String[] { "/a", "/a/d", "/a/b/e" }));
        secondCommit.setRevisionId(2L);

        DBCursor mockDbCursor = EasyMock.createMock(DBCursor.class);
        EasyMock.expect(mockDbCursor.sort(EasyMock.anyObject(DBObject.class))).andReturn(mockDbCursor);
        EasyMock.expect(mockDbCursor.limit(EasyMock.anyInt())).andReturn(mockDbCursor);
        EasyMock.expect(mockDbCursor.hasNext()).andReturn(true).once();
        EasyMock.expect(mockDbCursor.next()).andReturn(firstCommit).once();
        EasyMock.expect(mockDbCursor.hasNext()).andReturn(true).once();
        EasyMock.expect(mockDbCursor.next()).andReturn(secondCommit).once();
        EasyMock.expect(mockDbCursor.hasNext()).andReturn(false).once();
View Full Code Here

        secondCommit.setAffectedPaths(Arrays.asList(new String[] { "/a", "/a/d", "/a/b/e" }));
        secondCommit.setRevisionId(2L);

        DBCursor mockDbCursor = EasyMock.createMock(DBCursor.class);
        EasyMock.expect(mockDbCursor.sort(EasyMock.anyObject(DBObject.class))).andReturn(mockDbCursor);
        EasyMock.expect(mockDbCursor.limit(EasyMock.anyInt())).andReturn(mockDbCursor);
        EasyMock.expect(mockDbCursor.hasNext()).andReturn(true).once();
        EasyMock.expect(mockDbCursor.next()).andReturn(firstCommit).once();
        EasyMock.expect(mockDbCursor.hasNext()).andReturn(true).once();
        EasyMock.expect(mockDbCursor.next()).andReturn(secondCommit).once();
        EasyMock.expect(mockDbCursor.hasNext()).andReturn(false).once();
View Full Code Here

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

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

        try {
            while (dbCursor.hasNext()) {
                DBObject dbObject = dbCursor.next();
                if (kclass == null) {
View Full Code Here

    if ( queryParameters.getRowSelection().getFirstRow() != null ) {
      cursor.skip( queryParameters.getRowSelection().getFirstRow() );
    }

    if ( queryParameters.getRowSelection().getMaxRows() != null ) {
      cursor.limit( queryParameters.getRowSelection().getMaxRows() );
    }

    return new MongoDBResultsCursor( cursor, metadatas.length == 1 ? metadatas[0] : null );
  }
View Full Code Here

    if ( queryParameters.getRowSelection().getFirstRow() != null ) {
      cursor.skip( queryParameters.getRowSelection().getFirstRow() );
    }

    if ( queryParameters.getRowSelection().getMaxRows() != null ) {
      cursor.limit( queryParameters.getRowSelection().getMaxRows() );
    }

    return new MongoDBResultsCursor( cursor, entityKeyMetadata );
  }
View Full Code Here

     * @return
     * @throws IOException
     */
    private Collection<DBFeature.IGVFeat> getFeatures(DBObject queryObject, int limit) throws IOException{
        DBCursor cursor = this.collection.find(queryObject);
        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));
View Full Code Here

                    DBCursor cur = col.find(query, fields, skip, batchSize);
                    if (sort != null) {
                        cur.sort(sort);
                    }
                    if (limit > 0) {
                        cur.limit(limit);
                    }
                    if (hint != null) {
                        cur.hint(hint);
                    }
                    if (explain) {
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.