diff --git a/include/s3select.h b/include/s3select.h index 73691402..d4fe228b 100644 --- a/include/s3select.h +++ b/include/s3select.h @@ -3020,7 +3020,7 @@ class parquet_object : public base_s3object { private: - parquet_file_parser* object_reader; + std::unique_ptr object_reader; parquet_file_parser::column_pos_t m_where_clause_columns; parquet_file_parser::column_pos_t m_projections_columns; std::vector m_predicate_values; @@ -3032,11 +3032,11 @@ class parquet_object : public base_s3object class csv_definitions : public s3select_csv_definitions {}; - parquet_object(std::string parquet_file_name, s3select *s3_query,s3selectEngine::rgw_s3select_api* rgw) : base_s3object(s3_query),object_reader(nullptr) + parquet_object(std::string parquet_file_name, s3select *s3_query,s3selectEngine::rgw_s3select_api* rgw) : base_s3object(s3_query) { try{ - object_reader = new parquet_file_parser(parquet_file_name,rgw); //TODO uniq ptr + object_reader = std::make_unique(parquet_file_name,rgw); } catch(std::exception &e) { throw base_s3select_exception(std::string("failure while processing parquet meta-data ") + std::string(e.what()) ,base_s3select_exception::s3select_exp_en_t::FATAL); @@ -3045,7 +3045,7 @@ class parquet_object : public base_s3object parquet_query_setting(nullptr); } - parquet_object() : base_s3object(nullptr),object_reader(nullptr) + parquet_object() : base_s3object(nullptr) {} void parquet_query_setting(s3select *s3_query) @@ -3067,13 +3067,7 @@ class parquet_object : public base_s3object } ~parquet_object() - { - if(object_reader != nullptr) - { - delete object_reader; - } - - } + {} std::string get_error_description() { @@ -3089,7 +3083,7 @@ class parquet_object : public base_s3object { try{ m_csv_defintion = parquet; - object_reader = new parquet_file_parser(parquet_file_name,rgw); //TODO uniq ptr + object_reader = std::make_unique(parquet_file_name,rgw); } catch(std::exception &e) { throw base_s3select_exception(std::string("failure while processing parquet meta-data ") + std::string(e.what()) ,base_s3select_exception::s3select_exp_en_t::FATAL); diff --git a/include/s3select_parquet_intrf.h b/include/s3select_parquet_intrf.h index 7207796d..cac2b892 100644 --- a/include/s3select_parquet_intrf.h +++ b/include/s3select_parquet_intrf.h @@ -589,17 +589,12 @@ class ReadableFile::ReadableFileImpl : public ObjectInterface { public: ~ReadableFileImpl() - { - if(IMPL != nullptr) - { - delete IMPL; - } - } + {} #ifdef CEPH_USE_FS - explicit ReadableFileImpl(MemoryPool* pool) : pool_(pool) {IMPL=new OSFile();} + explicit ReadableFileImpl(MemoryPool* pool) : pool_(pool) {IMPL=std::make_unique();} #endif - explicit ReadableFileImpl(MemoryPool* pool,s3selectEngine::rgw_s3select_api* rgw) : pool_(pool) {IMPL=new RGWimpl(rgw);} + explicit ReadableFileImpl(MemoryPool* pool,s3selectEngine::rgw_s3select_api* rgw) : pool_(pool) {IMPL=std::make_unique(rgw);} Status Open(const std::string& path) { return IMPL->OpenReadable(path); } @@ -649,7 +644,7 @@ class ReadableFile::ReadableFileImpl : public ObjectInterface { return Status::OK(); } - ObjectInterface *IMPL;//TODO to declare in ObjectInterface + std::unique_ptr IMPL; private: @@ -1588,7 +1583,7 @@ class parquet_file_parser int m_num_row_groups; std::shared_ptr m_file_metadata; std::unique_ptr m_parquet_reader; - std::vector m_column_readers; + std::vector> m_column_readers; s3selectEngine::rgw_s3select_api* m_rgw_s3select_api; public: @@ -1607,12 +1602,7 @@ class parquet_file_parser } ~parquet_file_parser() - { - for(auto r : m_column_readers) - { - delete r; - } - } + {} int load_meta_data() { @@ -1662,7 +1652,7 @@ class parquet_file_parser } } - m_column_readers.push_back(new column_reader_wrap(m_parquet_reader,i)); + m_column_readers.push_back(std::make_shared(m_parquet_reader,i)); } return 0;