Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove the use of delete. using smart pointers #162

Merged
merged 1 commit into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading