@@ -940,16 +940,23 @@ std::vector<std::shared_ptr<arrow::RecordBatch>> SliceToRecordBatches(const std:
940
940
for (auto && i : t->columns ()) {
941
941
ui32 currentPosition = 0 ;
942
942
auto it = i->chunks ().begin ();
943
- ui32 length = (*it)->length ();
943
+ ui32 length = 0 ;
944
+ const auto initializeIt = [&length, &it, &i]() {
945
+ for (; it != i->chunks ().end () && !(*it)->length (); ++it) {
946
+ }
947
+ if (it != i->chunks ().end ()) {
948
+ length = (*it)->length ();
949
+ }
950
+ };
951
+ initializeIt ();
944
952
for (ui32 idx = 0 ; idx + 1 < positions.size (); ++idx) {
953
+ AFL_VERIFY (it != i->chunks ().end ());
954
+ AFL_VERIFY (positions[idx + 1 ] - currentPosition <= length)(" length" , length)(" idx+1" , positions[idx + 1 ])(" pos" , currentPosition);
945
955
auto chunk = (*it)->Slice (positions[idx] - currentPosition, positions[idx + 1 ] - positions[idx]);
946
- AFL_VERIFY_DEBUG (chunk->length () == positions[idx + 1 ] - positions[idx])(" length" , chunk->length ())(
947
- " delta" , positions[idx + 1 ] - positions[idx]);
948
- AFL_VERIFY_DEBUG (chunk->length ())(" delta" , positions[idx + 1 ] - positions[idx]);
956
+ AFL_VERIFY_DEBUG (chunk->length () == positions[idx + 1 ] - positions[idx])(" length" , chunk->length ())(" expect" , positions[idx + 1 ] - positions[idx]);
949
957
if (positions[idx + 1 ] - currentPosition == length) {
950
- if (++it != i->chunks ().end ()) {
951
- length = (*it)->length ();
952
- }
958
+ ++it;
959
+ initializeIt ();
953
960
currentPosition = positions[idx + 1 ];
954
961
}
955
962
slicedData[idx].emplace_back (chunk);
@@ -958,8 +965,8 @@ std::vector<std::shared_ptr<arrow::RecordBatch>> SliceToRecordBatches(const std:
958
965
std::vector<std::shared_ptr<arrow::RecordBatch>> result;
959
966
ui32 count = 0 ;
960
967
for (auto && i : slicedData) {
961
- AFL_VERIFY_DEBUG (i.size ());
962
- AFL_VERIFY_DEBUG (i.front ()->length ());
968
+ AFL_VERIFY (i.size ());
969
+ AFL_VERIFY (i.front ()->length ());
963
970
result.emplace_back (arrow::RecordBatch::Make (t->schema (), i.front ()->length (), i));
964
971
count += result.back ()->num_rows ();
965
972
}
0 commit comments