Skip to content

Handle different data types #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ set(SPARROW_IPC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(SPARROW_IPC_HEADERS
${SPARROW_IPC_INCLUDE_DIR}/config/config.hpp
${SPARROW_IPC_INCLUDE_DIR}/serialize.hpp
${SPARROW_IPC_INCLUDE_DIR}/utils.hpp
)

set(SPARROW_IPC_SRC
${SPARROW_IPC_SOURCE_DIR}/serialize.cpp
${SPARROW_IPC_SOURCE_DIR}/utils.cpp
)

set(SCHEMA_DIR ${CMAKE_BINARY_DIR}/format)
Expand Down
14 changes: 9 additions & 5 deletions include/serialize.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#pragma once

#include <vector>

#include "sparrow.hpp"

#include "config/config.hpp"

//TODO split serialize/deserialize fcts in two different files or just rename the current one?
template <typename T>
SPARROW_IPC_API std::vector<uint8_t> serialize_primitive_array(const sparrow::primitive_array<T>& arr);
namespace sparrow_ipc
{
//TODO split serialize/deserialize fcts in two different files or just rename the current one?
template <typename T>
SPARROW_IPC_API std::vector<uint8_t> serialize_primitive_array(const sparrow::primitive_array<T>& arr);

template <typename T>
SPARROW_IPC_API sparrow::primitive_array<T> deserialize_primitive_array(const std::vector<uint8_t>& buffer);
template <typename T>
SPARROW_IPC_API sparrow::primitive_array<T> deserialize_primitive_array(const std::vector<uint8_t>& buffer);
}
24 changes: 24 additions & 0 deletions include/utils.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include <cstdint>
#include <optional>
#include <string_view>
#include <utility>

#include "Schema_generated.h"

#include "config/config.hpp"

namespace sparrow_ipc
{
namespace utils
{
// Aligns a value to the next multiple of 8, as required by the Arrow IPC format for message bodies
SPARROW_IPC_API int64_t align_to_8(int64_t n);

// Creates a Flatbuffers type from a format string
// This function maps a sparrow data type to the corresponding Flatbuffers type
SPARROW_IPC_API std::pair<org::apache::arrow::flatbuf::Type, flatbuffers::Offset<void>>
get_flatbuffer_type(flatbuffers::FlatBufferBuilder& builder, std::string_view format_str);
}
}
506 changes: 237 additions & 269 deletions src/serialize.cpp

Large diffs are not rendered by default.

349 changes: 349 additions & 0 deletions src/utils.cpp

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ find_package(doctest CONFIG REQUIRED)

set(test_target "test_sparrow_ipc_lib")

add_executable(${test_target} test.cpp)
add_executable(${test_target} main.cpp test_primitive_array.cpp test_utils.cpp)
target_link_libraries(${test_target}
PRIVATE
sparrow-ipc
Expand All @@ -13,6 +13,7 @@ target_link_libraries(${test_target}
target_include_directories(${test_target}
PRIVATE
${CMAKE_BINARY_DIR}/generated
${CMAKE_SOURCE_DIR}/include
)
add_dependencies(${test_target} generate_flatbuffers_headers)
add_test(NAME sparrow-ipc-tests COMMAND ${test_target})
5 changes: 5 additions & 0 deletions tests/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN

#include "doctest/doctest.h"

//TODO check version?
158 changes: 0 additions & 158 deletions tests/test.cpp

This file was deleted.

Loading
Loading