| 1292 | |
| 1293 | private: |
| 1294 | Status DecodeArrowDense(int num_values, int null_count, const uint8_t* valid_bits, |
| 1295 | int64_t valid_bits_offset, |
| 1296 | typename EncodingTraits<ByteArrayType>::Accumulator* out, |
| 1297 | int* out_num_values) { |
| 1298 | constexpr int32_t kBufferSize = 1024; |
| 1299 | int32_t indices[kBufferSize]; |
| 1300 | |
| 1301 | auto visit_binary_helper = [&](auto* helper) { |
| 1302 | const auto* dict_values = dictionary_->data_as<ByteArray>(); |
| 1303 | const int values_to_decode = num_values - null_count; |
| 1304 | int values_decoded = 0; |
| 1305 | int num_indices = 0; |
| 1306 | int pos_indices = 0; |
| 1307 | |
| 1308 | auto visit_bit_run = [&](int64_t position, int64_t length, bool valid) { |
| 1309 | if (valid) { |
| 1310 | while (length > 0) { |
| 1311 | if (num_indices == pos_indices) { |
| 1312 | // Refill indices buffer |
| 1313 | const auto max_batch_size = |
| 1314 | std::min<int32_t>(kBufferSize, values_to_decode - values_decoded); |
| 1315 | num_indices = idx_decoder_.GetBatch(indices, max_batch_size); |
| 1316 | if (ARROW_PREDICT_FALSE(num_indices < 1)) { |
| 1317 | return Status::Invalid("Invalid number of indices: ", num_indices); |
| 1318 | } |
| 1319 | pos_indices = 0; |
| 1320 | } |
| 1321 | const auto batch_size = std::min<int64_t>(num_indices - pos_indices, length); |
| 1322 | for (int64_t j = 0; j < batch_size; ++j) { |
| 1323 | const auto index = indices[pos_indices++]; |
| 1324 | RETURN_NOT_OK(IndexInBounds(index)); |
| 1325 | const auto& val = dict_values[index]; |
| 1326 | RETURN_NOT_OK(helper->AppendValue(val.ptr, static_cast<int32_t>(val.len))); |
| 1327 | } |
| 1328 | values_decoded += static_cast<int32_t>(batch_size); |
| 1329 | length -= static_cast<int32_t>(batch_size); |
| 1330 | } |
| 1331 | } else { |
| 1332 | for (int64_t i = 0; i < length; ++i) { |
| 1333 | helper->UnsafeAppendNull(); |
| 1334 | } |
| 1335 | } |
| 1336 | return Status::OK(); |
| 1337 | }; |
| 1338 | |
| 1339 | RETURN_NOT_OK( |
| 1340 | VisitBitRuns(valid_bits, valid_bits_offset, num_values, visit_bit_run)); |
| 1341 | *out_num_values = values_decoded; |
| 1342 | return Status::OK(); |
| 1343 | }; |
| 1344 | // The `len_` in the ByteArrayDictDecoder is the total length of the |
| 1345 | // RLE/Bit-pack encoded data size, so, we cannot use `len_` to reserve |
| 1346 | // space for binary data. |
| 1347 | return DispatchArrowBinaryHelper<ByteArrayType>( |
| 1348 | out, num_values, /*estimated_data_length=*/{}, visit_binary_helper); |
| 1349 | } |
| 1350 | |
| 1351 | template <typename BuilderType> |
nothing calls this directly
no test coverage detected