@@ -153,10 +153,7 @@ class TJsonParser::TImpl {
153
153
LOG_ROW_DISPATCHER_TRACE (" Parse values:\n " << values);
154
154
155
155
with_lock (Alloc) {
156
- for (auto & parsedColumn : ParsedValues) {
157
- parsedColumn.clear ();
158
- parsedColumn.reserve (Buffer.NumberValues );
159
- }
156
+ ClearColumns (Buffer.NumberValues );
160
157
161
158
size_t rowId = 0 ;
162
159
simdjson::ondemand::document_stream documents = Parser.iterate_many (values, size, simdjson::ondemand::DEFAULT_BATCH_SIZE);
@@ -173,6 +170,7 @@ class TJsonParser::TImpl {
173
170
174
171
try {
175
172
parsedColumn.emplace_back (ParseJsonValue (columnDesc.Type , item.value ()));
173
+ Alloc.Ref ().LockObject (parsedColumn.back ());
176
174
} catch (...) {
177
175
throw yexception () << " Failed to parse json string at offset " << Buffer.Offsets [rowId] << " , got parsing error for column '" << columnDesc.Name << " ' with type " << columnDesc.TypeYson << " , description: " << CurrentExceptionMessage ();
178
176
}
@@ -202,9 +200,20 @@ class TJsonParser::TImpl {
202
200
203
201
~TImpl () {
204
202
Alloc.Acquire ();
203
+ ClearColumns (0 );
205
204
}
206
205
207
206
private:
207
+ void ClearColumns (size_t reserveSize) {
208
+ for (auto & parsedColumn : ParsedValues) {
209
+ for (const auto & value : parsedColumn) {
210
+ Alloc.Ref ().UnlockObject (value);
211
+ }
212
+ parsedColumn.clear ();
213
+ parsedColumn.reserve (reserveSize);
214
+ }
215
+ }
216
+
208
217
void ResizeColumn (const TColumnDescription& columnDesc, NKikimr::NMiniKQL::TUnboxedValueVector& parsedColumn, size_t size) const {
209
218
if (columnDesc.Type ->IsOptional ()) {
210
219
parsedColumn.resize (size);
@@ -213,7 +222,7 @@ class TJsonParser::TImpl {
213
222
}
214
223
}
215
224
216
- NYql::NUdf::TUnboxedValue ParseJsonValue (const NKikimr::NMiniKQL::TType* type, simdjson::fallback::ondemand::value jsonValue) const {
225
+ NYql::NUdf::TUnboxedValuePod ParseJsonValue (const NKikimr::NMiniKQL::TType* type, simdjson::fallback::ondemand::value jsonValue) const {
217
226
switch (type->GetKind ()) {
218
227
case NKikimr::NMiniKQL::TTypeBase::EKind::Data: {
219
228
const auto * dataType = AS_TYPE (NKikimr::NMiniKQL::TDataType, type);
@@ -236,7 +245,7 @@ class TJsonParser::TImpl {
236
245
}
237
246
}
238
247
239
- NYql::NUdf::TUnboxedValue ParseJsonValue (NYql::NUdf::EDataSlot dataSlot, simdjson::fallback::ondemand::value jsonValue) const {
248
+ NYql::NUdf::TUnboxedValuePod ParseJsonValue (NYql::NUdf::EDataSlot dataSlot, simdjson::fallback::ondemand::value jsonValue) const {
240
249
const auto & typeInfo = NYql::NUdf::GetDataTypeInfo (dataSlot);
241
250
switch (jsonValue.type ()) {
242
251
case simdjson::fallback::ondemand::json_type::number: {
@@ -307,7 +316,7 @@ class TJsonParser::TImpl {
307
316
}
308
317
309
318
template <typename TResult, typename TJsonNumber>
310
- static NYql::NUdf::TUnboxedValue ParseJsonNumber (TJsonNumber number) {
319
+ static NYql::NUdf::TUnboxedValuePod ParseJsonNumber (TJsonNumber number) {
311
320
if (number < std::numeric_limits<TResult>::min () || std::numeric_limits<TResult>::max () < number) {
312
321
throw yexception () << " number is out of range" ;
313
322
}
0 commit comments