class DBCollectionImpl extends DBCollection
| Modifier and Type | Class and Description |
|---|---|
private class |
DBCollectionImpl.OrderedRunGenerator |
private class |
DBCollectionImpl.Run |
private class |
DBCollectionImpl.UnorderedRunGenerator |
| Modifier and Type | Field and Description |
|---|---|
private DBApiLayer |
db |
private java.lang.String |
namespace |
private static int |
QUERY_DOCUMENT_HEADROOM |
private static java.util.logging.Level |
TRACE_LEVEL |
private static java.util.logging.Logger |
TRACE_LOGGER |
_db, _fullName, _hintFields, _name, _objectClass, _options| Constructor and Description |
|---|
DBCollectionImpl(DBApiLayer db,
java.lang.String name) |
| Modifier and Type | Method and Description |
|---|---|
private void |
addBulkWriteResultToCommandResult(BulkWriteResult bulkWriteResult,
WriteRequest.Type type,
CommandResult commandResult) |
Cursor |
aggregate(java.util.List<DBObject> pipeline,
AggregationOptions options,
ReadPreference readPreference)
Method implements aggregation framework.
|
private void |
applyRulesForInsert(java.util.List<DBObject> list) |
void |
createIndex(DBObject keys,
DBObject options,
DBEncoder encoder)
Forces creation of an index on a set of fields, if one does not already exist.
|
void |
doapply(DBObject o)
Method to be overridden if you need to add any fields to a given document before saving it to the collection.
|
void |
drop()
Drops (deletes) this collection from the database.
|
(package private) BulkWriteResult |
executeBulkWriteOperation(boolean ordered,
java.lang.Boolean bypassDocumentValidation,
java.util.List<WriteRequest> writeRequests,
WriteConcern writeConcern,
DBEncoder encoder) |
(package private) QueryResultIterator |
find(DBObject ref,
DBObject fields,
int numToSkip,
int batchSize,
int limit,
int options,
ReadPreference readPref,
DBDecoder decoder)
Finds objects
|
(package private) QueryResultIterator |
find(DBObject ref,
DBObject fields,
int numToSkip,
int batchSize,
int limit,
int options,
ReadPreference readPref,
DBDecoder decoder,
DBEncoder encoder) |
protected DBObject |
findAndModifyImpl(DBObject query,
DBObject fields,
DBObject sort,
boolean remove,
DBObject update,
boolean returnNew,
boolean upsert,
java.lang.Boolean bypassDocumentValidation,
long maxTime,
java.util.concurrent.TimeUnit maxTimeUnit,
WriteConcern writeConcern)
Atomically modify and return a single document.
|
java.util.List<DBObject> |
getIndexInfo()
Return a list of the indexes for this collection.
|
private java.util.logging.Logger |
getLogger() |
private int |
getMaxWriteBatchSize(DBPort port) |
private MessageSettings |
getMessageSettings(DBPort port) |
private MongoNamespace |
getNamespace() |
private java.lang.Iterable<DBCollectionImpl.Run> |
getRunGenerator(boolean ordered,
java.lang.Boolean bypassDocumentValidation,
java.util.List<WriteRequest> writeRequests,
WriteConcern writeConcern,
DBEncoder encoder,
DBPort port) |
protected WriteResult |
insertImpl(java.util.List<DBObject> list,
WriteConcern concern,
DBEncoder encoder,
java.lang.Boolean bypassDocumentValidation)
Insert documents into a collection.
|
private BulkWriteResult |
insertWithCommandProtocol(java.util.List<DBObject> list,
WriteConcern writeConcern,
DBEncoder encoder,
DBPort port,
java.lang.Boolean bypassDocumentValidation) |
private WriteResult |
insertWithWriteProtocol(java.util.List<DBObject> list,
WriteConcern concern,
DBEncoder encoder,
DBPort port,
boolean shouldApply) |
java.util.List<Cursor> |
parallelScan(ParallelScanOptions options)
Return a list of cursors over the collection that can be used to scan it in parallel.
|
private BasicDBObject |
prepareFindAndModifyCommand(DBObject query,
DBObject fields,
DBObject sort,
boolean remove,
DBObject update,
boolean returnNew,
boolean upsert,
java.lang.Boolean bypassDocumentValidation,
long maxTime,
java.util.concurrent.TimeUnit maxTimeUnit,
WriteConcern writeConcern,
ServerVersion serverVersion) |
private CommandResult |
receiveWriteCommandMessage(DBPort port) |
WriteResult |
remove(DBObject query,
boolean multi,
WriteConcern concern,
DBEncoder encoder) |
WriteResult |
remove(DBObject query,
WriteConcern concern,
DBEncoder encoder)
Remove documents from a collection.
|
private BulkWriteResult |
removeWithCommandProtocol(java.util.List<RemoveRequest> removeList,
WriteConcern writeConcern,
DBEncoder encoder,
DBPort port) |
private BaseWriteCommandMessage |
sendWriteCommandMessage(BaseWriteCommandMessage message,
int batchNum,
DBPort port) |
private void |
throwIfBypassDocumentValidationNotSupported(WriteConcern concern,
java.lang.Boolean bypassDocumentValidation,
DBPort port) |
private void |
trace(java.lang.String s) |
private MongoException |
translateBulkWriteException(BulkWriteException e,
WriteRequest.Type type) |
private WriteResult |
translateBulkWriteResult(BulkWriteResult bulkWriteResult,
WriteRequest.Type type,
WriteConcern writeConcern,
ServerAddress serverAddress) |
protected WriteResult |
updateImpl(DBObject query,
DBObject o,
boolean upsert,
boolean multi,
WriteConcern concern,
java.lang.Boolean bypassDocumentValidation,
DBEncoder encoder)
Modify an existing document or documents in collection.
|
private BulkWriteResult |
updateWithCommandProtocol(java.util.List<ModifyRequest> updates,
WriteConcern writeConcern,
java.lang.Boolean bypassDocumentValidation,
DBEncoder encoder,
DBPort port) |
private boolean |
useWriteCommands(WriteConcern concern,
DBPort port) |
private boolean |
willTrace() |
private BulkWriteResult |
writeWithCommandProtocol(DBPort port,
WriteRequest.Type type,
BaseWriteCommandMessage message,
WriteConcern writeConcern) |
_checkObject, addOption, aggregate, aggregate, aggregate, aggregate, apply, apply, checkReadOnly, command, count, count, count, createIndex, createIndex, createIndex, createIndex, createIndex, defaultOptions, distinct, distinct, distinct, distinct, dropIndex, dropIndex, dropIndexes, dropIndexes, ensureIndex, ensureIndex, ensureIndex, ensureIndex, ensureIndex, equals, executeBulkWriteOperation, executeBulkWriteOperation, explainAggregate, find, find, find, find, find, findAndModify, findAndModify, findAndModify, findAndModify, findAndModify, findAndModify, findAndModify, findAndModify, findAndRemove, findOne, findOne, findOne, findOne, findOne, findOne, findOne, findOne, findOne, genIndexName, getBypassDocumentValidationForServerVersion, getCollection, getCount, getCount, getCount, getCount, getCount, getCount, getCount, getCount, getCount, getDB, getDBDecoderFactory, getDBEncoderFactory, getDecoder, getFullName, getHintFields, getInternalClass, getName, getObjectClass, getOptions, getReadPreference, getStats, getWriteConcern, group, group, group, group, group, group, hashCode, initializeOrderedBulkOperation, initializeUnorderedBulkOperation, insert, insert, insert, insert, insert, insert, insert, insert, insert, isCapped, mapReduce, mapReduce, mapReduce, mapReduce, mapReduce, prepareAggregationCommand, remove, remove, rename, rename, replaceWithObjectClass, resetIndexCache, resetOptions, save, save, setDBDecoderFactory, setDBEncoderFactory, setHintFields, setInternalClass, setObjectClass, setOptions, setReadPreference, setWriteConcern, slaveOk, toString, update, update, update, update, update, updateMultiprivate static final int QUERY_DOCUMENT_HEADROOM
private final DBApiLayer db
private final java.lang.String namespace
private static final java.util.logging.Logger TRACE_LOGGER
private static final java.util.logging.Level TRACE_LEVEL
DBCollectionImpl(DBApiLayer db, java.lang.String name)
QueryResultIterator find(DBObject ref, DBObject fields, int numToSkip, int batchSize, int limit, int options, ReadPreference readPref, DBDecoder decoder)
DBCollectionfind in class DBCollectionQueryResultIterator find(DBObject ref, DBObject fields, int numToSkip, int batchSize, int limit, int options, ReadPreference readPref, DBDecoder decoder, DBEncoder encoder)
find in class DBCollectionpublic Cursor aggregate(java.util.List<DBObject> pipeline, AggregationOptions options, ReadPreference readPreference)
DBCollectionaggregate in class DBCollectionpipeline - operations to be performed in the aggregation pipelineoptions - options to apply to the aggregationreadPreference - ReadPreference to be used for this operationpublic java.util.List<Cursor> parallelScan(ParallelScanOptions options)
DBCollectionReturn a list of cursors over the collection that can be used to scan it in parallel.
Note: As of MongoDB 2.6, this method will work against a mongod, but not a mongos.
parallelScan in class DBCollectionoptions - the parallel scan optionsBulkWriteResult executeBulkWriteOperation(boolean ordered, java.lang.Boolean bypassDocumentValidation, java.util.List<WriteRequest> writeRequests, WriteConcern writeConcern, DBEncoder encoder)
executeBulkWriteOperation in class DBCollectionprotected WriteResult insertImpl(java.util.List<DBObject> list, WriteConcern concern, DBEncoder encoder, java.lang.Boolean bypassDocumentValidation)
DBCollectioninsertImpl in class DBCollectionlist - a list of DBObject's to be insertedconcern - WriteConcern to be used during operationencoder - DBEncoder to use to serialise the documentsbypassDocumentValidation - whether to bypass document validation, or null if the server's default value should be usedpublic WriteResult remove(DBObject query, WriteConcern concern, DBEncoder encoder)
DBCollectionremove in class DBCollectionquery - the deletion criteria using query operators. Omit the query parameter or pass an empty document to delete all
documents in the collection.concern - WriteConcern to be used during operationencoder - DBEncoder to be usedpublic WriteResult remove(DBObject query, boolean multi, WriteConcern concern, DBEncoder encoder)
protected WriteResult updateImpl(DBObject query, DBObject o, boolean upsert, boolean multi, WriteConcern concern, java.lang.Boolean bypassDocumentValidation, DBEncoder encoder)
DBCollectionDBCollection.find(DBObject).updateImpl in class DBCollectionquery - the selection criteria for the updateo - the modifications to applyupsert - when true, inserts a document if no document matches the update query criteriamulti - when true, updates all documents in the collection that match the update query criteria, otherwise only updates oneconcern - WriteConcern to be used during operationbypassDocumentValidation - whether to bypass document validation, or null if the server's default should be usedencoder - the DBEncoder to useprotected DBObject findAndModifyImpl(DBObject query, DBObject fields, DBObject sort, boolean remove, DBObject update, boolean returnNew, boolean upsert, java.lang.Boolean bypassDocumentValidation, long maxTime, java.util.concurrent.TimeUnit maxTimeUnit, WriteConcern writeConcern)
DBCollectionfindAndModifyImpl in class DBCollectionquery - specifies the selection criteria for the modificationfields - a subset of fields to returnsort - determines which document the operation will modify if the query selects multiple documentsremove - when true, removes the selected documentupdate - performs an update of the selected documentreturnNew - when true, returns the modified document rather than the originalupsert - when true, operation creates a new document if the query returns no documentsbypassDocumentValidation - whether to bypass document validation, or null if unspecifiedmaxTime - the maximum time that the server will allow this operation to execute before killing it. A non-zero value requires
a server version >= 2.6maxTimeUnit - the unit that maxTime is specified inwriteConcern - the write concern to apply to the operationreturnNew is true, in which case it returns the document
after the changes were madeprivate BasicDBObject prepareFindAndModifyCommand(DBObject query, DBObject fields, DBObject sort, boolean remove, DBObject update, boolean returnNew, boolean upsert, java.lang.Boolean bypassDocumentValidation, long maxTime, java.util.concurrent.TimeUnit maxTimeUnit, WriteConcern writeConcern, ServerVersion serverVersion)
public void drop()
DBCollectiondrop in class DBCollectionpublic void doapply(DBObject o)
DBCollectiondoapply in class DBCollectiono - object to which to add the fieldsprivate WriteResult translateBulkWriteResult(BulkWriteResult bulkWriteResult, WriteRequest.Type type, WriteConcern writeConcern, ServerAddress serverAddress)
private MongoException translateBulkWriteException(BulkWriteException e, WriteRequest.Type type)
private void addBulkWriteResultToCommandResult(BulkWriteResult bulkWriteResult, WriteRequest.Type type, CommandResult commandResult)
public java.util.List<DBObject> getIndexInfo()
DBCollectiongetIndexInfo in class DBCollectionpublic void createIndex(DBObject keys, DBObject options, DBEncoder encoder)
DBCollectioncreateIndex in class DBCollectionkeys - a document that contains pairs with the name of the field or fields to index and order of the indexoptions - a document that controls the creation of the index.encoder - specifies the encoder that used during operationprivate BulkWriteResult insertWithCommandProtocol(java.util.List<DBObject> list, WriteConcern writeConcern, DBEncoder encoder, DBPort port, java.lang.Boolean bypassDocumentValidation)
private void applyRulesForInsert(java.util.List<DBObject> list)
private BulkWriteResult removeWithCommandProtocol(java.util.List<RemoveRequest> removeList, WriteConcern writeConcern, DBEncoder encoder, DBPort port)
private BulkWriteResult updateWithCommandProtocol(java.util.List<ModifyRequest> updates, WriteConcern writeConcern, java.lang.Boolean bypassDocumentValidation, DBEncoder encoder, DBPort port)
private BulkWriteResult writeWithCommandProtocol(DBPort port, WriteRequest.Type type, BaseWriteCommandMessage message, WriteConcern writeConcern)
private boolean useWriteCommands(WriteConcern concern, DBPort port)
private void throwIfBypassDocumentValidationNotSupported(WriteConcern concern, java.lang.Boolean bypassDocumentValidation, DBPort port)
private MessageSettings getMessageSettings(DBPort port)
private int getMaxWriteBatchSize(DBPort port)
private MongoNamespace getNamespace()
private BaseWriteCommandMessage sendWriteCommandMessage(BaseWriteCommandMessage message, int batchNum, DBPort port) throws java.io.IOException
java.io.IOExceptionprivate CommandResult receiveWriteCommandMessage(DBPort port) throws java.io.IOException
java.io.IOExceptionprivate WriteResult insertWithWriteProtocol(java.util.List<DBObject> list, WriteConcern concern, DBEncoder encoder, DBPort port, boolean shouldApply)
private java.lang.Iterable<DBCollectionImpl.Run> getRunGenerator(boolean ordered, java.lang.Boolean bypassDocumentValidation, java.util.List<WriteRequest> writeRequests, WriteConcern writeConcern, DBEncoder encoder, DBPort port)
private boolean willTrace()
private void trace(java.lang.String s)
private java.util.logging.Logger getLogger()