use of com.eightkdata.mongowp.messages.response.ReplyMessage in project torodb by torodb.
the class TorodbSafeRequestProcessor method query.
@Override
public ReplyMessage query(MongodConnection connection, Request req, int requestId, QueryRequest queryRequest) throws MongoException {
FindArgument findArg = new FindArgument.Builder().setCollection(queryRequest.getCollection()).setFilter(queryRequest.getQuery() != null ? queryRequest.getQuery() : DefaultBsonValues.EMPTY_DOC).build();
Status<FindResult> status = execute(req, FindCommand.INSTANCE, findArg, connection);
if (!status.isOk()) {
throw new MongoException(status.getErrorCode(), status.getErrorMsg());
}
FindResult result = status.getResult();
assert result != null;
return new ReplyMessage(EmptyBsonContext.getInstance(), requestId, false, false, false, false, result.getCursor().getCursorId(), queryRequest.getNumberToSkip(), IterableDocumentProvider.of(Lists.newArrayList(result.getCursor().getFirstBatch())));
}
Aggregations