Skip to content

Commit

Permalink
remove the use of delete. using unique/shared pointers
Browse files Browse the repository at this point in the history
Signed-off-by: Gal Salomon <[email protected]>
  • Loading branch information
galsalomon66 committed Jul 31, 2024
1 parent 2680e95 commit 224d1d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 29 deletions.
18 changes: 6 additions & 12 deletions include/s3select.h
Original file line number Diff line number Diff line change
Expand Up @@ -3020,7 +3020,7 @@ class parquet_object : public base_s3object
{

private:
parquet_file_parser* object_reader;
std::unique_ptr<parquet_file_parser> object_reader;
parquet_file_parser::column_pos_t m_where_clause_columns;
parquet_file_parser::column_pos_t m_projections_columns;
std::vector<parquet_file_parser::parquet_value_t> m_predicate_values;
Expand All @@ -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_parser>(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);
Expand All @@ -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)
Expand All @@ -3067,13 +3067,7 @@ class parquet_object : public base_s3object
}

~parquet_object()
{
if(object_reader != nullptr)
{
delete object_reader;
}

}
{}

std::string get_error_description()
{
Expand All @@ -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_parser>(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);
Expand Down
24 changes: 7 additions & 17 deletions include/s3select_parquet_intrf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<OSFile>();}
#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<RGWimpl>(rgw);}

Status Open(const std::string& path) { return IMPL->OpenReadable(path); }

Expand Down Expand Up @@ -649,7 +644,7 @@ class ReadableFile::ReadableFileImpl : public ObjectInterface {
return Status::OK();
}

ObjectInterface *IMPL;//TODO to declare in ObjectInterface
std::unique_ptr<ObjectInterface> IMPL;

private:

Expand Down Expand Up @@ -1588,7 +1583,7 @@ class parquet_file_parser
int m_num_row_groups;
std::shared_ptr<parquet::FileMetaData> m_file_metadata;
std::unique_ptr<parquet::ceph::ParquetFileReader> m_parquet_reader;
std::vector<column_reader_wrap*> m_column_readers;
std::vector<std::shared_ptr<column_reader_wrap>> m_column_readers;
s3selectEngine::rgw_s3select_api* m_rgw_s3select_api;

public:
Expand All @@ -1607,12 +1602,7 @@ class parquet_file_parser
}

~parquet_file_parser()
{
for(auto r : m_column_readers)
{
delete r;
}
}
{}

int load_meta_data()
{
Expand Down Expand Up @@ -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<column_reader_wrap>(m_parquet_reader,i));
}

return 0;
Expand Down

0 comments on commit 224d1d0

Please sign in to comment.