@@ -161,20 +161,22 @@ class EncodeToBech32Representation : public IFunction
161161 bool have_witver = arguments.size () == 3 ;
162162 const ColumnPtr & col0 = arguments[0 ].column ;
163163 const ColumnPtr & col1 = arguments[1 ].column ;
164- const ColumnPtr & col2 = have_witver ? arguments[2 ].column : IColumn::Ptr () /* dummy */ ;
164+ ColumnPtr col2;
165+ if (have_witver)
166+ col2 = arguments[2 ].column ;
165167
166168 if (const ColumnString * col0_str_ptr = checkAndGetColumn<ColumnString>(col0.get ()))
167169 {
168170 const ColumnString::Chars & col0_vec = col0_str_ptr->getChars ();
169- const ColumnString::Offsets & col0_offsets = col0_str_ptr->getOffsets ();
171+ const ColumnString::Offsets * col0_offsets = & col0_str_ptr->getOffsets ();
170172
171173 return chooseCol1AndExecute (col0_vec, col0_offsets, col1, col2, input_rows_count, have_witver);
172174 }
173175
174176 if (const ColumnFixedString * col0_fstr_ptr = checkAndGetColumn<ColumnFixedString>(col0.get ()))
175177 {
176178 const ColumnString::Chars & col0_vec = col0_fstr_ptr->getChars ();
177- const ColumnString::Offsets & col0_offsets = PaddedPODArray<IColumn::Offset>() ; // dummy
179+ const ColumnString::Offsets * col0_offsets = nullptr ; // dummy
178180
179181 return chooseCol1AndExecute (col0_vec, col0_offsets, col1, col2, input_rows_count, have_witver, col0_fstr_ptr->getN ());
180182 }
@@ -186,7 +188,7 @@ class EncodeToBech32Representation : public IFunction
186188private:
187189 ColumnPtr chooseCol1AndExecute (
188190 const ColumnString::Chars & col0_vec,
189- const ColumnString::Offsets & col0_offsets,
191+ const ColumnString::Offsets * col0_offsets,
190192 const ColumnPtr & col1,
191193 const ColumnPtr & col2,
192194 const size_t input_rows_count,
@@ -196,15 +198,15 @@ class EncodeToBech32Representation : public IFunction
196198 if (const ColumnString * col1_str_ptr = checkAndGetColumn<ColumnString>(col1.get ()))
197199 {
198200 const ColumnString::Chars & col1_vec = col1_str_ptr->getChars ();
199- const ColumnString::Offsets & col1_offsets = col1_str_ptr->getOffsets ();
201+ const ColumnString::Offsets * col1_offsets = & col1_str_ptr->getOffsets ();
200202
201203 return execute (col0_vec, col0_offsets, col1_vec, col1_offsets, col2, input_rows_count, have_witver, col0_width);
202204 }
203205
204206 if (const ColumnFixedString * col1_fstr_ptr = checkAndGetColumn<ColumnFixedString>(col1.get ()))
205207 {
206208 const ColumnString::Chars & col1_vec = col1_fstr_ptr->getChars ();
207- const ColumnString::Offsets & col1_offsets = PaddedPODArray<IColumn::Offset>() ; // dummy
209+ const ColumnString::Offsets * col1_offsets = nullptr ; // dummy
208210
209211 return execute (
210212 col0_vec, col0_offsets, col1_vec, col1_offsets, col2, input_rows_count, have_witver, col0_width, col1_fstr_ptr->getN ());
@@ -215,9 +217,9 @@ class EncodeToBech32Representation : public IFunction
215217
216218 static ColumnPtr execute (
217219 const ColumnString::Chars & hrp_vec,
218- const ColumnString::Offsets & hrp_offsets,
220+ const ColumnString::Offsets * hrp_offsets,
219221 const ColumnString::Chars & data_vec,
220- const ColumnString::Offsets & data_offsets,
222+ const ColumnString::Offsets * data_offsets,
221223 const ColumnPtr & witver_col,
222224 const size_t input_rows_count,
223225 const bool have_witver = false ,
@@ -244,8 +246,8 @@ class EncodeToBech32Representation : public IFunction
244246
245247 for (size_t i = 0 ; i < input_rows_count; ++i)
246248 {
247- size_t hrp_new_offset = hrp_width == 0 ? hrp_offsets[i] : hrp_prev_offset + hrp_width;
248- size_t data_new_offset = data_width == 0 ? data_offsets[i] : data_prev_offset + data_width;
249+ size_t hrp_new_offset = hrp_width == 0 ? (* hrp_offsets) [i] : hrp_prev_offset + hrp_width;
250+ size_t data_new_offset = data_width == 0 ? (* data_offsets) [i] : data_prev_offset + data_width;
249251
250252 // NUL chars are used to pad fixed width strings, so we remove them here since they are not valid inputs anyway
251253 while (hrp_width > 0 && hrp_vec[hrp_new_offset - 1 ] == 0 && hrp_new_offset > hrp_prev_offset)
@@ -356,15 +358,15 @@ class DecodeFromBech32Representation : public IFunction
356358 if (const ColumnString * col = checkAndGetColumn<ColumnString>(column.get ()))
357359 {
358360 const ColumnString::Chars & in_vec = col->getChars ();
359- const ColumnString::Offsets & in_offsets = col->getOffsets ();
361+ const ColumnString::Offsets * in_offsets = & col->getOffsets ();
360362
361363 return execute (in_vec, in_offsets, input_rows_count);
362364 }
363365
364366 if (const ColumnFixedString * col_fix_string = checkAndGetColumn<ColumnFixedString>(column.get ()))
365367 {
366368 const ColumnString::Chars & in_vec = col_fix_string->getChars ();
367- const ColumnString::Offsets & in_offsets = PaddedPODArray<IColumn::Offset>() ; // dummy
369+ const ColumnString::Offsets * in_offsets = nullptr ; // dummy
368370
369371 return execute (in_vec, in_offsets, input_rows_count, col_fix_string->getN ());
370372 }
@@ -375,7 +377,7 @@ class DecodeFromBech32Representation : public IFunction
375377
376378private:
377379 static ColumnPtr
378- execute (const ColumnString::Chars & in_vec, const ColumnString::Offsets & in_offsets, size_t input_rows_count, size_t col_width = 0 )
380+ execute (const ColumnString::Chars & in_vec, const ColumnString::Offsets * in_offsets, size_t input_rows_count, size_t col_width = 0 )
379381 {
380382 auto col0_res = ColumnString::create ();
381383 auto col1_res = ColumnString::create ();
@@ -405,7 +407,7 @@ class DecodeFromBech32Representation : public IFunction
405407
406408 for (size_t i = 0 ; i < input_rows_count; ++i)
407409 {
408- size_t new_offset = col_width == 0 ? in_offsets[i] : prev_offset + col_width;
410+ size_t new_offset = col_width == 0 ? (* in_offsets) [i] : prev_offset + col_width;
409411
410412 // NUL chars are used to pad fixed width strings, so we remove them here since they are not valid inputs anyway
411413 while (col_width > 0 && in_vec[new_offset - 1 ] == 0 && new_offset > prev_offset)
0 commit comments