| 1244 | template <typename T> |
| 1245 | template <typename Converter> |
| 1246 | auto RleBitPackedDecoder<T>::GetSpaced(Converter converter, |
| 1247 | typename Converter::out_type* out, |
| 1248 | rle_size_t batch_size, |
| 1249 | const uint8_t* validity_bits, |
| 1250 | int64_t validity_bits_offset, |
| 1251 | rle_size_t null_count) -> rle_size_t { |
| 1252 | using ControlFlow = RleBitPackedParser::ControlFlow; |
| 1253 | |
| 1254 | ARROW_DCHECK_GT(batch_size, 0); |
| 1255 | |
| 1256 | auto batch = internal::BatchCounter::FromBatchSizeAndNulls(batch_size, null_count); |
| 1257 | |
| 1258 | if (ARROW_PREDICT_FALSE(batch.is_fully_null())) { |
| 1259 | converter.WriteZero(out, out + batch.null_remaining()); |
| 1260 | return batch.null_remaining(); |
| 1261 | } |
| 1262 | |
| 1263 | arrow::internal::BitRunReader validity_reader(validity_bits, validity_bits_offset, |
| 1264 | /*length=*/batch.total_remaining()); |
| 1265 | arrow::internal::BitRun validity_run = validity_reader.NextRun(); |
| 1266 | |
| 1267 | const auto check_and_handle_fully_null_remaining = [&]() { |
| 1268 | if (batch.is_fully_null()) { |
| 1269 | ARROW_DCHECK(validity_run.length == 0 || !validity_run.set); |
| 1270 | ARROW_DCHECK_GE(validity_run.length, batch.null_remaining()); |
| 1271 | |
| 1272 | converter.WriteZero(out, out + batch.null_remaining()); |
| 1273 | out += batch.null_remaining(); |
| 1274 | batch.AccrueReadNulls(batch.null_remaining()); |
| 1275 | } |
| 1276 | }; |
| 1277 | |
| 1278 | // Remaining from a previous call that would have left some unread data from a run. |
| 1279 | if (ARROW_PREDICT_FALSE(run_remaining() > 0)) { |
| 1280 | const auto read = internal::RunGetSpaced(&converter, out, batch.total_remaining(), |
| 1281 | batch.null_remaining(), value_bit_width_, |
| 1282 | &validity_reader, &validity_run, &decoder_); |
| 1283 | |
| 1284 | batch.AccrueReadNulls(read.null_read); |
| 1285 | batch.AccrueReadValues(read.values_read); |
| 1286 | out += read.values_read + read.null_read; |
| 1287 | |
| 1288 | // Either we fulfilled all the batch values to be read |
| 1289 | if (ARROW_PREDICT_FALSE(batch.values_remaining() == 0)) { |
| 1290 | // There may be remaining null if they are not greedily filled |
| 1291 | check_and_handle_fully_null_remaining(); |
| 1292 | return batch.total_read(); |
| 1293 | } |
| 1294 | |
| 1295 | // We finished the remaining run |
| 1296 | ARROW_DCHECK(run_remaining() == 0); |
| 1297 | } |
| 1298 | |
| 1299 | parser_.ParseWithCallable([&](auto run) { |
| 1300 | using RunDecoder = |
| 1301 | typename RleBitPackedDecoderGetRunDecoder<value_type, decltype(run)>::type; |
| 1302 | |
| 1303 | RunDecoder decoder(run, value_bit_width_); |
nothing calls this directly
no test coverage detected