sparrow-extensions 0.1.0
Extension types for the sparrow library
Loading...
Searching...
No Matches
json_array.hpp
Go to the documentation of this file.
1// Copyright 2024 Man Group Operations Limited
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include "sparrow/utils/extension.hpp"
18#include "sparrow/variable_size_binary_array.hpp"
19#include "sparrow/variable_size_binary_view_array.hpp"
20
21namespace sparrow_extensions
22{
23
24 using json_extension = sparrow::simple_extension<"arrow.json">;
43 using json_array = sparrow::variable_size_binary_array_impl<
44 sparrow::arrow_traits<std::string>::value_type,
45 sparrow::arrow_traits<std::string>::const_reference,
46 std::int32_t,
48
66 using big_json_array = sparrow::variable_size_binary_array_impl<
67 sparrow::arrow_traits<std::string>::value_type,
68 sparrow::arrow_traits<std::string>::const_reference,
69 std::int64_t,
71
90 using json_view_array = sparrow::variable_size_binary_view_array_impl<
91 sparrow::arrow_traits<std::string>::value_type,
92 sparrow::arrow_traits<std::string>::const_reference,
94}
95
97{
98 template <>
99 struct get_data_type_from_array<sparrow_extensions::json_array>
100 {
101 [[nodiscard]] static constexpr sparrow::data_type get()
102 {
103 return sparrow::data_type::STRING;
104 }
105 };
106
107 template <>
108 struct get_data_type_from_array<sparrow_extensions::big_json_array>
109 {
110 [[nodiscard]] static constexpr sparrow::data_type get()
111 {
112 return sparrow::data_type::LARGE_STRING;
113 }
114 };
115
116 template <>
117 struct get_data_type_from_array<sparrow_extensions::json_view_array>
118 {
119 [[nodiscard]] static constexpr sparrow::data_type get()
120 {
121 return sparrow::data_type::STRING_VIEW;
122 }
123 };
124}
sparrow::variable_size_binary_view_array_impl< sparrow::arrow_traits< std::string >::value_type, sparrow::arrow_traits< std::string >::const_reference, json_extension > json_view_array
JSON array with view-based storage.
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 > big_json_array
JSON array with 64-bit offsets.
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 > json_array
JSON array with 32-bit offsets.
sparrow::simple_extension<"arrow.json"> json_extension