File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,8 +57,8 @@ class ColumnDispatcher
5757
5858 virtual void * getCurValueUntyped () = 0;
5959
60- ::arrow::Type::type m_arrowTypeId;
61- std::string m_columnName;
60+ const ::arrow::Type::type m_arrowTypeId;
61+ const std::string m_columnName;
6262};
6363
6464// Factory: create a typed ColumnDispatcher for an arrow field.
Original file line number Diff line number Diff line change @@ -102,22 +102,7 @@ void RecordBatchRowProcessor::bindSources(
102102 }
103103
104104 // Pull first non-empty batch
105- for ( ;; )
106- {
107- auto status = entry.source -> ReadNext ( &entry.currentBatch );
108- CSP_TRUE_OR_THROW_RUNTIME ( status.ok (),
109- " bindSources: failed to read first batch: " << status.ToString () );
110-
111- if ( !entry.currentBatch )
112- break ;
113-
114- entry.numRows = entry.currentBatch -> num_rows ();
115- entry.currentRow = 0 ;
116- rebindSource ( entry );
117-
118- if ( entry.numRows > 0 )
119- break ;
120- }
105+ fetchNextBatch ( entry );
121106
122107 m_sources.push_back ( std::move ( entry ) );
123108 }
@@ -143,8 +128,9 @@ bool RecordBatchRowProcessor::fetchNextBatch( SourceEntry & entry )
143128
144129void RecordBatchRowProcessor::rebindSource ( SourceEntry & entry )
145130{
131+ auto & cols = entry.currentBatch -> columns ();
146132 for ( size_t i = 0 ; i < entry.dispatchers .size (); ++i )
147- entry.dispatchers [i] -> bindColumn ( entry.currentBatch -> column ( entry. colIndices [i] ) .get () );
133+ entry.dispatchers [i] -> bindColumn ( cols[ entry.colIndices [i]] .get () );
148134}
149135
150136bool RecordBatchRowProcessor::skipRow ()
Original file line number Diff line number Diff line change @@ -31,16 +31,6 @@ class RecordBatchRowProcessor
3131 int colIndex;
3232 };
3333
34- struct SourceEntry
35- {
36- ::arrow::RecordBatchReader * source = nullptr ;
37- std::shared_ptr<::arrow::RecordBatch> currentBatch;
38- int64_t numRows = 0 ;
39- int64_t currentRow = 0 ;
40- std::vector<int > colIndices;
41- std::vector<ColumnDispatcher *> dispatchers;
42- };
43-
4434 RecordBatchRowProcessor () = default ;
4535
4636 // (Re)create dispatchers for the given schema and requested columns.
@@ -74,6 +64,16 @@ class RecordBatchRowProcessor
7464 bool readRowAndAdvance ();
7565
7666private:
67+ struct SourceEntry
68+ {
69+ ::arrow::RecordBatchReader * source = nullptr ;
70+ std::shared_ptr<::arrow::RecordBatch> currentBatch;
71+ int64_t numRows = 0 ;
72+ int64_t currentRow = 0 ;
73+ std::vector<int > colIndices;
74+ std::vector<ColumnDispatcher *> dispatchers;
75+ };
76+
7777 std::vector<std::unique_ptr<ColumnDispatcher>> m_dispatchers;
7878 std::unordered_map<std::string, ColumnDispatcher *> m_nameToDispatcher;
7979 std::vector<SourceEntry> m_sources;
You can’t perform that action at this time.
0 commit comments