if (dbOptions.getBatchSize() != that.getBatchSize()) { return false; if (dbOptions.getLimit() != that.getLimit()) { return false; if (dbOptions.getMaxTime(MILLISECONDS) != that.getMaxTime(MILLISECONDS)) { return false; if (dbOptions.getMaxAwaitTime(MILLISECONDS) != that.getMaxAwaitTime(MILLISECONDS)) { return false; if (dbOptions.getSkip() != that.getSkip()) { return false; if (dbOptions.isNoCursorTimeout() != that.isNoCursorTimeout()) { return false; if (dbOptions.isOplogReplay() != that.isOplogReplay()) { return false; if (dbOptions.isPartial() != that.isPartial()) { return false; if (dbOptions.getModifiers() != null ? !dbOptions.getModifiers().equals(that.getModifiers()) : that.getModifiers() != null) { return false; if (dbOptions.getProjection() != null ? !dbOptions.getProjection().equals(that.getProjection()) : that.getProjection() != null) { return false;
FindOperation<DBObject> operation = new FindOperation<DBObject>(collection.getNamespace(), decoder) .filter(collection.wrapAllowNull(filter)) .batchSize(findOptions.getBatchSize()) .skip(findOptions.getSkip()) .limit(findOptions.getLimit()) .maxAwaitTime(findOptions.getMaxAwaitTime(MILLISECONDS), MILLISECONDS) .maxTime(findOptions.getMaxTime(MILLISECONDS), MILLISECONDS) .modifiers(collection.wrapAllowNull(findOptions.getModifiers())) .projection(collection.wrapAllowNull(findOptions.getProjection())) .sort(collection.wrapAllowNull(findOptions.getSort())) .collation(findOptions.getCollation()) .comment(findOptions.getComment()) .hint(collection.wrapAllowNull(findOptions.getHint())) .min(collection.wrapAllowNull(findOptions.getMin())) .max(collection.wrapAllowNull(findOptions.getMax())) .returnKey(findOptions.isReturnKey()) .showRecordId(findOptions.isShowRecordId()); operation.cursorType(findOptions.getCursorType()); operation.oplogReplay(findOptions.isOplogReplay()); operation.noCursorTimeout(findOptions.isNoCursorTimeout()); operation.partial(findOptions.isPartial());
/** * Gets the query modifiers to apply to this operation. The default is not to apply any modifiers. * * @return the query modifiers, which may be null * @mongodb.driver.manual reference/operator/query-modifier/ Query Modifiers */ DBObject getModifiers() { return options.getModifiers(); }
private DBCollectionCountOptions getDbCollectionCountOptions() { DBCollectionCountOptions countOptions = new DBCollectionCountOptions() .readPreference(getReadPreferenceForCursor()) .readConcern(getReadConcern()) .collation(getCollation()) .maxTime(findOptions.getMaxTime(MILLISECONDS), MILLISECONDS); Object hint = findOptions.getHint() != null ? findOptions.getHint() : findOptions.getModifiers().get("$hint"); if (hint != null) { if (hint instanceof String) { countOptions.hintString((String) hint); } else { countOptions.hint((DBObject) hint); } } return countOptions; } }
/** * Gets a document describing the fields to return for all matching documents. * * @return the project document, which may be null * @mongodb.driver.manual reference/method/db.collection.find/ Projection */ DBObject getProjection() { return options.getProjection(); }
/** * Counts the number of objects matching the query this does take limit/skip into consideration * * @return the number of objects * @throws MongoException if the operation failed * @see #count() */ public int size() { DBCollectionCountOptions countOptions = getDbCollectionCountOptions().skip(findOptions.getSkip()).limit(findOptions.getLimit()); return (int) collection.getCount(getQuery(), countOptions); }
/** * Returns the readConcern * * @return the readConcern * @mongodb.server.release 3.2 */ public ReadConcern getReadConcern() { return options.getReadConcern(); }
/** * Returns the collation options * * @return the collation options * @mongodb.server.release 3.4 */ public Collation getCollation() { return options.getCollation(); }
/** * Gets the number of documents to return per batch. Default to 0, which indicates that the server chooses an appropriate batch * size. * * @return the batch size, which may be null * @mongodb.driver.manual reference/method/cursor.batchSize/#cursor.batchSize Batch Size */ public int getBatchSize() { return options.getBatchSize(); }
/** * Gets the limit to apply. The default is null. * * @return the limit * @mongodb.driver.manual reference/method/cursor.limit/#cursor.limit Limit */ public int getLimit() { return options.getLimit(); }
/** * Returns the readPreference * * @return the readPreference */ public ReadPreference getReadPreference() { return options.getReadPreference(); }
/** * Gets the maximum execution time on the server for this operation. The default is 0, which places no limit on the execution time. * * @param timeUnit the time unit to return the result in * @return the maximum execution time in the given time unit * @mongodb.driver.manual reference/method/cursor.maxTimeMS/#cursor.maxTimeMS Max Time */ public long getMaxTime(final TimeUnit timeUnit) { return options.getMaxTime(timeUnit); }
/** * Get the cursor type. * * @return the cursor type */ public CursorType getCursorType() { return options.getCursorType(); }
/** * The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor * query. This only applies to a TAILABLE_AWAIT cursor. When the cursor is not a TAILABLE_AWAIT cursor, * this option is ignored. * * On servers >= 3.2, this option will be specified on the getMore command as "maxTimeMS". The default * is no value: no "maxTimeMS" is sent to the server with the getMore command. * * On servers < 3.2, this option is ignored, and indicates that the driver should respect the server's default value * * A zero value will be ignored. * * @param timeUnit the time unit to return the result in * @return the maximum await execution time in the given time unit * @mongodb.driver.manual reference/method/cursor.maxTimeMS/#cursor.maxTimeMS Max Time */ public long getMaxAwaitTime(final TimeUnit timeUnit) { return options.getMaxAwaitTime(timeUnit); }
FindOperation<DBObject> operation = new FindOperation<DBObject>(collection.getNamespace(), decoder) .filter(collection.wrapAllowNull(filter)) .batchSize(findOptions.getBatchSize()) .skip(findOptions.getSkip()) .limit(findOptions.getLimit()) .maxAwaitTime(findOptions.getMaxAwaitTime(MILLISECONDS), MILLISECONDS) .maxTime(findOptions.getMaxTime(MILLISECONDS), MILLISECONDS) .modifiers(collection.wrapAllowNull(findOptions.getModifiers())) .projection(collection.wrapAllowNull(findOptions.getProjection())) .sort(collection.wrapAllowNull(findOptions.getSort())) .collation(findOptions.getCollation()) .comment(findOptions.getComment()) .hint(collection.wrapAllowNull(findOptions.getHint())) .min(collection.wrapAllowNull(findOptions.getMin())) .max(collection.wrapAllowNull(findOptions.getMax())) .returnKey(findOptions.isReturnKey()) .showRecordId(findOptions.isShowRecordId()); operation.cursorType(findOptions.getCursorType()); operation.oplogReplay(findOptions.isOplogReplay()); operation.noCursorTimeout(findOptions.isNoCursorTimeout()); operation.partial(findOptions.isPartial());
/** * Adds a modifier to the find operation * * @param key the modifier name * @param value the modifier value * @return this */ public FindOptions modifier(final String key, final Object value) { options.getModifiers().put(key, value); return this; }
private DBCollectionCountOptions getDbCollectionCountOptions() { DBCollectionCountOptions countOptions = new DBCollectionCountOptions() .readPreference(getReadPreferenceForCursor()) .readConcern(getReadConcern()) .collation(getCollation()) .maxTime(findOptions.getMaxTime(MILLISECONDS), MILLISECONDS); Object hint = findOptions.getHint() != null ? findOptions.getHint() : findOptions.getModifiers().get("$hint"); if (hint != null) { if (hint instanceof String) { countOptions.hintString((String) hint); } else { countOptions.hint((DBObject) hint); } } return countOptions; } }
/** * Gets the fields to be returned. * * @return the field selector that cursor used */ @Nullable public DBObject getKeysWanted() { return findOptions.getProjection(); }
/** * Counts the number of objects matching the query this does take limit/skip into consideration * * @return the number of objects * @throws MongoException if the operation failed * @see #count() */ public int size() { DBCollectionCountOptions countOptions = getDbCollectionCountOptions().skip(findOptions.getSkip()).limit(findOptions.getLimit()); return (int) collection.getCount(getQuery(), countOptions); }
/** * Get the read concern for this collection. * * @return the {@link com.mongodb.ReadConcern} * @since 3.2 * @mongodb.server.release 3.2 * @mongodb.driver.manual reference/readConcern/ Read Concern */ ReadConcern getReadConcern() { ReadConcern readConcern = findOptions.getReadConcern(); if (readConcern != null) { return readConcern; } return collection.getReadConcern(); }