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