T
- the type of document to decode query results toclass QueryProtocol<T> extends java.lang.Object implements LegacyProtocol<QueryResult<T>>
Modifier and Type | Class and Description |
---|---|
(package private) class |
QueryProtocol.QueryResultCallback |
Modifier and Type | Field and Description |
---|---|
private boolean |
awaitData |
private int |
batchSize |
private CommandListener |
commandListener |
private static java.lang.String |
EXPLAIN_COMMAND_NAME |
private BsonDocument |
fields |
private static java.lang.String |
FIND_COMMAND_NAME |
private int |
limit |
static Logger |
LOGGER |
private static java.util.Map<java.lang.String,java.lang.String> |
META_OPERATOR_TO_COMMAND_FIELD_MAP |
private MongoNamespace |
namespace |
private boolean |
noCursorTimeout |
private int |
numberToReturn |
private boolean |
oplogReplay |
private boolean |
partial |
private BsonDocument |
queryDocument |
private Decoder<T> |
resultDecoder |
private int |
skip |
private boolean |
slaveOk |
private boolean |
tailableCursor |
private boolean |
withLimitAndBatchSize |
Constructor and Description |
---|
QueryProtocol(MongoNamespace namespace,
int skip,
int numberToReturn,
BsonDocument queryDocument,
BsonDocument fields,
Decoder<T> resultDecoder) |
QueryProtocol(MongoNamespace namespace,
int skip,
int limit,
int batchSize,
BsonDocument queryDocument,
BsonDocument fields,
Decoder<T> resultDecoder) |
Modifier and Type | Method and Description |
---|---|
private BsonDocument |
asFindCommandDocument(ByteBufferBsonOutput bsonOutput,
int firstDocumentPosition) |
private BsonDocument |
asFindCommandResponseDocument(ResponseBuffers responseBuffers,
QueryResult<T> queryResult,
boolean isExplain) |
QueryProtocol<T> |
awaitData(boolean awaitData)
Sets if the cursor should await for data.
|
private QueryMessage |
createQueryMessage(ConnectionDescription connectionDescription) |
QueryResult<T> |
execute(InternalConnection connection) |
void |
executeAsync(InternalConnection connection,
SingleResultCallback<QueryResult<T>> callback) |
CommandListener |
getCommandListener() |
private java.lang.String |
getCommandName(boolean isExplainEvent) |
private int |
getNumberToReturn() |
boolean |
isAwaitData()
Returns true if the cursor should await for data.
|
boolean |
isNoCursorTimeout()
Returns true if cursor timeout has been turned off.
|
boolean |
isOplogReplay()
Internal replication use only.
|
boolean |
isPartial()
Returns true if can get partial results from a mongos if some shards are down.
|
boolean |
isSlaveOk()
Returns true if set to allowed to query non-primary replica set members.
|
boolean |
isTailableCursor()
Gets whether the cursor is configured to be a tailable cursor.
|
QueryProtocol<T> |
noCursorTimeout(boolean noCursorTimeout)
Sets if the cursor timeout should be turned off.
|
QueryProtocol<T> |
oplogReplay(boolean oplogReplay)
Internal replication use only.
|
QueryProtocol<T> |
partial(boolean partial)
Sets if partial results from a mongos if some shards are down are allowed
|
private boolean |
sendQueryStartedEvent(InternalConnection connection,
QueryMessage message,
ByteBufferBsonOutput bsonOutput,
RequestMessage.EncodingMetadata metadata) |
private void |
sendQuerySucceededEvent(ConnectionDescription connectionDescription,
long startTimeNanos,
QueryMessage message,
boolean isExplainEvent,
ResponseBuffers responseBuffers,
QueryResult<T> queryResult) |
void |
setCommandListener(CommandListener commandListener) |
QueryProtocol<T> |
slaveOk(boolean slaveOk)
Sets if allowed to query non-primary replica set members.
|
QueryProtocol<T> |
tailableCursor(boolean tailableCursor)
Sets whether the cursor should be a tailable cursor.
|
public static final Logger LOGGER
private static final java.lang.String FIND_COMMAND_NAME
private static final java.lang.String EXPLAIN_COMMAND_NAME
private final int skip
private final int limit
private final int batchSize
private final int numberToReturn
private final boolean withLimitAndBatchSize
private final BsonDocument queryDocument
private final BsonDocument fields
private final MongoNamespace namespace
private boolean tailableCursor
private boolean slaveOk
private boolean oplogReplay
private boolean noCursorTimeout
private boolean awaitData
private boolean partial
private CommandListener commandListener
private static final java.util.Map<java.lang.String,java.lang.String> META_OPERATOR_TO_COMMAND_FIELD_MAP
QueryProtocol(MongoNamespace namespace, int skip, int numberToReturn, BsonDocument queryDocument, BsonDocument fields, Decoder<T> resultDecoder)
QueryProtocol(MongoNamespace namespace, int skip, int limit, int batchSize, BsonDocument queryDocument, BsonDocument fields, Decoder<T> resultDecoder)
public void setCommandListener(CommandListener commandListener)
setCommandListener
in interface LegacyProtocol<QueryResult<T>>
public CommandListener getCommandListener()
public boolean isTailableCursor()
Tailable means the cursor is not closed when the last data is retrieved. Rather, the cursor marks the final object's position. You can resume using the cursor later, from where it was located, if more data were received. Like any "latent cursor", the cursor may become invalid at some point - for example if the final object it references were deleted.
public QueryProtocol<T> tailableCursor(boolean tailableCursor)
Tailable means the cursor is not closed when the last data is retrieved. Rather, the cursor marks the final object's position. You can resume using the cursor later, from where it was located, if more data were received. Like any "latent cursor", the cursor may become invalid at some point - for example if the final object it references were deleted.
tailableCursor
- whether the cursor should be a tailable cursor.public boolean isSlaveOk()
public QueryProtocol<T> slaveOk(boolean slaveOk)
slaveOk
- true if allowed to query non-primary replica set members.public boolean isOplogReplay()
public QueryProtocol<T> oplogReplay(boolean oplogReplay)
oplogReplay
- the oplogReplay valuepublic boolean isNoCursorTimeout()
The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use.
public QueryProtocol<T> noCursorTimeout(boolean noCursorTimeout)
noCursorTimeout
- true if the cursor timeout should be turned off.public boolean isAwaitData()
Use with tailableCursor
. If we are at the end of the data, block for a while rather than returning no data. After a
timeout period, we do return as normal.
public QueryProtocol<T> awaitData(boolean awaitData)
Use with tailableCursor
. If we are at the end of the data, block for a while rather than returning no data. After a
timeout period, we do return as normal.
awaitData
- if we should await for datapublic boolean isPartial()
public QueryProtocol<T> partial(boolean partial)
partial
- allow partial results from a mongos if some shards are downpublic QueryResult<T> execute(InternalConnection connection)
execute
in interface LegacyProtocol<QueryResult<T>>
public void executeAsync(InternalConnection connection, SingleResultCallback<QueryResult<T>> callback)
executeAsync
in interface LegacyProtocol<QueryResult<T>>
private boolean sendQueryStartedEvent(InternalConnection connection, QueryMessage message, ByteBufferBsonOutput bsonOutput, RequestMessage.EncodingMetadata metadata)
private java.lang.String getCommandName(boolean isExplainEvent)
private void sendQuerySucceededEvent(ConnectionDescription connectionDescription, long startTimeNanos, QueryMessage message, boolean isExplainEvent, ResponseBuffers responseBuffers, QueryResult<T> queryResult)
private QueryMessage createQueryMessage(ConnectionDescription connectionDescription)
private int getNumberToReturn()
private BsonDocument asFindCommandDocument(ByteBufferBsonOutput bsonOutput, int firstDocumentPosition)
private BsonDocument asFindCommandResponseDocument(ResponseBuffers responseBuffers, QueryResult<T> queryResult, boolean isExplain)