@@ -1945,11 +1945,10 @@ class Table
19451945 }
19461946
19471947 Table (o2::soa::ArrowTableRef tableRef)
1948- : mTable (tableRef.tablePtr),
1949- mOffset (tableRef.offset),
1950- mEnd{tableRef.size }
1948+ : mArrowTableRef (tableRef),
1949+ mEnd {tableRef.range .size }
19511950 {
1952- if (mTable ->num_rows () == 0 ) {
1951+ if (mArrowTableRef . tablePtr ->num_rows () == 0 ) {
19531952 for (size_t ci = 0 ; ci < framework::pack_size (columns_t {}); ++ci) {
19541953 mColumnChunks [ci] = nullptr ;
19551954 }
@@ -1959,40 +1958,40 @@ class Table
19591958 for (size_t ci = 0 ; ci < framework::pack_size (columns_t {}); ++ci) {
19601959 mColumnChunks [ci] = lookups[ci];
19611960 }
1962- mBegin = unfiltered_iterator{mColumnChunks , {mEnd .index , mOffset }};
1961+ mBegin = unfiltered_iterator{mColumnChunks , {mEnd .index , mArrowTableRef . range . offset }};
19631962 mBegin .bindInternalIndices (this );
19641963 }
19651964 }
19661965
1967- Table (std::shared_ptr<arrow::Table> table, uint64_t offset = 0 )
1968- : mTable (table),
1969- mOffset (offset),
1970- mEnd{table->num_rows ()}
1971- {
1972- if (mTable ->num_rows () == 0 ) {
1973- for (size_t ci = 0 ; ci < framework::pack_size (columns_t {}); ++ci) {
1974- mColumnChunks [ci] = nullptr ;
1975- }
1976- mBegin = mEnd ;
1977- } else {
1978- auto lookups = [this ]<typename ... C>(framework::pack<C...>) -> std::array<arrow::ChunkedArray*, framework::pack_size (columns_t {})> { return {lookupColumn<C>()...}; }(columns_t {});
1979- for (size_t ci = 0 ; ci < framework::pack_size (columns_t {}); ++ci) {
1980- mColumnChunks [ci] = lookups[ci];
1981- }
1982- mBegin = unfiltered_iterator{mColumnChunks , {table->num_rows (), offset}};
1983- mBegin .bindInternalIndices (this );
1984- }
1985- }
1986-
1987- Table (std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t offset = 0 )
1966+ // Table(std::shared_ptr<arrow::Table> table, uint64_t offset = 0)
1967+ // : mTable(table),
1968+ // mOffset(offset),
1969+ // mEnd{table->num_rows()}
1970+ // {
1971+ // if (mTable->num_rows() == 0) {
1972+ // for (size_t ci = 0; ci < framework::pack_size(columns_t{}); ++ci) {
1973+ // mColumnChunks[ci] = nullptr;
1974+ // }
1975+ // mBegin = mEnd;
1976+ // } else {
1977+ // auto lookups = [this]<typename... C>(framework::pack<C...>) -> std::array<arrow::ChunkedArray*, framework::pack_size(columns_t{})> { return {lookupColumn<C>()...}; }(columns_t{});
1978+ // for (size_t ci = 0; ci < framework::pack_size(columns_t{}); ++ci) {
1979+ // mColumnChunks[ci] = lookups[ci];
1980+ // }
1981+ // mBegin = unfiltered_iterator{mColumnChunks, {table->num_rows(), offset}};
1982+ // mBegin.bindInternalIndices(this);
1983+ // }
1984+ // }
1985+
1986+ Table (std::vector<std::shared_ptr<arrow::Table>>&& tables, ArrowRange range )
19881987 requires (ref.origin_hash != " CONC" _h)
1989- : Table(ArrowHelpers::joinTables(std::move(tables), std::span{originalLabels}), offset )
1988+ : Table({ ArrowHelpers::joinTables (std::move (tables), std::span{originalLabels}), range} )
19901989 {
19911990 }
19921991
1993- Table (std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t offset = 0 )
1992+ Table (std::vector<std::shared_ptr<arrow::Table>>&& tables, ArrowRange range )
19941993 requires (ref.origin_hash == " CONC" _h)
1995- : Table(ArrowHelpers::concatTables(std::move(tables)), offset )
1994+ : Table({ ArrowHelpers::concatTables (std::move (tables)), range} )
19961995 {
19971996 }
19981997
@@ -2042,7 +2041,7 @@ class Table
20422041 // is held by the table, so we are safe passing the bare pointer. If it does it
20432042 // means that the iterator on a table is outliving the table itself, which is
20442043 // a bad idea.
2045- return filtered_iterator (mColumnChunks , {selection, mTable ->num_rows (), mOffset });
2044+ return filtered_iterator (mColumnChunks , {selection, mArrowTableRef . tablePtr ->num_rows (), mArrowTableRef . range . offset });
20462045 }
20472046
20482047 iterator iteratorAt (uint64_t i) const
@@ -2070,17 +2069,27 @@ class Table
20702069 // / Return a type erased arrow table backing store for / the type safe table.
20712070 [[nodiscard]] std::shared_ptr<arrow::Table> asArrowTable () const
20722071 {
2073- return mTable ;
2072+ return mArrowTableRef .tablePtr ;
2073+ }
2074+
2075+ [[nodiscard]] std::shared_ptr<arrow::Table> asArrowTableConstrained () const
2076+ {
2077+ return mArrowTableRef .tablePtr ->Slice (mArrowTableRef .range .offset , mArrowTableRef .range .size );
2078+ }
2079+
2080+ [[nodiscard]] ArrowTableRef asArrowTableRef () const
2081+ {
2082+ return mArrowTableRef ;
20742083 }
20752084 // / Return offset
20762085 auto offset () const
20772086 {
2078- return mOffset ;
2087+ return mArrowTableRef . range . offset ;
20792088 }
20802089 // / Size of the table, in rows.
20812090 [[nodiscard]] int64_t size () const
20822091 {
2083- return mTable ->num_rows ();
2092+ return mArrowTableRef . tablePtr ->num_rows ();
20842093 }
20852094
20862095 [[nodiscard]] int64_t tableSize () const
@@ -2166,27 +2175,30 @@ class Table
21662175
21672176 auto rawSlice (uint64_t start, uint64_t end) const
21682177 {
2169- return self_t {mTable -> Slice ( start, end - start + 1 ), start };
2178+ return self_t {mArrowTableRef . slice ({ start, static_cast < int64_t >( end - start + 1 )}) };
21702179 }
21712180
21722181 auto emptySlice () const
21732182 {
2174- return self_t {mTable -> Slice ( 0 , 0 ), 0 };
2183+ return self_t {mArrowTableRef . makeEmpty () };
21752184 }
21762185
21772186 private:
21782187 template <typename T>
21792188 arrow::ChunkedArray* lookupColumn ()
21802189 {
2181- if constexpr (soa::is_persistent_column<T>) {
2182- auto label = T::columnLabel ();
2183- return getIndexFromLabel (mTable .get (), label);
2184- } else {
2185- return nullptr ;
2186- }
2190+ return nullptr ;
21872191 }
2188- std::shared_ptr<arrow::Table> mTable = nullptr ;
2189- uint64_t mOffset = 0 ;
2192+
2193+ template <soa::is_persistent_column T>
2194+ arrow::ChunkedArray* lookupColumn ()
2195+ {
2196+ return getIndexFromLabel (mArrowTableRef .tablePtr .get (), T::columnLabel ());
2197+ }
2198+
2199+ ArrowTableRef mArrowTableRef ;
2200+ // std::shared_ptr<arrow::Table> mTable = nullptr;
2201+ // uint64_t mOffset = 0;
21902202 // Cached pointers to the ChunkedArray associated to a column
21912203 arrow::ChunkedArray* mColumnChunks [framework::pack_size(columns_t {})];
21922204 RowViewSentinel mEnd ;
0 commit comments