@@ -42,12 +42,6 @@ class Table;
4242class Array ;
4343} // namespace arrow
4444
45- template <typename T>
46- struct BulkInfo {
47- const T ptr;
48- size_t size;
49- };
50-
5145extern template class arrow ::NumericBuilder<arrow::UInt8Type>;
5246extern template class arrow ::NumericBuilder<arrow::UInt32Type>;
5347extern template class arrow ::NumericBuilder<arrow::FloatType>;
@@ -200,34 +194,6 @@ struct BuilderUtils {
200194 }
201195 }
202196
203- template <typename HolderType, typename PTR>
204- static arrow::Status bulkAppend (HolderType& holder, size_t bulkSize, const PTR ptr)
205- {
206- return holder.builder ->AppendValues (ptr, bulkSize, nullptr );
207- }
208-
209- template <typename HolderType, typename PTR>
210- static arrow::Status bulkAppendChunked (HolderType& holder, BulkInfo<PTR> info)
211- {
212- // Appending nullptr is a no-op.
213- if (info.ptr == nullptr ) {
214- return arrow::Status::OK ();
215- }
216- if constexpr (std::is_same_v<decltype (holder.builder ), std::unique_ptr<arrow::FixedSizeListBuilder>>) {
217- if (appendToList<std::remove_pointer_t <decltype (info.ptr )>>(holder.builder , info.ptr , info.size ).ok () == false ) {
218- throw runtime_error (" Unable to append to column" );
219- } else {
220- return arrow::Status::OK ();
221- }
222- } else {
223- if (holder.builder ->AppendValues (info.ptr , info.size , nullptr ).ok () == false ) {
224- throw runtime_error (" Unable to append to column" );
225- } else {
226- return arrow::Status::OK ();
227- }
228- }
229- }
230-
231197 template <typename HolderType, typename ITERATOR>
232198 static arrow::Status append (HolderType& holder, std::pair<ITERATOR, ITERATOR> ip)
233199 {
@@ -518,14 +484,6 @@ struct TableBuilderHelpers {
518484 return {BuilderTraits<ARGS>::make_datatype ()...};
519485 }
520486
521- template <typename ... ARGS, size_t NCOLUMNS = sizeof ...(ARGS)>
522- static std::vector<std::shared_ptr<arrow::Field>> makeFields (std::array<char const *, NCOLUMNS> const & names)
523- {
524- char const * const * names_ptr = names.data ();
525- return {
526- std::make_shared<arrow::Field>(*names_ptr++, BuilderMaker<ARGS>::make_datatype (), true , nullptr )...};
527- }
528-
529487 // / Invokes the append method for each entry in the tuple
530488 template <typename ... Ts, typename VALUES>
531489 static bool append (std::tuple<Ts...>& holders, VALUES&& values)
@@ -542,19 +500,6 @@ struct TableBuilderHelpers {
542500 (BuilderUtils::unsafeAppend (std::get<Ts::index>(holders), std::get<Ts::index>(values)), ...);
543501 }
544502
545- template <typename ... Ts, typename PTRS>
546- static bool bulkAppend (std::tuple<Ts...>& holders, size_t bulkSize, PTRS ptrs)
547- {
548- return (BuilderUtils::bulkAppend (std::get<Ts::index>(holders), bulkSize, std::get<Ts::index>(ptrs)).ok () && ...);
549- }
550-
551- // / Return true if all columns are done.
552- template <typename ... Ts, typename INFOS>
553- static bool bulkAppendChunked (std::tuple<Ts...>& holders, INFOS infos)
554- {
555- return (BuilderUtils::bulkAppendChunked (std::get<Ts::index>(holders), std::get<Ts::index>(infos)).ok () && ...);
556- }
557-
558503 // / Invokes the append method for each entry in the tuple
559504 template <typename ... Ts>
560505 static bool finalize (std::vector<std::shared_ptr<arrow::Array>>& arrays, std::tuple<Ts...>& holders)
@@ -575,15 +520,9 @@ constexpr auto tuple_to_pack(std::tuple<ARGS...>&&)
575520 return framework::pack<ARGS...>{};
576521}
577522
578- template <typename T>
579- concept BulkInsertable = (std::integral<std::decay<T>> && !std::same_as<bool , std::decay_t <T>>);
580-
581523template <typename T>
582524struct InsertionTrait {
583- static consteval DirectInsertion<T> policy ()
584- requires(!BulkInsertable<T>);
585- static consteval CachedInsertion<T> policy ()
586- requires(BulkInsertable<T>);
525+ static consteval DirectInsertion<T> policy ();
587526 using Policy = decltype (policy());
588527};
589528
@@ -658,7 +597,9 @@ class TableBuilder
658597 template <typename ... ARGS, size_t I = sizeof ...(ARGS)>
659598 auto makeBuilders (std::array<char const *, I> const & columnNames, size_t nRows)
660599 {
661- mSchema = std::make_shared<arrow::Schema>(TableBuilderHelpers::makeFields<ARGS...>(columnNames));
600+ char const * const * names_ptr = columnNames.data ();
601+ mSchema = std::make_shared<arrow::Schema>(
602+ std::vector<std::shared_ptr<arrow::Field>>({std::make_shared<arrow::Field>(*names_ptr++, BuilderMaker<ARGS>::make_datatype (), true , nullptr )...}));
662603
663604 mHolders = makeHolders<ARGS...>(mMemoryPool , nRows);
664605 mFinalizer = [](std::vector<std::shared_ptr<arrow::Array>>& arrays, void * holders) -> bool {
@@ -768,45 +709,6 @@ class TableBuilder
768709 }(typename T::table_t ::persistent_columns_t {});
769710 }
770711
771- template <typename ... ARGS, size_t NCOLUMNS = sizeof ...(ARGS)>
772- auto preallocatedPersist (std::array<char const *, NCOLUMNS> const & columnNames, int nRows)
773- {
774- constexpr size_t nColumns = NCOLUMNS;
775- validate ();
776- mArrays .resize (nColumns);
777- makeBuilders<ARGS...>(columnNames, nRows);
778-
779- // Callback used to fill the builders
780- return [holders = mHolders ](unsigned int /* slot*/ , typename BuilderMaker<ARGS>::FillType... args) -> void {
781- TableBuilderHelpers::unsafeAppend (*(HoldersTupleIndexed<ARGS...>*)holders, std::forward_as_tuple (args...));
782- };
783- }
784-
785- template <typename ... ARGS, size_t NCOLUMNS = sizeof ...(ARGS)>
786- auto bulkPersist (std::array<char const *, NCOLUMNS> const & columnNames, size_t nRows)
787- {
788- validate ();
789- // Should not be called more than once
790- mArrays .resize (NCOLUMNS);
791- makeBuilders<ARGS...>(columnNames, nRows);
792-
793- return [holders = mHolders ](unsigned int /* slot*/ , size_t batchSize, typename BuilderMaker<ARGS>::FillType const *... args) -> void {
794- TableBuilderHelpers::bulkAppend (*(HoldersTupleIndexed<ARGS...>*)holders, batchSize, std::forward_as_tuple (args...));
795- };
796- }
797-
798- template <typename ... ARGS, size_t NCOLUMNS = sizeof ...(ARGS)>
799- auto bulkPersistChunked (std::array<char const *, NCOLUMNS> const & columnNames, size_t nRows)
800- {
801- validate ();
802- mArrays .resize (NCOLUMNS);
803- makeBuilders<ARGS...>(columnNames, nRows);
804-
805- return [holders = mHolders ](unsigned int /* slot*/ , BulkInfo<typename BuilderMaker<ARGS>::STLValueType const *>... args) -> bool {
806- return TableBuilderHelpers::bulkAppendChunked (*(HoldersTupleIndexed<ARGS...>*)holders, std::forward_as_tuple (args...));
807- };
808- }
809-
810712 // / Reserve method to expand the columns as needed.
811713 template <typename ... Ts>
812714 auto reserveArrays (std::tuple<Ts...>& holders, int s)
0 commit comments