diff --git a/include/sparrow_ipc/flatbuffer_utils.hpp b/include/sparrow_ipc/flatbuffer_utils.hpp index 592c006..4b3e42f 100644 --- a/include/sparrow_ipc/flatbuffer_utils.hpp +++ b/include/sparrow_ipc/flatbuffer_utils.hpp @@ -200,8 +200,9 @@ namespace sparrow_ipc { std::vector buffers; int64_t offset = 0; - for (const auto& column : record_batch.columns()) + for (size_t i = 0; i < record_batch.nb_columns(); ++i) { + const auto& column = record_batch.get_column(i); const auto& arrow_proxy = sparrow::detail::array_access::get_arrow_proxy(column); fill_buffers_func(arrow_proxy, buffers, offset); } diff --git a/src/flatbuffer_utils.cpp b/src/flatbuffer_utils.cpp index 4c4e79a..ec453c9 100644 --- a/src/flatbuffer_utils.cpp +++ b/src/flatbuffer_utils.cpp @@ -468,13 +468,13 @@ namespace sparrow_ipc ::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset>> create_children(flatbuffers::FlatBufferBuilder& builder, const sparrow::record_batch& record_batch) { - const auto& columns = record_batch.columns(); std::vector> children_vec; - children_vec.reserve(columns.size()); + children_vec.reserve(record_batch.nb_columns()); const auto names = record_batch.names(); - for (size_t i = 0; i < columns.size(); ++i) + for (size_t i = 0; i < record_batch.nb_columns(); ++i) { - const auto& arrow_schema = sparrow::detail::array_access::get_arrow_proxy(columns[i]).schema(); + const auto& column = record_batch.get_column(i); + const auto& arrow_schema = sparrow::detail::array_access::get_arrow_proxy(column).schema(); flatbuffers::Offset field = create_field( builder, arrow_schema, @@ -523,9 +523,10 @@ namespace sparrow_ipc create_fieldnodes(const sparrow::record_batch& record_batch) { std::vector nodes; - nodes.reserve(record_batch.columns().size()); - for (const auto& column : record_batch.columns()) + nodes.reserve(record_batch.nb_columns()); + for (size_t i = 0; i < record_batch.nb_columns(); ++i) { + const auto& column = record_batch.get_column(i); fill_fieldnodes(sparrow::detail::array_access::get_arrow_proxy(column), nodes); } return nodes; @@ -608,16 +609,14 @@ namespace sparrow_ipc std::optional compression, std::optional> cache) { - return std::accumulate( - record_batch.columns().begin(), - record_batch.columns().end(), - int64_t{0}, - [&](int64_t acc, const sparrow::array& arr) - { - const auto& arrow_proxy = sparrow::detail::array_access::get_arrow_proxy(arr); - return acc + calculate_body_size(arrow_proxy, compression, cache); - } - ); + int64_t acc = 0; + for (size_t i = 0; i < record_batch.nb_columns(); ++i) + { + const auto& arr = record_batch.get_column(i); + const auto& arrow_proxy = sparrow::detail::array_access::get_arrow_proxy(arr); + acc += calculate_body_size(arrow_proxy, compression, cache); + } + return acc; } flatbuffers::FlatBufferBuilder get_record_batch_message_builder(const sparrow::record_batch& record_batch, diff --git a/src/metadata.cpp b/src/metadata.cpp index 3638f76..699229b 100644 --- a/src/metadata.cpp +++ b/src/metadata.cpp @@ -20,4 +20,4 @@ namespace sparrow_ipc ); return sparrow_metadata; } -} \ No newline at end of file +} diff --git a/src/serialize_utils.cpp b/src/serialize_utils.cpp index 45ab970..1efa864 100644 --- a/src/serialize_utils.cpp +++ b/src/serialize_utils.cpp @@ -38,10 +38,12 @@ namespace sparrow_ipc std::optional compression, std::optional> cache) { - std::for_each(record_batch.columns().begin(), record_batch.columns().end(), [&](const auto& column) { + for (size_t i = 0; i < record_batch.nb_columns(); ++i) + { + const auto& column = record_batch.get_column(i); const auto& arrow_proxy = sparrow::detail::array_access::get_arrow_proxy(column); fill_body(arrow_proxy, stream, compression, cache); - }); + } } std::size_t calculate_schema_message_size(const sparrow::record_batch& record_batch) @@ -85,14 +87,10 @@ namespace sparrow_ipc { std::vector dtypes; dtypes.reserve(rb.nb_columns()); - std::ranges::transform( - rb.columns(), - std::back_inserter(dtypes), - [](const auto& col) - { - return col.data_type(); - } - ); + for (size_t i = 0; i < rb.nb_columns(); ++i) + { + dtypes.push_back(rb.get_column(i).data_type()); + } return dtypes; } } diff --git a/src/serializer.cpp b/src/serializer.cpp index b12459c..0b222bb 100644 --- a/src/serializer.cpp +++ b/src/serializer.cpp @@ -23,9 +23,9 @@ namespace sparrow_ipc { std::vector dtypes; dtypes.reserve(rb.nb_columns()); - for (const auto& col : rb.columns()) + for (size_t i = 0; i < rb.nb_columns(); ++i) { - dtypes.push_back(col.data_type()); + dtypes.push_back(rb.get_column(i).data_type()); } return dtypes; }