37 template <timestamp_type T>
40 template <timestamp_type T>
102 template <timestamp_type T>
174 template <
class... Args>
177 :
base_type(create_proxy(std::forward<Args>(args)...))
178 , m_timezone(get_timezone(this->get_arrow_proxy()))
179 , m_data_access(
this, DATA_BUFFER_INDEX)
184 const date::time_zone* timezone,
185 std::initializer_list<inner_value_type> init,
186 std::optional<std::string_view> name = std::nullopt,
187 std::optional<std::string_view> metadata = std::nullopt
189 :
base_type(create_proxy(timezone, init,
std::move(name),
std::move(metadata)))
190 , m_timezone(timezone)
191 , m_data_access(this, DATA_BUFFER_INDEX)
200 [[nodiscard]] value_iterator value_begin();
201 [[nodiscard]] value_iterator value_end();
207 const date::time_zone* timezone,
209 std::optional<std::string_view> name = std::nullopt,
210 std::optional<std::string_view> metadata = std::nullopt
213 template <val
idity_bitmap_input R = val
idity_bitmap>
214 [[nodiscard]]
static auto create_proxy(
215 const date::time_zone* timezone,
218 std::optional<std::string_view> name = std::nullopt,
219 std::optional<std::string_view> metadata = std::nullopt
223 template <std::ranges::input_range R>
224 requires std::convertible_to<std::ranges::range_value_t<R>, T>
225 [[nodiscard]]
static auto create_proxy(
226 const date::time_zone* timezone,
228 std::optional<std::string_view> name = std::nullopt,
229 std::optional<std::string_view> metadata = std::nullopt
232 template <
typename U>
233 requires std::convertible_to<U, T>
234 [[nodiscard]]
static arrow_proxy create_proxy(
235 const date::time_zone* timezone,
237 const U& value = U{},
238 std::optional<std::string_view> name = std::nullopt,
239 std::optional<std::string_view> metadata = std::nullopt
243 template <std::ranges::input_range VALUE_RANGE, val
idity_bitmap_input VALIDITY_RANGE>
244 requires(std::convertible_to<std::ranges::range_value_t<VALUE_RANGE>, T>)
245 [[nodiscard]]
static arrow_proxy create_proxy(
246 const date::time_zone* timezone,
249 std::optional<std::string_view> name = std::nullopt,
250 std::optional<std::string_view> metadata = std::nullopt
254 template <std::ranges::input_range R>
255 requires std::is_same_v<std::ranges::range_value_t<R>, nullable<T>>
256 [[nodiscard]]
static arrow_proxy create_proxy(
257 const date::time_zone* timezone,
259 std::optional<std::string_view> name = std::nullopt,
260 std::optional<std::string_view> metadata = std::nullopt
269 template <mpl::iterator_of_type<typename timestamp_array<T>::inner_value_type> InputIt>
272 const auto input_range = std::ranges::subrange(first, last);
273 const auto values = input_range
274 | std::views::transform(
277 return v.get_sys_time().time_since_epoch();
280 const size_t idx =
static_cast<size_t>(std::distance(value_cbegin(), pos));
281 m_data_access.insert_values(idx, values.begin(), values.end());
287 void assign(
const T& rhs,
size_type index);
290 [[nodiscard]]
static const date::time_zone* get_timezone(
const arrow_proxy& proxy);
292 const date::time_zone* m_timezone;
293 details::trivial_copyable_data_access<inner_value_type_duration, self_type> m_data_access;
304 template <timestamp_type T>
305 const date::time_zone* timestamp_array<T>::get_timezone(
const arrow_proxy& proxy)
307 const std::string_view timezone_string = proxy.
format().substr(4);
308 return date::locate_zone(timezone_string);
311 template <timestamp_type T>
314 , m_timezone(get_timezone(this->get_arrow_proxy()))
315 , m_data_access(this, DATA_BUFFER_INDEX)
319 template <timestamp_type T>
320 template <val
idity_bitmap_input R>
321 auto timestamp_array<T>::create_proxy(
322 const date::time_zone* timezone,
325 std::optional<std::string_view> name,
326 std::optional<std::string_view> metadata
329 const auto size = data_buffer.size();
334 format += timezone->name();
347 std::vector<buffer<uint8_t>> buffers(2);
348 buffers[0] = std::move(bitmap).extract_storage();
349 buffers[1] = std::move(data_buffer).extract_storage();
353 static_cast<std::int64_t
>(size),
354 static_cast<int64_t
>(null_count),
361 return arrow_proxy(std::move(arr), std::move(schema));
364 template <timestamp_type T>
365 template <std::ranges::input_range VALUE_RANGE, val
idity_bitmap_input VALIDITY_RANGE>
366 requires(std::convertible_to<std::ranges::range_value_t<VALUE_RANGE>, T>)
367 arrow_proxy timestamp_array<T>::create_proxy(
368 const date::time_zone* timezone,
369 VALUE_RANGE&& values,
370 VALIDITY_RANGE&& validity_input,
371 std::optional<std::string_view> name,
372 std::optional<std::string_view> metadata
375 const auto range = values
376 | std::views::transform(
379 return v.get_sys_time().time_since_epoch().count();
387 std::move(data_buffer),
388 std::forward<VALIDITY_RANGE>(validity_input),
394 template <timestamp_type T>
395 template <
typename U>
396 requires std::convertible_to<U, T>
398 const date::time_zone* timezone,
401 std::optional<std::string_view> name,
402 std::optional<std::string_view> metadata
407 return create_proxy(timezone, std::move(data_buffer), std::move(name), std::move(metadata));
410 template <timestamp_type T>
411 template <std::ranges::input_range R>
412 requires std::convertible_to<std::ranges::range_value_t<R>, T>
414 const date::time_zone* timezone,
416 std::optional<std::string_view> name,
417 std::optional<std::string_view> metadata
421 const auto iota = std::ranges::iota_view{std::size_t(0), n};
422 std::ranges::transform_view iota_to_is_non_missing(
429 return self_type::create_proxy(
431 std::forward<R>(range),
432 std::move(iota_to_is_non_missing),
439 template <timestamp_type T>
440 template <std::ranges::input_range R>
441 requires std::is_same_v<std::ranges::range_value_t<R>,
nullable<T>>
443 const date::time_zone* timezone,
445 std::optional<std::string_view> name,
446 std::optional<std::string_view> metadata
450 | std::views::transform(
456 auto is_non_null = range
457 | std::views::transform(
460 return v.has_value();
463 return self_type::create_proxy(timezone, values, is_non_null, std::move(name), std::move(metadata));
466 template <timestamp_type T>
467 void timestamp_array<T>::assign(
const T& rhs, size_type index)
470 m_data_access.value(index) = rhs.get_sys_time().time_since_epoch();
473 template <timestamp_type T>
474 void timestamp_array<T>::assign(T&& rhs, size_type index)
477 m_data_access.value(index) = rhs.get_sys_time().time_since_epoch();
480 template <timestamp_type T>
481 auto timestamp_array<T>::value(size_type i) -> inner_reference
484 return inner_reference(
this, i);
487 template <timestamp_type T>
488 auto timestamp_array<T>::value(size_type i)
const -> inner_const_reference
491 const auto& val = m_data_access.value(i);
492 using time_duration =
typename T::duration;
493 const auto sys_time = std::chrono::sys_time<time_duration>{val};
494 return T{m_timezone, sys_time};
497 template <timestamp_type T>
498 auto timestamp_array<T>::value_begin() -> value_iterator
500 return value_iterator(functor_type(
this), 0);
503 template <timestamp_type T>
504 auto timestamp_array<T>::value_end() -> value_iterator
506 return value_iterator(functor_type(
this), this->
size());
509 template <timestamp_type T>
510 auto timestamp_array<T>::value_cbegin() const -> const_value_iterator
512 return const_value_iterator(const_functor_type(
this), 0);
515 template <timestamp_type T>
516 auto timestamp_array<T>::value_cend() const -> const_value_iterator
518 return const_value_iterator(const_functor_type(
this), this->
size());
521 template <timestamp_type T>
522 void timestamp_array<T>::resize_values(size_type new_length, inner_value_type value)
524 m_data_access.resize_values(new_length, value.get_sys_time().time_since_epoch());
527 template <timestamp_type T>
528 auto timestamp_array<T>::insert_value(const_value_iterator pos, inner_value_type value, size_type count)
532 const size_t idx =
static_cast<size_t>(std::distance(value_cbegin(), pos));
533 m_data_access.insert_value(idx, value.get_sys_time().time_since_epoch(), count);
534 return value_iterator(functor_type(
this), idx);
537 template <timestamp_type T>
538 auto timestamp_array<T>::erase_values(const_value_iterator pos, size_type count) -> value_iterator
541 const size_t idx =
static_cast<size_t>(std::distance(value_cbegin(), pos));
542 m_data_access.erase_values(idx, count);
543 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
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
Proxy class over ArrowArray and ArrowSchema.
SPARROW_API const std::string_view format() const
constexpr size_type null_count() const noexcept
The nullable class models a value or a reference that can be "null", or missing, like values traditio...
timestamp_array(Args &&... args)
Construct a timestamp array with the passed range of values and an optional bitmap.
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
timestamp_array(arrow_proxy)
typename base_type::const_bitmap_iterator const_bitmap_iterator
typename base_type::const_iterator const_iterator
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
timestamp_array(const date::time_zone *timezone, std::initializer_list< inner_value_type > init, std::optional< std::string_view > name=std::nullopt, std::optional< std::string_view > metadata=std::nullopt)
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
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
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.
#define SPARROW_ASSERT_TRUE(expr__)
constexpr std::size_t size(typelist< T... >={})
constexpr bool excludes_copy_and_move_ctor_v
array_bitmap_base_impl< D, true > mutable_array_bitmap_base
Convenient typedef to be used as a crtp base class for arrays using a mutable validity buffer.
timestamp< std::chrono::microseconds > timestamp_microsecond
constexpr std::string_view data_type_to_format(data_type type)
ArrowSchema make_arrow_schema(F format, N name, M metadata, std::optional< ArrowFlag > flags, int64_t n_children, ArrowSchema **children, ArrowSchema *dictionary)
Creates an ArrowSchema owned by a unique_ptr and holding the provided data.
timestamp< std::chrono::nanoseconds > timestamp_nanosecond
constexpr InputIt next(InputIt it, Distance n)
timestamp_array< timestamp_second > timestamp_seconds_array
date::zoned_time< Duration, TimeZonePtr > timestamp
constexpr bool is_timestamp_array_v
dynamic_bitset< std::uint8_t > validity_bitmap
timestamp_array< timestamp_nanosecond > timestamp_nanoseconds_array
timestamp< std::chrono::seconds > timestamp_second
validity_bitmap ensure_validity_bitmap(std::size_t size, R &&validity_input)
std::size_t range_size(R &&r)
timestamp< std::chrono::milliseconds > timestamp_millisecond
timestamp_array< timestamp_microsecond > timestamp_microseconds_array
ArrowArray make_arrow_array(int64_t length, int64_t null_count, int64_t offset, B buffers, size_t n_children, ArrowArray **children, ArrowArray *dictionary)
Creates an ArrowArray.
timestamp_array< timestamp_millisecond > timestamp_milliseconds_array
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 specialization.
Traits class that must be specialized by array classes inheriting from array_crtp_base.
Provides compile-time information about Arrow data types.