예제 #1
0
static mongoc_cursor_state_t
_get_next_batch (mongoc_cursor_t *cursor)
{
   data_find_opquery_t *data = (data_find_opquery_t *) cursor->impl.data;
   _mongoc_cursor_op_getmore (cursor, &data->response_legacy);
   return IN_BATCH;
}
static bool
_mongoc_cursor_cursorid_get_more (mongoc_cursor_t *cursor)
{
   mongoc_cursor_cursorid_t *cid;
   mongoc_server_stream_t *server_stream;
   bson_t command;
   bool ret;

   ENTRY;

   cid = (mongoc_cursor_cursorid_t *)cursor->iface_data;
   BSON_ASSERT (cid);

   server_stream = _mongoc_cursor_fetch_stream (cursor);

   if (!server_stream) {
      RETURN (false);
   }

   if (_use_find_command (cursor, server_stream)) {
      if (!_mongoc_cursor_prepare_getmore_command (cursor, &command)) {
         mongoc_server_stream_cleanup (server_stream);
         RETURN (false);
      }

      ret = _mongoc_cursor_cursorid_refresh_from_command (cursor, &command);
      bson_destroy (&command);
   } else {
      ret = _mongoc_cursor_op_getmore (cursor, server_stream);
      cid->in_reader = ret;
   }

   mongoc_server_stream_cleanup (server_stream);
   RETURN (ret);
}
예제 #3
0
static mongoc_cursor_state_t
_get_next_batch (mongoc_cursor_t *cursor)
{
   data_cmd_t *data = (data_cmd_t *) cursor->impl.data;
   bson_t getmore_cmd;
   getmore_type_t getmore_type = _getmore_type (cursor);

   switch (getmore_type) {
   case GETMORE_CMD:
      _mongoc_cursor_prepare_getmore_command (cursor, &getmore_cmd);
      _mongoc_cursor_response_refresh (
         cursor, &getmore_cmd, NULL /* opts */, &data->response);
      bson_destroy (&getmore_cmd);
      data->reading_from = CMD_RESPONSE;
      return IN_BATCH;
   case OP_GETMORE:
      _mongoc_cursor_op_getmore (cursor, &data->response_legacy);
      data->reading_from = OP_GETMORE_RESPONSE;
      return IN_BATCH;
   case UNKNOWN:
   default:
      return DONE;
   }
}