Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 5 additions & 6 deletions include/sparrow_extensions/bool8_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

#include "sparrow/primitive_array.hpp"
#include "sparrow/utils/extension.hpp"
#include "sparrow_extensions/config/config.hpp"

namespace sparrow
namespace sparrow_extensions
{
/**
* @brief Bool8 array using 8-bit storage for boolean values.
Expand All @@ -36,22 +35,22 @@ namespace sparrow
* - Extension metadata: empty string
*
*/
using bool8_array = primitive_array<int8_t, simple_extension<"arrow.bool8">, bool>;
using bool8_array = sparrow::primitive_array<int8_t, sparrow::simple_extension<"arrow.bool8">, bool>;
}

#if defined(__cpp_lib_format)
# include <format>

// Formatter specialization for bool8_array
template <>
struct std::formatter<sparrow::bool8_array>
struct std::formatter<sparrow_extensions::bool8_array>
{
constexpr auto parse(std::format_parse_context& ctx)
{
return ctx.begin();
}

auto format(const sparrow::bool8_array& ar, std::format_context& ctx) const
auto format(const sparrow_extensions::bool8_array& ar, std::format_context& ctx) const
{
std::format_to(ctx.out(), "Bool8 array [{}]: [", ar.size());
for (std::size_t i = 0; i < ar.size(); ++i)
Expand All @@ -74,7 +73,7 @@ struct std::formatter<sparrow::bool8_array>
}
};

namespace sparrow
namespace sparrow_extensions
{
inline std::ostream& operator<<(std::ostream& os, const bool8_array& value)
{
Expand Down
71 changes: 35 additions & 36 deletions include/sparrow_extensions/json_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
#include "sparrow/utils/extension.hpp"
#include "sparrow/variable_size_binary_array.hpp"
#include "sparrow/variable_size_binary_view_array.hpp"
#include "sparrow_extensions/config/config.hpp"

namespace sparrow
namespace sparrow_extensions
{

using json_extension = simple_extension<"arrow.json">;
using json_extension = sparrow::simple_extension<"arrow.json">;
/**
* @brief JSON array with 32-bit offsets.
*
Expand All @@ -41,9 +40,9 @@ namespace sparrow
* @see big_json_array for larger datasets requiring 64-bit offsets
* @see json_view_array for view-based storage
*/
using json_array = variable_size_binary_array_impl<
arrow_traits<std::string>::value_type,
arrow_traits<std::string>::const_reference,
using json_array = sparrow::variable_size_binary_array_impl<
sparrow::arrow_traits<std::string>::value_type,
sparrow::arrow_traits<std::string>::const_reference,
std::int32_t,
json_extension>;

Expand All @@ -64,9 +63,9 @@ namespace sparrow
* @see json_array for smaller datasets with 32-bit offsets
* @see json_view_array for view-based storage
*/
using big_json_array = variable_size_binary_array_impl<
arrow_traits<std::string>::value_type,
arrow_traits<std::string>::const_reference,
using big_json_array = sparrow::variable_size_binary_array_impl<
sparrow::arrow_traits<std::string>::value_type,
sparrow::arrow_traits<std::string>::const_reference,
std::int64_t,
json_extension>;

Expand All @@ -88,38 +87,38 @@ namespace sparrow
* @see json_array for offset-based storage with 32-bit offsets
* @see big_json_array for offset-based storage with 64-bit offsets
*/
using json_view_array = variable_size_binary_view_array_impl<
arrow_traits<std::string>::value_type,
arrow_traits<std::string>::const_reference,
using json_view_array = sparrow::variable_size_binary_view_array_impl<
sparrow::arrow_traits<std::string>::value_type,
sparrow::arrow_traits<std::string>::const_reference,
json_extension>;
}

namespace detail
namespace sparrow::detail
{
template <>
struct get_data_type_from_array<sparrow_extensions::json_array>
{
template <>
struct get_data_type_from_array<sparrow::json_array>
[[nodiscard]] static constexpr sparrow::data_type get()
{
[[nodiscard]] static constexpr sparrow::data_type get()
{
return sparrow::data_type::STRING;
}
};
return sparrow::data_type::STRING;
}
};

template <>
struct get_data_type_from_array<sparrow::big_json_array>
template <>
struct get_data_type_from_array<sparrow_extensions::big_json_array>
{
[[nodiscard]] static constexpr sparrow::data_type get()
{
[[nodiscard]] static constexpr sparrow::data_type get()
{
return sparrow::data_type::LARGE_STRING;
}
};
return sparrow::data_type::LARGE_STRING;
}
};

template <>
struct get_data_type_from_array<sparrow::json_view_array>
template <>
struct get_data_type_from_array<sparrow_extensions::json_view_array>
{
[[nodiscard]] static constexpr sparrow::data_type get()
{
[[nodiscard]] static constexpr sparrow::data_type get()
{
return sparrow::data_type::STRING_VIEW;
}
};
}
}
return sparrow::data_type::STRING_VIEW;
}
};
}
4 changes: 2 additions & 2 deletions include/sparrow_extensions/uuid_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include "sparrow/fixed_width_binary_array.hpp"
#include "sparrow/utils/contracts.hpp"
#include "sparrow_extensions/config/config.hpp"

namespace sparrow_extensions
{
Expand Down Expand Up @@ -97,4 +96,5 @@ namespace sparrow::detail
return sparrow::data_type::FIXED_WIDTH_BINARY;
}
};
} // namespace sparrow::detail
}

16 changes: 9 additions & 7 deletions src/bool8_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,25 @@

#include "sparrow/layout/array_registry.hpp"

