26 namespace data_conversion {
28 template <
typename ScalarEncoderType>
31 typename ScalarEncoderType::MetadataType> {
37 const bool error_tracking_enabled)
40 error_tracking_enabled)
48 auto typed_data =
reinterpret_cast<const std::string_view*
>(data);
52 std::optional<std::vector<bool>> error_occurred = std::nullopt;
55 error_occurred = std::vector<bool>{};
56 error_occurred->reserve(num_elements);
61 encodeScalarData(num_elements, typed_data, default_copy_params, error_occurred);
63 auto current_data =
reinterpret_cast<int8_t*
>(
65 size_t current_scalar_offset = 0;
67 appendArrayDatums(num_elements, error_occurred, current_data, current_scalar_offset);
73 size_t current_scalar_offset) {
74 for (
size_t i = 0; i < num_elements; ++i) {
84 throw std::runtime_error(
"NULL value not allowed in NOT NULL column");
91 for (
size_t j = current_scalar_offset; j < current_scalar_offset + array_size;
94 (*error_occurred)[i] =
true;
98 current_scalar_offset += array_size;
110 throw std::runtime_error(
112 ") in array for fixed length array of size " +
117 if ((*error_occurred)[i]) {
155 const std::string_view* typed_data,
158 for (
size_t i = 0; i < num_elements; ++i) {
160 error_occurred->push_back(
false);
162 if (typed_data[i].empty()) {
172 std::string s{typed_data[i]};
174 s, default_copy_params,
array_,
false);
176 for (
const auto& s :
array_) {
179 }
catch (std::exception& except) {
181 error_occurred->back() =
true;
void encodeScalarData(const size_t num_elements, const std::string_view *typed_data, const import_export::CopyParams &default_copy_params, std::optional< std::vector< bool >> &error_occurred)
HOST DEVICE int get_size() const
bool is_varlen_array() const
static ArrayDatum composeNullArray(const SQLTypeInfo &ti)
SQLTypeInfo dst_type_info_
std::vector< bool > is_null_
StringViewToArrayEncoder(const Chunk_NS::Chunk &scalar_temp_chunk, const Chunk_NS::Chunk &dst_chunk, const bool error_tracking_enabled)
std::vector< std::string > array_
const Chunk_NS::Chunk & dst_chunk_
ScalarEncoderType scalar_encoder_
const ColumnDescriptor * getColumnDesc() const
bool is_fixlen_array() const
const Chunk_NS::Chunk & scalar_temp_chunk_
void appendArrayDatums(const size_t num_elements, std::optional< std::vector< bool >> &error_occurred, int8_t *current_data, size_t current_scalar_offset)
void parse_string_array(const std::string &s, const import_export::CopyParams ©_params, std::vector< std::string > &string_vec, bool truncate_values)
Parses given string array and inserts into given vector of strings.
An AbstractBuffer is a unit of data management for a data manager.
std::optional< std::vector< bool > > delete_buffer_
void encodeAndAppendData(const int8_t *data, const size_t num_elements) override
void clearLocalState(const size_t num_elements)
AbstractBuffer * getBuffer() const
typename ScalarEncoderType::DataType DstDataType
ScalarEncoderType::MetadataType MetadataType
unencoded fixed length array encoder
std::vector< ArrayDatum > array_datums_
Encoder * getEncoder() const
std::vector< std::string_view > array_views_
ScalarEncoderType::DataType DataType
HOST DEVICE bool get_notnull() const
const bool error_tracking_enabled_
std::vector< size_t > array_sizes_