42 template <timestamp_type T>
51 return "timestamp_array";
55 template <timestamp_type T>
207 template <timestamp_type T>
303 template <
class... Args>
306 :
base_type(create_proxy(std::forward<Args>(args)...))
308 , m_data_access(this->get_arrow_proxy(), DATA_BUFFER_INDEX)
326 template <input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
328 const date::time_zone* timezone,
329 std::initializer_list<inner_value_type> init,
330 std::optional<std::string_view> name = std::nullopt,
331 std::optional<METADATA_RANGE> metadata = std::nullopt
333 :
base_type(create_proxy(timezone, init,
std::move(name),
std::move(metadata)))
334 , m_timezone(timezone)
335 , m_data_access(this->get_arrow_proxy(), DATA_BUFFER_INDEX)
490 template <input_metadata_container METADATA_RANGE>
492 const date::time_zone* timezone,
494 std::optional<std::string_view> name = std::nullopt,
495 std::optional<METADATA_RANGE> metadata = std::nullopt
529 [[nodiscard]]
static auto create_proxy(
530 const date::time_zone* timezone,
533 std::optional<std::string_view> name = std::nullopt,
534 std::optional<METADATA_RANGE> metadata = std::nullopt
565 template <std::ranges::input_range R, input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
566 requires std::convertible_to<std::ranges::range_value_t<R>, T>
567 [[nodiscard]]
static auto create_proxy(
568 const date::time_zone* timezone,
571 std::optional<std::string_view> name = std::nullopt,
572 std::optional<METADATA_RANGE> metadata = std::nullopt
601 template <
typename U, input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
602 requires std::convertible_to<U, T>
604 const date::time_zone* timezone,
606 const U& value = U{},
607 std::optional<std::string_view> name = std::nullopt,
608 std::optional<METADATA_RANGE> metadata = std::nullopt
642 std::ranges::input_range VALUE_RANGE,
643 validity_bitmap_input VALIDITY_RANGE,
644 input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
645 requires(std::convertible_to<std::ranges::range_value_t<VALUE_RANGE>, T>)
646 [[nodiscard]]
static arrow_proxy create_proxy(
647 const date::time_zone* timezone,
650 std::optional<std::string_view> name = std::nullopt,
651 std::optional<METADATA_RANGE> metadata = std::nullopt
682 template <std::ranges::input_range R, input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
683 requires std::is_same_v<std::ranges::range_value_t<R>, nullable<T>>
684 [[nodiscard]]
static arrow_proxy create_proxy(
685 const date::time_zone* timezone,
687 std::optional<std::string_view> name = std::nullopt,
688 std::optional<METADATA_RANGE> metadata = std::nullopt
732 template <input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
733 [[nodiscard]]
static arrow_proxy create_proxy_impl(
734 const date::time_zone* timezone,
735 u8_buffer<buffer_inner_value_type>&& data_buffer,
736 std::optional<validity_bitmap>&& bitmap,
737 std::optional<std::string_view> name = std::nullopt,
738 std::optional<METADATA_RANGE> metadata = std::nullopt
772 constexpr value_iterator
792 template <mpl::iterator_of_type<typename timestamp_array<T>::inner_value_type> InputIt>
793 constexpr auto insert_values(
const_value_iterator pos, InputIt first, InputIt last) -> value_iterator
795 const auto input_range = std::ranges::subrange(first, last);
796 const auto values = input_range | std::views::transform(extract_duration);
797 const size_t idx =
static_cast<size_t>(std::distance(value_cbegin(), pos));
798 m_data_access.
insert_values(idx, values.begin(), values.end());
832 constexpr void assign(
const T& rhs,
size_type index);
847 constexpr void assign(T&& rhs,
size_type index);
858 return timestamp.get_sys_time().time_since_epoch();
861 const date::time_zone* m_timezone;
862 details::primitive_data_access<inner_value_type_duration> m_data_access;
873 template <timestamp_type T>
876 , m_timezone(rhs.m_timezone)
877 , m_data_access(this->get_arrow_proxy(), DATA_BUFFER_INDEX)
882 template <timestamp_type T>
887 m_timezone = rhs.m_timezone;
888 m_data_access.reset_proxy(this->get_arrow_proxy());
892 template <timestamp_type T>
895 , m_timezone(rhs.m_timezone)
896 , m_data_access(this->get_arrow_proxy(), DATA_BUFFER_INDEX)
900 template <timestamp_type T>
904 m_timezone = rhs.m_timezone;
905 m_data_access.reset_proxy(this->get_arrow_proxy());
909 template <timestamp_type T>
913 , m_data_access(this->get_arrow_proxy(), DATA_BUFFER_INDEX)
917 template <timestamp_type T>
918 template <val
idity_bitmap_input R, input_metadata_container METADATA_RANGE>
919 auto timestamp_array<T>::create_proxy(
920 const date::time_zone* timezone,
923 std::optional<std::string_view> name,
924 std::optional<METADATA_RANGE> metadata
927 const auto size = data_buffer.size();
929 return create_proxy_impl(
938 template <timestamp_type T>
939 template <std::ranges::input_range VALUE_RANGE, val
idity_bitmap_input VALIDITY_RANGE, input_metadata_container METADATA_RANGE>
940 requires(std::convertible_to<std::ranges::range_value_t<VALUE_RANGE>, T>)
941 arrow_proxy timestamp_array<T>::create_proxy(
942 const date::time_zone* timezone,
943 VALUE_RANGE&& values,
944 VALIDITY_RANGE&& validity_input,
945 std::optional<std::string_view> name,
946 std::optional<METADATA_RANGE> metadata
949 constexpr auto extract_duration_count = [](
const auto& v)
951 return v.get_sys_time().time_since_epoch().count();
954 const auto range = values | std::views::transform(extract_duration_count);
959 std::move(data_buffer),
960 std::forward<VALIDITY_RANGE>(validity_input),
966 template <timestamp_type T>
967 template <
typename U, input_metadata_container METADATA_RANGE>
968 requires std::convertible_to<U, T>
970 const date::time_zone* timezone,
973 std::optional<std::string_view> name,
974 std::optional<METADATA_RANGE> metadata
978 const auto duration_count = value.get_sys_time().time_since_epoch().count();
980 return create_proxy(timezone, std::move(data_buffer), std::move(name), std::move(metadata));
983 template <timestamp_type T>
984 template <std::ranges::input_range R, input_metadata_container METADATA_RANGE>
985 requires std::convertible_to<std::ranges::range_value_t<R>, T>
987 const date::time_zone* timezone,
990 std::optional<std::string_view> name,
991 std::optional<METADATA_RANGE> metadata
994 constexpr auto extract_duration_count = [](
const auto& v)
996 return v.get_sys_time().time_since_epoch().count();
999 std::optional<validity_bitmap> bitmap =
nullable ? std::make_optional<validity_bitmap>(
1005 const auto values = range | std::views::transform(extract_duration_count);
1007 return self_type::create_proxy_impl(
1009 std::move(data_buffer),
1017 template <timestamp_type T>
1018 template <std::ranges::input_range R, input_metadata_container METADATA_RANGE>
1019 requires std::is_same_v<std::ranges::range_value_t<R>,
nullable<T>>
1021 const date::time_zone* timezone,
1023 std::optional<std::string_view> name,
1024 std::optional<METADATA_RANGE> metadata
1028 | std::views::transform(
1034 auto is_non_null = range
1035 | std::views::transform(
1038 return v.has_value();
1041 return self_type::create_proxy(timezone, values, is_non_null, std::move(name), std::move(metadata));
1044 template <timestamp_type T>
1045 template <input_metadata_container METADATA_RANGE>
1046 arrow_proxy timestamp_array<T>::create_proxy_impl(
1047 const date::time_zone* timezone,
1049 std::optional<validity_bitmap>&& bitmap,
1050 std::optional<std::string_view> name,
1051 std::optional<METADATA_RANGE> metadata
1054 const auto size = data_buffer.size();
1055 const auto null_count = bitmap.has_value() ? bitmap->
null_count() : 0;
1058 format += timezone->name();
1062 const std::optional<std::unordered_set<sparrow::ArrowFlag>>
1063 flags = bitmap.has_value()
1071 std::move(metadata),
1079 std::vector<buffer<uint8_t>> buffers;
1081 buffers.emplace_back(
1085 buffers.emplace_back(std::move(data_buffer).extract_storage());
1089 static_cast<std::int64_t
>(size),
1090 static_cast<int64_t
>(null_count),
1098 return arrow_proxy(std::move(arr), std::move(schema));
1101 template <timestamp_type T>
1102 constexpr void timestamp_array<T>::assign(
const T& rhs, size_type index)
1105 m_data_access.value(index) = extract_duration(rhs);
1108 template <timestamp_type T>
1109 constexpr void timestamp_array<T>::assign(T&& rhs, size_type index)
1112 m_data_access.value(index) = extract_duration(rhs);
1115 template <timestamp_type T>
1116 constexpr auto timestamp_array<T>::value(size_type i) -> inner_reference
1119 return inner_reference(
this, i);
1122 template <timestamp_type T>
1123 constexpr auto timestamp_array<T>::value(size_type i)
const -> inner_const_reference
1126 const auto& val = m_data_access.value(i);
1127 using time_duration =
typename T::duration;
1128 const auto sys_time = std::chrono::sys_time<time_duration>{val};
1129 return T{m_timezone, sys_time};
1132 template <timestamp_type T>
1133 constexpr auto timestamp_array<T>::value_begin() -> value_iterator
1135 return value_iterator(functor_type(
this), 0);
1138 template <timestamp_type T>
1139 constexpr auto timestamp_array<T>::value_end() -> value_iterator
1141 return value_iterator(functor_type(
this), this->
size());
1144 template <timestamp_type T>
1145 constexpr auto timestamp_array<T>::value_cbegin() const -> const_value_iterator
1147 return const_value_iterator(const_functor_type(
this), 0);
1150 template <timestamp_type T>
1151 constexpr auto timestamp_array<T>::value_cend() const -> const_value_iterator
1153 return const_value_iterator(const_functor_type(
this), this->
size());
1156 template <timestamp_type T>
1157 constexpr void timestamp_array<T>::resize_values(size_type new_length, inner_value_type value)
1159 m_data_access.resize_values(new_length, extract_duration(value));
1162 template <timestamp_type T>
1164 timestamp_array<T>::insert_value(const_value_iterator pos, inner_value_type value, size_type count)
1168 const size_t idx =
static_cast<size_t>(std::distance(value_cbegin(), pos));
1169 m_data_access.insert_value(idx, extract_duration(value), count);
1170 return value_iterator(functor_type(
this), idx);
1173 template <timestamp_type T>
1174 constexpr auto timestamp_array<T>::erase_values(const_value_iterator pos, size_type count) -> value_iterator
1177 const size_t idx =
static_cast<size_t>(std::distance(value_cbegin(), pos));
1178 m_data_access.erase_values(idx, count);
1179 return value_iterator(functor_type(
this), idx);
typename base_type::const_bitmap_range const_bitmap_range
typename base_type::bitmap_iterator bitmap_iterator
typename base_type::iterator_tag iterator_tag
typename base_type::const_bitmap_iterator const_bitmap_iterator
constexpr array_bitmap_base_impl & operator=(const array_bitmap_base_impl &)
std::conditional_t< is_mutable, mutable_array_base< D >, array_crtp_base< D > > base_type
typename base_type::bitmap_const_reference bitmap_const_reference
typename base_type::bitmap_type bitmap_type
typename base_type::difference_type difference_type
Object that owns a piece of contiguous memory.
constexpr auto insert_values(const_value_iterator pos, InputIt first, InputIt last) -> value_iterator
storage_type extract_storage() noexcept
Extracts the underlying storage (move operation).
constexpr size_type null_count() const noexcept
Returns the number of bits set to false (null/invalid).
typename storage_type::default_allocator default_allocator
A view that repeats a value a given number of times.
Array implementation for storing timestamp values with timezone information.
timestamp_array self_type
typename base_type::bitmap_range bitmap_range
nullable< inner_value_type > value_type
inner_value_type_duration::rep buffer_inner_value_type
mutable_array_bitmap_base< self_type > base_type
typename base_type::size_type size_type
typename base_type::bitmap_type bitmap_type
typename inner_types::inner_reference inner_reference
typename base_type::difference_type difference_type
array_inner_types< self_type > inner_types
constexpr timestamp_array(const timestamp_array &rhs)
Copy constructor.
timestamp_array(arrow_proxy)
Constructs timestamp array from Arrow proxy.
typename base_type::const_bitmap_iterator const_bitmap_iterator
typename base_type::const_iterator const_iterator
constexpr timestamp_array(timestamp_array &&rhs) noexcept
Move constructor.
typename base_type::iterator_tag iterator_tag
typename base_type::const_value_iterator const_value_iterator
typename inner_types::functor_type functor_type
pointer_iterator< const buffer_inner_value_type * > buffer_inner_const_value_iterator
typename base_type::iterator iterator
typename base_type::bitmap_const_reference bitmap_const_reference
constexpr timestamp_array & operator=(const timestamp_array &rhs)
Copy assignment operator.
constexpr timestamp_array & operator=(timestamp_array &&rhs) noexcept
Move assignment operator.
pointer_iterator< buffer_inner_value_type * > buffer_inner_value_iterator
typename base_type::const_bitmap_range const_bitmap_range
typename base_type::bitmap_iterator bitmap_iterator
constexpr timestamp_array(Args &&... args)
Generic constructor for creating timestamp arrays from various inputs.
nullable< inner_const_reference, bitmap_const_reference > const_reference
typename inner_types::inner_const_reference inner_const_reference
inner_value_type::duration inner_value_type_duration
typename base_type::value_iterator value_iterator
nullable< inner_reference, bitmap_reference > reference
typename base_type::bitmap_reference bitmap_reference
constexpr timestamp_array(const date::time_zone *timezone, std::initializer_list< inner_value_type > init, std::optional< std::string_view > name=std::nullopt, std::optional< METADATA_RANGE > metadata=std::nullopt)
Constructs timestamp array from initializer list.
typename inner_types::const_functor_type const_functor_type
typename inner_types::inner_value_type inner_value_type
Implementation of reference to inner type used for layout L.
This buffer class is used as storage buffer for all sparrow arrays.
#define SPARROW_ASSERT_TRUE(expr__)
SPARROW_API void increase(const std::string &key)
constexpr std::size_t size(typelist< T... >={})
Gets the count of types contained in a typelist.
constexpr bool excludes_copy_and_move_ctor_v
Convenience variable template for excludes_copy_and_move_ctor.
constexpr bool is_type_instance_of_v
Variable template for convenient access to is_type_instance_of.
array_bitmap_base_impl< D, true > mutable_array_bitmap_base
Convenient alias for arrays with mutable validity bitmaps.
ArrowSchema make_arrow_schema(F format, N name, std::optional< M > metadata, std::optional< std::unordered_set< ArrowFlag > > flags, ArrowSchema **children, const CHILDREN_OWNERSHIP &children_ownership, ArrowSchema *dictionary, bool dictionary_ownership)
Creates an ArrowSchema owned by a unique_ptr and holding the provided data.
timestamp< std::chrono::microseconds > timestamp_microsecond
constexpr std::string_view data_type_to_format(data_type type)
timestamp< std::chrono::nanoseconds > timestamp_nanosecond
constexpr InputIt next(InputIt it, Distance n)
SPARROW_API const date::time_zone * get_timezone(const arrow_proxy &proxy)
timestamp_array< timestamp_second > timestamp_seconds_array
Type aliases for timestamp arrays with common durations.
date::zoned_time< Duration, TimeZonePtr > timestamp
constexpr bool is_timestamp_array_v
Variable template for convenient access to is_timestamp_array.
ArrowArray make_arrow_array(int64_t length, int64_t null_count, int64_t offset, B buffers, ArrowArray **children, const CHILDREN_OWNERSHIP &children_ownership, ArrowArray *dictionary, bool dictionary_ownership)
Creates an ArrowArray.
dynamic_bitset< std::uint8_t > validity_bitmap
Type alias for a validity bitmap using 8-bit storage blocks.
timestamp_array< timestamp_nanosecond > timestamp_nanoseconds_array
timestamp< std::chrono::seconds > timestamp_second
Type aliases for common timestamp durations.
validity_bitmap ensure_validity_bitmap(std::size_t size, R &&validity_input)
Ensures a validity bitmap of the specified size from various input types.
timestamp< std::chrono::milliseconds > timestamp_millisecond
data_type
Runtime identifier of arrow data types, usually associated with raw bytes with the associated value.
timestamp_array< timestamp_microsecond > timestamp_microseconds_array
timestamp_array< timestamp_millisecond > timestamp_milliseconds_array
Extensions to the C++ standard library.
functor_index_iterator< functor_type > value_iterator
functor_index_iterator< const_functor_type > const_value_iterator
timestamp_array< T > self_type
detail::layout_value_functor< self_type, inner_reference > functor_type
detail::layout_value_functor< const self_type, inner_const_reference > const_functor_type
timestamp_reference< self_type > inner_reference
std::random_access_iterator_tag iterator_tag
Base class for array_inner_types specializations.
Traits class that must be specialized by array implementations.
static constexpr sparrow::data_type get()
static constexpr sparrow::data_type get()
static constexpr sparrow::data_type get()
static constexpr sparrow::data_type get()
Metafunction for retrieving the data_type of a typed array.
Type trait to check if a type is a timestamp_array.