namespace sparrow::detail
#include "sparrow_extensions/config/config.hpp"

namespace sparrow_extensions::detail
{
SPARROW_EXTENSIONS_API const bool bool8_array_registered = []()
{
auto& registry = array_registry::instance();
auto& registry = sparrow::array_registry::instance();

registry.register_extension(
data_type::INT8,
sparrow::data_type::INT8,
"arrow.bool8",
[](arrow_proxy proxy)
[](sparrow::arrow_proxy proxy)
{
return cloning_ptr<array_wrapper>{
new array_wrapper_impl<bool8_array>(bool8_array(std::move(proxy)))
return sparrow::cloning_ptr<sparrow::array_wrapper>{
new sparrow::array_wrapper_impl<bool8_array>(bool8_array(std::move(proxy)))
};
}
);

return true;
}();
} // namespace sparrow::detail
}
34 changes: 18 additions & 16 deletions src/json_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,52 +14,54 @@

#include "sparrow_extensions/json_array.hpp"

#include "sparrow/layout/array_registry.hpp"
#include <sparrow/layout/array_registry.hpp>

namespace sparrow::detail
#include "sparrow_extensions/config/config.hpp"

namespace sparrow_extensions::detail
{
SPARROW_EXTENSIONS_API const bool json_arrays_registered = []()
{
auto& registry = array_registry::instance();
auto& registry = sparrow::array_registry::instance();

constexpr std::string_view extension_name = "arrow.json";

// Register json_array (STRING base type)
registry.register_extension(
data_type::STRING,
sparrow::data_type::STRING,
extension_name,
[](arrow_proxy proxy)
[](sparrow::arrow_proxy proxy)
{
return cloning_ptr<array_wrapper>{
new array_wrapper_impl<json_array>(json_array(std::move(proxy)))
return sparrow::cloning_ptr<sparrow::array_wrapper>{
new sparrow::array_wrapper_impl<json_array>(json_array(std::move(proxy)))
};
}
);

// Register big_json_array (LARGE_STRING base type)
registry.register_extension(
data_type::LARGE_STRING,
sparrow::data_type::LARGE_STRING,
extension_name,
[](arrow_proxy proxy)
[](sparrow::arrow_proxy proxy)
{
return cloning_ptr<array_wrapper>{
new array_wrapper_impl<big_json_array>(big_json_array(std::move(proxy)))
return sparrow::cloning_ptr<sparrow::array_wrapper>{
new sparrow::array_wrapper_impl<big_json_array>(big_json_array(std::move(proxy)))
};
}
);

// Register json_view_array (STRING_VIEW base type)
registry.register_extension(
data_type::STRING_VIEW,
sparrow::data_type::STRING_VIEW,
extension_name,
[](arrow_proxy proxy)
[](sparrow::arrow_proxy proxy)
{
return cloning_ptr<array_wrapper>{
new array_wrapper_impl<json_view_array>(json_view_array(std::move(proxy)))
return sparrow::cloning_ptr<sparrow::array_wrapper>{
new sparrow::array_wrapper_impl<json_view_array>(json_view_array(std::move(proxy)))
};
}
);

return true;
}();
} // namespace sparrow::detail
}
4 changes: 3 additions & 1 deletion src/uuid_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include "sparrow/layout/array_registry.hpp"

#include "sparrow_extensions/config/config.hpp"

namespace sparrow::detail
{
SPARROW_EXTENSIONS_API const bool uuid_array_registered = []()
Expand All @@ -35,4 +37,4 @@ namespace sparrow::detail

return true;
}();
} // namespace sparrow::detail
}
11 changes: 6 additions & 5 deletions tests/test_bool8_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@
// limitations under the License.

#include <ranges>
#include <vector>

#include "sparrow/array.hpp"
#include "sparrow/layout/array_access.hpp"
#include <doctest/doctest.h>

#include <sparrow/array.hpp>

#include "doctest/doctest.h"
#include "metadata_sample.hpp"
#include "sparrow_extensions/bool8_array.hpp"

namespace sparrow
using namespace sparrow;

namespace sparrow_extensions
{
TEST_SUITE("bool8_array")
{
Expand Down
15 changes: 8 additions & 7 deletions tests/test_json_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
#include <string>
#include <vector>

#include "sparrow/array.hpp"
#include "sparrow/layout/array_access.hpp"
#include "sparrow/layout/array_registry.hpp"
#include "sparrow/types/data_type.hpp"
#include "sparrow/utils/nullable.hpp"
#include <doctest/doctest.h>

#include <sparrow/array.hpp>
#include <sparrow/types/data_type.hpp>
#include <sparrow/utils/nullable.hpp>

#include "doctest/doctest.h"
#include "sparrow_extensions/json_array.hpp"

namespace sparrow
using namespace sparrow;

namespace sparrow_extensions
{
TEST_SUITE("json_array")
{
Expand Down
12 changes: 5 additions & 7 deletions tests/test_uuid_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
#include <algorithm>
#include <array>
#include <cstddef>
#include <vector>

#include "sparrow/array.hpp"
#include "sparrow/layout/array_access.hpp"
#include "sparrow/layout/array_registry.hpp"
#include "sparrow/types/data_type.hpp"
#include "sparrow/utils/nullable.hpp"
#include <doctest/doctest.h>

#include <sparrow/array.hpp>
#include <sparrow/types/data_type.hpp>
#include <sparrow/utils/nullable.hpp>

#include "doctest/doctest.h"
#include "sparrow_extensions/uuid_array.hpp"

namespace sparrow_extensions
Expand Down
Loading