Skip to content

Commit 2db5795

Browse files
committed
wip
1 parent 1c1cd18 commit 2db5795

File tree

5 files changed

+55
-41
lines changed

5 files changed

+55
-41
lines changed

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,14 @@ set(SPARROW_IPC_SRC
111111
${SPARROW_IPC_SOURCE_DIR}/arrow_interface/arrow_array/private_data.cpp
112112
${SPARROW_IPC_SOURCE_DIR}/arrow_interface/arrow_schema.cpp
113113
${SPARROW_IPC_SOURCE_DIR}/arrow_interface/arrow_schema/private_data.cpp
114+
${SPARROW_IPC_SOURCE_DIR}/deserialize_fixedsizebinary_array.cpp
115+
${SPARROW_IPC_SOURCE_DIR}/deserialize_utils.cpp
114116
${SPARROW_IPC_SOURCE_DIR}/deserialize.cpp
115117
${SPARROW_IPC_SOURCE_DIR}/encapsulated_message.cpp
118+
${SPARROW_IPC_SOURCE_DIR}/metadata.cpp
116119
${SPARROW_IPC_SOURCE_DIR}/serialize_null_array.cpp
117120
${SPARROW_IPC_SOURCE_DIR}/serialize.cpp
118121
${SPARROW_IPC_SOURCE_DIR}/utils.cpp
119-
${SPARROW_IPC_SOURCE_DIR}/metadata.cpp
120-
${SPARROW_IPC_SOURCE_DIR}/deserialize_utils.cpp
121122
)
122123

123124
# Fetch schemas from apache arrow

include/sparrow_ipc/deserialize_fixedsizebinary_array.hpp

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,12 @@
1010

1111
namespace sparrow_ipc
1212
{
13-
[[nodiscard]] sparrow::fixed_width_binary_array deserialize_fixedwidthbinary(
13+
[[nodiscard]] sparrow::fixed_width_binary_array deserialize_non_owning_fixedwidthbinary(
1414
const org::apache::arrow::flatbuf::RecordBatch& record_batch,
1515
std::span<const uint8_t> body,
1616
std::string_view name,
1717
const std::optional<std::vector<sparrow::metadata_pair>>& metadata,
1818
size_t& buffer_index,
1919
int32_t byte_width
20-
)
21-
{
22-
const std::string format = "w:" + std::to_string(byte_width);
23-
ArrowSchema schema = make_non_owning_arrow_schema(
24-
format,
25-
name.data(),
26-
metadata,
27-
std::nullopt,
28-
0,
29-
nullptr,
30-
nullptr
31-
);
32-
const auto [bitmap_ptr, null_count] = utils::get_bitmap_pointer_and_null_count(
33-
record_batch,
34-
body,
35-
buffer_index++
36-
);
37-
const auto buffer_metadata = record_batch.buffers()->Get(buffer_index++);
38-
auto buffer_ptr = const_cast<uint8_t*>(body.data() + buffer_metadata->offset());
39-
std::vector<std::uint8_t*> buffers = {bitmap_ptr, buffer_ptr};
40-
ArrowArray array = make_non_owning_arrow_array(
41-
record_batch.length(),
42-
null_count,
43-
0,
44-
std::move(buffers),
45-
0,
46-
nullptr,
47-
nullptr
48-
);
49-
sparrow::arrow_proxy ap{std::move(array), std::move(schema)};
50-
return sparrow::fixed_width_binary_array{std::move(ap)};
51-
}
20+
);
5221
}

