/** * Sets the maximum execution time on the server for this operation. * * @param maxTime the max time * @param timeUnit the time unit, which may not be null * @return this * @mongodb.driver.manual reference/method/cursor.maxTimeMS/#cursor.maxTimeMS Max Time */ public FindOptions maxTime(final long maxTime, final TimeUnit timeUnit) { options.maxTime(maxTime, timeUnit); return this; }
/** * Set the maximum execution time for operations on this cursor. * * @param maxTime the maximum time that the server will allow the query to run, before killing the operation. A non-zero value requires * a server version >= 2.6 * @param timeUnit the time unit * @return same DBCursor for chaining operations * @mongodb.server.release 2.6 * @mongodb.driver.manual reference/operator/meta/maxTimeMS/ $maxTimeMS * @since 2.12.0 */ public DBCursor maxTime(final long maxTime, final TimeUnit timeUnit) { findOptions.maxTime(maxTime, timeUnit); return this; }
/** * Copy this DBCollectionFindOptions instance into a new instance. * * @return the new DBCollectionFindOptions with the same settings as this instance. */ public DBCollectionFindOptions copy() { DBCollectionFindOptions copiedOptions = new DBCollectionFindOptions(); copiedOptions.batchSize(batchSize); copiedOptions.limit(limit); copiedOptions.modifiers(modifiers); copiedOptions.projection(projection); copiedOptions.maxTime(maxTimeMS, TimeUnit.MILLISECONDS); copiedOptions.maxAwaitTime(maxAwaitTimeMS, TimeUnit.MILLISECONDS); copiedOptions.skip(skip); copiedOptions.sort(sort); copiedOptions.cursorType(cursorType); copiedOptions.noCursorTimeout(noCursorTimeout); copiedOptions.oplogReplay(oplogReplay); copiedOptions.partial(partial); copiedOptions.readPreference(readPreference); copiedOptions.readConcern(readConcern); copiedOptions.collation(collation); copiedOptions.comment(comment); copiedOptions.hint(hint); copiedOptions.max(max); copiedOptions.min(min); copiedOptions.returnKey(returnKey); copiedOptions.showRecordId(showRecordId); return copiedOptions; }
/** * Sets the maximum execution time on the server for this operation. * * @param maxTime the max time * @param timeUnit the time unit, which may not be null * @return this * @mongodb.driver.manual reference/method/cursor.maxTimeMS/#cursor.maxTimeMS Max Time */ public FindOptions maxTime(final long maxTime, final TimeUnit timeUnit) { options.maxTime(maxTime, timeUnit); return this; }
/** * Set the maximum execution time for operations on this cursor. * * @param maxTime the maximum time that the server will allow the query to run, before killing the operation. A non-zero value requires * a server version >= 2.6 * @param timeUnit the time unit * @return same DBCursor for chaining operations * @mongodb.server.release 2.6 * @mongodb.driver.manual reference/operator/meta/maxTimeMS/ $maxTimeMS * @since 2.12.0 */ public DBCursor maxTime(final long maxTime, final TimeUnit timeUnit) { findOptions.maxTime(maxTime, timeUnit); return this; }
@Override public List<T> results(){ DBObject projection; if(fieldsSpecified){ projection = fields; }else{ projection = dao.getKeyFields(); } DBCollectionFindOptions options = new DBCollectionFindOptions(); options.projection(projection); if(maxTimeMS > 0){ options.maxTime(maxTimeMS, TimeUnit.MILLISECONDS); } if(orderBy != null){ options.sort(SortUtil.getSort(orderBy)); } if(pageNumber>0 && pageSize>0){ options.skip((pageNumber-1) * pageSize); options.limit(pageSize); } DBCollection coll = dao.getCollection(); DBCursor cursor = coll.find(condition, options); return MapperUtil.toList(dao.getEntityClass(), cursor, withoutCascade); }
/** * Copy this DBCollectionFindOptions instance into a new instance. * * @return the new DBCollectionFindOptions with the same settings as this instance. */ public DBCollectionFindOptions copy() { DBCollectionFindOptions copiedOptions = new DBCollectionFindOptions(); copiedOptions.batchSize(batchSize); copiedOptions.limit(limit); copiedOptions.modifiers(modifiers); copiedOptions.projection(projection); copiedOptions.maxTime(maxTimeMS, TimeUnit.MILLISECONDS); copiedOptions.maxAwaitTime(maxAwaitTimeMS, TimeUnit.MILLISECONDS); copiedOptions.skip(skip); copiedOptions.sort(sort); copiedOptions.cursorType(cursorType); copiedOptions.noCursorTimeout(noCursorTimeout); copiedOptions.oplogReplay(oplogReplay); copiedOptions.partial(partial); copiedOptions.readPreference(readPreference); copiedOptions.readConcern(readConcern); copiedOptions.collation(collation); copiedOptions.comment(comment); copiedOptions.hint(hint); copiedOptions.max(max); copiedOptions.min(min); copiedOptions.returnKey(returnKey); copiedOptions.showRecordId(showRecordId); return copiedOptions; }