| 1265 | } |
| 1266 | |
| 1267 | static Status Exec(KernelContext* ctx, const ExecSpan& batch, ExecResult* out) { |
| 1268 | const ArraySpan& in = batch[0].array; |
| 1269 | ARROW_ASSIGN_OR_RAISE(auto self, Make(ctx, *in.type)); |
| 1270 | |
| 1271 | ArraySpan* out_span = out->array_span_mutable(); |
| 1272 | int64_t* out_data = out_span->GetValues<int64_t>(1); |
| 1273 | |
| 1274 | if (self.error_is_null) { |
| 1275 | // Set all values to non-null, and only clear bits when there is a |
| 1276 | // parsing error |
| 1277 | bit_util::SetBitmap(out_span->buffers[0].data, out_span->offset, out_span->length); |
| 1278 | |
| 1279 | int64_t null_count = 0; |
| 1280 | arrow::internal::BitmapWriter out_writer(out_span->buffers[0].data, |
| 1281 | out_span->offset, out_span->length); |
| 1282 | auto visit_null = [&]() { |
| 1283 | *out_data++ = 0; |
| 1284 | out_writer.Clear(); |
| 1285 | out_writer.Next(); |
| 1286 | null_count++; |
| 1287 | }; |
| 1288 | auto visit_value = [&](std::string_view s) { |
| 1289 | int64_t result; |
| 1290 | if ((*self.parser)(s.data(), s.size(), self.unit, &result)) { |
| 1291 | *out_data++ = result; |
| 1292 | } else { |
| 1293 | *out_data++ = 0; |
| 1294 | out_writer.Clear(); |
| 1295 | null_count++; |
| 1296 | } |
| 1297 | out_writer.Next(); |
| 1298 | }; |
| 1299 | VisitArraySpanInline<InType>(in, visit_value, visit_null); |
| 1300 | out_writer.Finish(); |
| 1301 | out_span->null_count = null_count; |
| 1302 | } else { |
| 1303 | if (in.buffers[0].data != nullptr) { |
| 1304 | ::arrow::internal::CopyBitmap(in.buffers[0].data, in.offset, in.length, |
| 1305 | out_span->buffers[0].data, out_span->offset); |
| 1306 | } else { |
| 1307 | // Input is all non-null |
| 1308 | bit_util::SetBitmap(out_span->buffers[0].data, out_span->offset, |
| 1309 | out_span->length); |
| 1310 | } |
| 1311 | auto visit_null = [&]() { |
| 1312 | *out_data++ = 0; |
| 1313 | return Status::OK(); |
| 1314 | }; |
| 1315 | auto visit_value = [&](std::string_view s) { |
| 1316 | int64_t result; |
| 1317 | if ((*self.parser)(s.data(), s.size(), self.unit, &result)) { |
| 1318 | *out_data++ = result; |
| 1319 | return Status::OK(); |
| 1320 | } else { |
| 1321 | return Status::Invalid("Failed to parse string: '", s, "' as a scalar of type ", |
| 1322 | TimestampType(self.unit).ToString()); |
| 1323 | } |
| 1324 | }; |
nothing calls this directly
no test coverage detected