include/sparrow_ipc/deserialize_variable_size_binary_array.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
namespace sparrow_ipc
1414
{
1515
template <typename T>
16-
[[nodiscard]] T deserialize_variable_size_binary(
16+
[[nodiscard]] T deserialize_non_owning_variable_size_binary(
1717
const org::apache::arrow::flatbuf::RecordBatch& record_batch,
1818
std::span<const uint8_t> body,
1919
std::string_view name,

src/deserialize.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ namespace sparrow_ipc
164164
case org::apache::arrow::flatbuf::Type::FixedSizeBinary:
165165
{
166166
const auto fixed_size_binary_field = field->type_as_FixedSizeBinary();
167-
arrays.emplace_back(deserialize_fixedwidthbinary(
167+
arrays.emplace_back(deserialize_non_owning_fixedwidthbinary(
168168
record_batch,
169169
encapsulated_message.body(),
170170
name,
@@ -176,7 +176,7 @@ namespace sparrow_ipc
176176
}
177177
case org::apache::arrow::flatbuf::Type::Binary:
178178
arrays.emplace_back(
179-
deserialize_variable_size_binary<sparrow::binary_array>(
179+
deserialize_non_owning_variable_size_binary<sparrow::binary_array>(
180180
record_batch,
181181
encapsulated_message.body(),
182182
name,
@@ -187,7 +187,7 @@ namespace sparrow_ipc
187187
break;
188188
case org::apache::arrow::flatbuf::Type::LargeBinary:
189189
arrays.emplace_back(
190-
deserialize_variable_size_binary<sparrow::big_binary_array>(
190+
deserialize_non_owning_variable_size_binary<sparrow::big_binary_array>(
191191
record_batch,
192192
encapsulated_message.body(),
193193
name,
@@ -198,7 +198,7 @@ namespace sparrow_ipc
198198
break;
199199
case org::apache::arrow::flatbuf::Type::Utf8:
200200
arrays.emplace_back(
201-
deserialize_variable_size_binary<sparrow::string_array>(
201+
deserialize_non_owning_variable_size_binary<sparrow::string_array>(
202202
record_batch,
203203
encapsulated_message.body(),
204204
name,
@@ -209,7 +209,7 @@ namespace sparrow_ipc
209209
break;
210210
case org::apache::arrow::flatbuf::Type::LargeUtf8:
211211
arrays.emplace_back(
212-
deserialize_variable_size_binary<sparrow::big_string_array>(
212+
deserialize_non_owning_variable_size_binary<sparrow::big_string_array>(
213213
record_batch,
214214
encapsulated_message.body(),
215215
name,
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include "sparrow_ipc/deserialize_fixedsizebinary_array.hpp"
2+
3+
namespace sparrow_ipc
4+
{
5+
sparrow::fixed_width_binary_array deserialize_non_owning_fixedwidthbinary(
6+
const org::apache::arrow::flatbuf::RecordBatch& record_batch,
7+
std::span<const uint8_t> body,
8+
std::string_view name,
9+
const std::optional<std::vector<sparrow::metadata_pair>>& metadata,
10+
size_t& buffer_index,
11+
int32_t byte_width
12+
)
13+
{
14+
const std::string format = "w:" + std::to_string(byte_width);
15+
ArrowSchema schema = make_non_owning_arrow_schema(
16+
format,
17+
name.data(),
18+
metadata,
19+
std::nullopt,
20+
0,
21+
nullptr,
22+
nullptr
23+
);
24+
const auto [bitmap_ptr, null_count] = utils::get_bitmap_pointer_and_null_count(
25+
record_batch,
26+
body,
27+
buffer_index++
28+
);
29+
const auto buffer_metadata = record_batch.buffers()->Get(buffer_index++);
30+
auto buffer_ptr = const_cast<uint8_t*>(body.data() + buffer_metadata->offset());
31+
std::vector<std::uint8_t*> buffers = {bitmap_ptr, buffer_ptr};
32+
ArrowArray array = make_non_owning_arrow_array(
33+
record_batch.length(),
34+
null_count,
35+
0,
36+
std::move(buffers),
37+
0,
38+
nullptr,
39+
nullptr
40+
);
41+
sparrow::arrow_proxy ap{std::move(array), std::move(schema)};
42+
return sparrow::fixed_width_binary_array{std::move(ap)};
43+
}
44+
}

0 commit comments

Comments
 (0)