1010#include " storage/micro_partition_file_factory.h"
1111#include " storage/micro_partition_metadata.h"
1212
13+ #ifdef VEC_BUILD
14+ #include " storage/vec/pax_vec_reader.h"
15+ #endif
16+
1317namespace pax {
1418
1519static std::string GenRandomBlockId () {
@@ -182,65 +186,11 @@ bool TableReader::ReadTuple(CTupleSlot *slot) {
182186 }
183187 OpenFile ();
184188 }
185- num_tuples_++;
186- slot->SetTableNo (table_no_);
187- slot->SetBlockNumber (current_block_number_);
188- slot->StoreVirtualTuple ();
189- return true ;
190- }
191-
192- #ifdef VEC_BUILD
193- // TODO(jiaqizho): should remove this method but provider a
194- // new mirco partition reader which include adapter
195- bool TableReader::ReadVecTuple (CTupleSlot *slot, VecAdapter *adapter) {
196- size_t flush_nums_of_rows = 0 ;
197-
198- if (is_empty_) {
199- return false ;
200- }
201-
202- // Three conditions indicate that there is no data left
203- // - `VecAdapter` must be set
204- // - `VecAdapter` has consumed all buffer data
205- // - current have not next reader
206- if (adapter->IsInitialized () && adapter->IsEnd () && !iterator_->HasNext ()) {
207- return false ;
208- }
209-
210- Assert (reader_);
211-
212- // `No set` means that the first reader not setup in apapter
213- if (!adapter->IsInitialized ()) {
214- PaxColumns *pax_columns =
215- reinterpret_cast <OrcReader *>(reader_)->GetAllColumns ();
216- adapter->SetDataSource (pax_columns);
217- }
218-
219- // `VecAdapter` has consumed all buffer data
220- if (adapter->IsEnd ()) {
221- if (iterator_->HasNext ()) {
222- reader_->Close ();
223- OpenFile ();
224-
225- PaxColumns *pax_columns =
226- reinterpret_cast <OrcReader *>(reader_)->GetAllColumns ();
227- adapter->SetDataSource (pax_columns);
228- }
229- }
230-
231- auto ok = adapter->AppendToVecBuffer ();
232- CBDB_CHECK (ok, cbdb::CException::ExType::kExTypeLogicError );
233-
234- flush_nums_of_rows = adapter->FlushVecBuffer (slot);
235- Assert (flush_nums_of_rows);
236-
237- num_tuples_ += flush_nums_of_rows;
238189 slot->SetTableNo (table_no_);
239190 slot->SetBlockNumber (current_block_number_);
240191 slot->StoreVirtualTuple ();
241192 return true ;
242193}
243- #endif // VEC_BUILD
244194
245195void TableReader::OpenFile () {
246196 Assert (iterator_->HasNext ());
@@ -266,6 +216,14 @@ void TableReader::OpenFile() {
266216
267217 reader_ = new OrcReader (
268218 Singleton<LocalFileSystem>::GetInstance ()->Open (options.file_name ));
219+
220+ #ifdef VEC_BUILD
221+ if (reader_options_.is_vec ) {
222+ Assert (reader_options_.adapter );
223+ reader_ = new PaxVecReader (reader_, reader_options_.adapter );
224+ }
225+ #endif
226+
269227 reader_->Open (options);
270228}
271229
0 commit comments