From 9e411c3e67905631b2fce80916d353f42ede1a59 Mon Sep 17 00:00:00 2001 From: gal salomon Date: Thu, 17 Mar 2022 22:37:12 +0200 Subject: [PATCH] replace chunkalloc with std::pmr, resolve big-rows issue in case of star-operation Signed-off-by: gal salomon --- CMakeLists.txt | 2 +- include/s3select_oper.h | 28 +++++++++++++--------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3906450c..a4357abc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ if(Arrow_FOUND) add_definitions(-D_ARROW_EXIST) endif() -set(CMAKE_CXX_FLAGS "-std=gnu++17 -ggdb -Wnon-virtual-dtor -Wreorder -Wunused-variable -Wtype-limits -Wsign-compare -Wmaybe-uninitialized") +set(CMAKE_CXX_FLAGS "-std=gnu++2a -ggdb -Wnon-virtual-dtor -Wreorder -Wunused-variable -Wtype-limits -Wsign-compare -Wmaybe-uninitialized") set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/include/s3select_oper.h b/include/s3select_oper.h index 0c5181cb..3b741c53 100644 --- a/include/s3select_oper.h +++ b/include/s3select_oper.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -104,7 +105,8 @@ class base_statement; //typedef std::vector bs_stmt_vec_t; //without specific allocator //ChunkAllocator, prevent allocation from heap. -typedef std::vector > bs_stmt_vec_t; +//typedef std::vector > bs_stmt_vec_t; +typedef std::pmr::vector bs_stmt_vec_t; class base_s3select_exception { @@ -416,10 +418,10 @@ class value private: value_t __val; - //std::string m_to_string; - std::basic_string,ChunkAllocator> m_to_string; - //std::string m_str_value; - std::basic_string,ChunkAllocator> m_str_value; + std::string m_to_string; + //std::basic_string,ChunkAllocator> m_to_string; + std::string m_str_value; + //std::basic_string,ChunkAllocator> m_str_value; public: enum class value_En_t @@ -1003,7 +1005,7 @@ class scratch_area scratch_area():m_upper_bound(-1),parquet_type(false),buff_loc(0) { - m_schema_values = new std::vector(128,value("")); + m_schema_values = new std::vector(128); } ~scratch_area() @@ -1364,9 +1366,8 @@ class variable : public base_statement std::string _name; int column_pos; value var_value; - std::string m_star_op_result; char m_star_op_result_charc[4096]; //TODO cause larger allocations for other objects containing variable (dynamic is one solution) - value star_operation_values[16];//TODO cause larger allocations for other objects containing variable (dynamic is one solution) + std::vector star_operation_values; const int undefined_column_pos = -1; const int column_alias = -2; @@ -1516,11 +1517,7 @@ class variable : public base_statement size_t num_of_columns = m_scratch->get_num_of_columns(); var_value.multiple_values.clear(); //TODO var_value.clear()?? - if(sizeof(star_operation_values)/sizeof(value) < num_of_columns) - { - throw base_s3select_exception(std::string("not enough memory for star-operation"), base_s3select_exception::s3select_exp_en_t::FATAL); - } - + star_operation_values.reserve(num_of_columns); for(size_t i=0; iget_column_value(i).size(); @@ -1532,8 +1529,9 @@ class variable : public base_statement memcpy(&m_star_op_result_charc[pos], m_scratch->get_column_value(i).data(), len);//TODO using string_view will avoid copy m_star_op_result_charc[ pos + len ] = 0; - star_operation_values[i] = &m_star_op_result_charc[pos];//set string value - var_value.multiple_values.push_value( &star_operation_values[i] ); + value v1(m_star_op_result_charc+pos); + star_operation_values.push_back(v1); + var_value.multiple_values.push_value( &star_operation_values.back() ); pos += len; pos ++;