You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "yiguolei (via GitHub)" <gi...@apache.org> on 2023/04/24 10:59:28 UTC

[GitHub] [doris] yiguolei commented on a diff in pull request #19000: [Refactor](exceptionsafe) add factory creator to some class

yiguolei commented on code in PR #19000:
URL: https://github.com/apache/doris/pull/19000#discussion_r1175122379


##########
be/src/vec/exec/scan/vfile_scanner.cpp:
##########
@@ -574,40 +574,40 @@ Status VFileScanner::_get_next_reader() {
         // TODO: use data lake type
         switch (_params.format_type) {
         case TFileFormatType::FORMAT_PARQUET: {
-            ParquetReader* parquet_reader =
-                    new ParquetReader(_profile, _params, range, _state->query_options().batch_size,
-                                      const_cast<cctz::time_zone*>(&_state->timezone_obj()),
-                                      _io_ctx.get(), _state, _kv_cache);
+            std::unique_ptr<ParquetReader> parquet_reader = ParquetReader::create_unique(
+                    _profile, _params, range, _state->query_options().batch_size,
+                    const_cast<cctz::time_zone*>(&_state->timezone_obj()), _io_ctx.get(), _state,
+                    _kv_cache);
             RETURN_IF_ERROR(parquet_reader->open());
             if (!_is_load && _push_down_expr == nullptr && _vconjunct_ctx != nullptr) {
                 RETURN_IF_ERROR(_vconjunct_ctx->clone(_state, &_push_down_expr));
                 _discard_conjuncts();
             }
             if (range.__isset.table_format_params &&
                 range.table_format_params.table_format_type == "iceberg") {
-                IcebergTableReader* iceberg_reader =
-                        new IcebergTableReader((GenericReader*)parquet_reader, _profile, _state,
-                                               _params, range, _kv_cache, _io_ctx.get());
+                std::unique_ptr<IcebergTableReader> iceberg_reader =
+                        IcebergTableReader::create_unique(parquet_reader.get(), _profile, _state,

Review Comment:
   这里应该不对, 在577 行是一个unique ptr,结果iceberg reader 拿到的是裸指针,然后再596 行返回了,所以577 行的unique ptr 会析构调对象,就core了。
   你可以再589 行,用 std::move 把 parquet reader move 到iceberg reader 的构造方法里。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org