@@ -502,13 +502,13 @@ class ColumnIterator : ChunkingPolicy
502502 : mColumn {column},
503503 mCurrent {nullptr },
504504 mCurrentPos {nullptr },
505+ mGlobalOffset {nullptr },
505506 mLast {nullptr },
506507 mFirstIndex {0 },
507- mCurrentChunk {0 },
508- mOffset {0 }
508+ mCurrentChunk {0 }
509509 {
510510 auto array = getCurrentArray ();
511- mCurrent = reinterpret_cast <unwrap_t <T> const *>(array->values ()->data ()) + ( mOffset >> SCALE_FACTOR ) ;
511+ mCurrent = reinterpret_cast <unwrap_t <T> const *>(array->values ()->data ());
512512 mLast = mCurrent + array->length ();
513513 }
514514
@@ -524,21 +524,19 @@ class ColumnIterator : ChunkingPolicy
524524 {
525525 auto previousArray = getCurrentArray ();
526526 mFirstIndex += previousArray->length ();
527-
528527 mCurrentChunk ++;
529528 auto array = getCurrentArray ();
530- mCurrent = reinterpret_cast <unwrap_t <T> const *>(array->values ()->data ()) + ( mOffset >> SCALE_FACTOR ) - (mFirstIndex >> SCALE_FACTOR );
529+ mCurrent = reinterpret_cast <unwrap_t <T> const *>(array->values ()->data ()) - (mFirstIndex >> SCALE_FACTOR );
531530 mLast = mCurrent + array->length () + (mFirstIndex >> SCALE_FACTOR );
532531 }
533532
534533 void prevChunk () const
535534 {
536535 auto previousArray = getCurrentArray ();
537536 mFirstIndex -= previousArray->length ();
538-
539537 mCurrentChunk --;
540538 auto array = getCurrentArray ();
541- mCurrent = reinterpret_cast <unwrap_t <T> const *>(array->values ()->data ()) + ( mOffset >> SCALE_FACTOR ) - (mFirstIndex >> SCALE_FACTOR );
539+ mCurrent = reinterpret_cast <unwrap_t <T> const *>(array->values ()->data ()) - (mFirstIndex >> SCALE_FACTOR );
542540 mLast = mCurrent + array->length () + (mFirstIndex >> SCALE_FACTOR );
543541 }
544542
@@ -561,24 +559,24 @@ class ColumnIterator : ChunkingPolicy
561559 mCurrentChunk = mColumn ->num_chunks () - 1 ;
562560 auto array = getCurrentArray ();
563561 mFirstIndex = mColumn ->length () - array->length ();
564- mCurrent = reinterpret_cast <unwrap_t <T> const *>(array->values ()->data ()) + ( mOffset >> SCALE_FACTOR ) - (mFirstIndex >> SCALE_FACTOR );
562+ mCurrent = reinterpret_cast <unwrap_t <T> const *>(array->values ()->data ()) - (mFirstIndex >> SCALE_FACTOR );
565563 mLast = mCurrent + array->length () + (mFirstIndex >> SCALE_FACTOR );
566564 }
567565
568566 auto operator *() const
569567 requires std::same_as<bool , std::decay_t <T>>
570568 {
571569 checkSkipChunk ();
572- return (*(mCurrent - ( mOffset >> SCALE_FACTOR ) + ((*mCurrentPos + mOffset ) >> SCALE_FACTOR )) & (1 << ((*mCurrentPos + mOffset ) & 0x7 ))) != 0 ;
570+ return (*(mCurrent + ((*mCurrentPos + * mGlobalOffset ) >> SCALE_FACTOR )) & (1 << ((*mCurrentPos + * mGlobalOffset ) & (( 1 << SCALE_FACTOR ) - 1 ) ))) != 0 ;
573571 }
574572
575573 auto operator *() const
576574 requires ((!std::same_as<bool , std::decay_t <T>>) && std::same_as<arrow_array_for_t <T>, arrow::ListArray>)
577575 {
578576 checkSkipChunk ();
579577 auto list = std::static_pointer_cast<arrow::ListArray>(mColumn ->chunk (mCurrentChunk ));
580- auto offset = list->value_offset (*mCurrentPos - mFirstIndex );
581- auto length = list->value_length (*mCurrentPos - mFirstIndex );
578+ auto offset = list->value_offset (*mCurrentPos + * mGlobalOffset - mFirstIndex );
579+ auto length = list->value_length (*mCurrentPos + * mGlobalOffset - mFirstIndex );
582580 return gsl::span<unwrap_t <T> const >{mCurrent + mFirstIndex + offset, mCurrent + mFirstIndex + (offset + length)};
583581 }
584582
@@ -587,14 +585,14 @@ class ColumnIterator : ChunkingPolicy
587585 {
588586 checkSkipChunk ();
589587 auto array = std::static_pointer_cast<arrow::BinaryViewArray>(mColumn ->chunk (mCurrentChunk ));
590- return array->GetView (*mCurrentPos - mFirstIndex );
588+ return array->GetView (*mCurrentPos + * mGlobalOffset - mFirstIndex );
591589 }
592590
593591 decltype (auto ) operator *() const
594592 requires ((!std::same_as<bool , std::decay_t <T>>) && !std::same_as<arrow_array_for_t <T>, arrow::ListArray> && !std::same_as<arrow_array_for_t <T>, arrow::BinaryViewArray>)
595593 {
596594 checkSkipChunk ();
597- return *(mCurrent + (*mCurrentPos >> SCALE_FACTOR ));
595+ return *(mCurrent + (( *mCurrentPos + * mGlobalOffset ) >> SCALE_FACTOR ));
598596 }
599597
600598 // Move to the chunk which containts element pos
@@ -606,26 +604,26 @@ class ColumnIterator : ChunkingPolicy
606604
607605 mutable unwrap_t <T> const * mCurrent ;
608606 int64_t const * mCurrentPos ;
607+ uint64_t const * mGlobalOffset ;
609608 mutable unwrap_t <T> const * mLast ;
610609 arrow::ChunkedArray const * mColumn ;
611610 mutable int mFirstIndex ;
612611 mutable int mCurrentChunk ;
613- mutable int mOffset ;
614612
615613 private:
616614 void checkSkipChunk () const
617615 requires((ChunkingPolicy::chunked == true ) && std::same_as<arrow_array_for_t<T>, arrow::ListArray>)
618616 {
619617 auto list = std::static_pointer_cast<arrow::ListArray>(mColumn ->chunk (mCurrentChunk ));
620- if (O2_BUILTIN_UNLIKELY (*mCurrentPos - mFirstIndex >= list->length ())) {
618+ if (O2_BUILTIN_UNLIKELY (*mCurrentPos + * mGlobalOffset - mFirstIndex >= list->length ())) {
621619 nextChunk ();
622620 }
623621 }
624622
625623 void checkSkipChunk () const
626624 requires((ChunkingPolicy::chunked == true ) && !std::same_as<arrow_array_for_t<T>, arrow::ListArray>)
627625 {
628- if (O2_BUILTIN_UNLIKELY (((mCurrent + (*mCurrentPos >> SCALE_FACTOR )) >= mLast ))) {
626+ if (O2_BUILTIN_UNLIKELY (((mCurrent + (( *mCurrentPos + * mGlobalOffset ) >> SCALE_FACTOR )) >= mLast ))) {
629627 nextChunk ();
630628 }
631629 }
@@ -639,7 +637,6 @@ class ColumnIterator : ChunkingPolicy
639637 requires(std::same_as<arrow_array_for_t <T>, arrow::FixedSizeListArray>)
640638 {
641639 std::shared_ptr<arrow::Array> chunkToUse = mColumn ->chunk (mCurrentChunk );
642- mOffset = chunkToUse->offset ();
643640 chunkToUse = std::dynamic_pointer_cast<arrow::FixedSizeListArray>(chunkToUse)->values ();
644641 return std::static_pointer_cast<arrow_array_for_t <value_for_t <T>>>(chunkToUse);
645642 }
@@ -648,17 +645,14 @@ class ColumnIterator : ChunkingPolicy
648645 requires(std::same_as<arrow_array_for_t <T>, arrow::ListArray>)
649646 {
650647 std::shared_ptr<arrow::Array> chunkToUse = mColumn ->chunk (mCurrentChunk );
651- mOffset = chunkToUse->offset ();
652648 chunkToUse = std::dynamic_pointer_cast<arrow::ListArray>(chunkToUse)->values ();
653- mOffset = chunkToUse->offset ();
654649 return std::static_pointer_cast<arrow_array_for_t <value_for_t <T>>>(chunkToUse);
655650 }
656651
657652 auto getCurrentArray () const
658653 requires(!std::same_as<arrow_array_for_t <T>, arrow::FixedSizeListArray> && !std::same_as<arrow_array_for_t <T>, arrow::ListArray>)
659654 {
660655 std::shared_ptr<arrow::Array> chunkToUse = mColumn ->chunk (mCurrentChunk );
661- mOffset = chunkToUse->offset ();
662656 return std::static_pointer_cast<arrow_array_for_t <T>>(chunkToUse);
663657 }
664658};
@@ -1212,7 +1206,7 @@ struct TableIterator : IP, C... {
12121206 {
12131207 using namespace o2 ::soa;
12141208 auto f = framework::overloaded{
1215- [this ]<soa::is_persistent_column T>(T*) -> void { T::mColumnIterator .mCurrentPos = &this ->mRowIndex ; },
1209+ [this ]<soa::is_persistent_column T>(T*) -> void { T::mColumnIterator .mCurrentPos = &this ->mRowIndex ; T:: mColumnIterator . mGlobalOffset = & this -> mOffset ; },
12161210 [this ]<soa::is_dynamic_column T>(T*) -> void { bindDynamicColumn<T>(typename T::bindings_t {}); },
12171211 [this ]<typename T>(T*) -> void {},
12181212 };
@@ -3468,11 +3462,6 @@ struct Concat : Table<o2::aod::Hash<"CONC"_h>, o2::aod::Hash<"CONC/0"_h>, o2::ao
34683462 {
34693463 }
34703464
3471- Concat (std::vector<std::shared_ptr<arrow::Table>>&& tables)
3472- : Concat{ArrowHelpers::concatTables (std::move (tables))}
3473- {
3474- }
3475-
34763465 Concat (Ts const &... t)
34773466 : Concat{ArrowHelpers::concatTables ({t.asArrowTableRef ()...})}
34783467 {
@@ -3729,19 +3718,31 @@ class FilteredBase : public T
37293718 }
37303719 }
37313720
3732- inline void adoptSelection (gandiva::Selection const & selection)
3721+ template <typename S>
3722+ inline void adoptSelection (S)
3723+ {
3724+ }
3725+
3726+ template <typename S>
3727+ requires (std::same_as<std::decay_t <S>, gandiva::Selection>)
3728+ inline void adoptSelection (S selection)
37333729 {
37343730 mSelectedRows = getSpan (selection);
37353731 mCached = false ;
37363732 }
37373733
3738- inline void adoptSelection (SelectionVector&& selection)
3734+ template <typename S>
3735+ requires (std::same_as<std::decay_t <S>, SelectionVector>)
3736+ inline void adoptSelection (S selection)
37393737 {
37403738 mSelectedRowsCache = std::move (selection);
3739+ mSelectedRows = std::span{mSelectedRowsCache };
37413740 mCached = true ;
37423741 }
37433742
3744- inline void adoptSelection (std::span<int64_t const > const & selection)
3743+ template <typename S>
3744+ requires (std::same_as<std::decay_t <S>, std::span<int64_t const >>)
3745+ inline void adoptSelection (S selection)
37453746 {
37463747 mSelectedRows = selection;
37473748 mCached = false ;
@@ -3778,7 +3779,7 @@ class Filtered : public FilteredBase<T>
37783779 }
37793780
37803781 Filtered (std::vector<ArrowTableRef>&& tables, is_a_selection auto selection)
3781- : FilteredBase<T>{std::move (tables), selection} {}
3782+ : FilteredBase<T>{std::move (tables), std::forward< decltype ( selection)>(selection) } {}
37823783
37833784 Filtered<T> operator +(is_a_selection auto selection)
37843785 {
@@ -3908,7 +3909,7 @@ class Filtered<Filtered<T>> : public FilteredBase<typename T::table_t>
39083909 }
39093910
39103911 Filtered (std::vector<Filtered<T>>&& tables, is_a_selection auto selection)
3911- : FilteredBase<typename T::table_t >(std::move(extractTablesFromFiltered(tables)), selection)
3912+ : FilteredBase<typename T::table_t >(std::move(extractTablesFromFiltered(tables)), std::forward< decltype ( selection)>(selection) )
39123913 {
39133914 for (auto & table : tables) {
39143915 *this *= table;
0 commit comments