@@ -361,9 +361,20 @@ void NumericArray<T>::PostConstruct(const ObjectMeta& meta) {
361
361
} else {
362
362
data_type = type_name_to_arrow_type (this ->data_type_ );
363
363
}
364
+
365
+ #if defined(ARROW_VERSION) && ARROW_VERSION >= 20000000
366
+ // use the factory method as the constructor is protected since 20.0.0
367
+ auto data = arrow::ArrayData::Make (
368
+ data_type, this ->length_ ,
369
+ {this ->null_bitmap_ ->ArrowBuffer (), this ->buffer_ ->ArrowBufferOrEmpty ()},
370
+ this ->null_count_ , this ->offset_ );
371
+ this ->array_ = std::static_pointer_cast<ArrayType>(arrow::MakeArray (data));
372
+ #else
373
+ // use the constructor
364
374
this ->array_ = std::make_shared<ArrayType>(
365
375
data_type, this ->length_ , this ->buffer_ ->ArrowBufferOrEmpty (),
366
376
this ->null_bitmap_ ->ArrowBuffer (), this ->null_count_ , this ->offset_ );
377
+ #endif
367
378
}
368
379
369
380
template class NumericArray <int8_t >;
@@ -584,10 +595,18 @@ template class FixedNumericArrayBuilder<arrow::Time64Type>;
584
595
template class FixedNumericArrayBuilder <arrow::TimestampType>;
585
596
586
597
void BooleanArray::PostConstruct (const ObjectMeta& meta) {
598
+ #if defined(ARROW_VERSION) && ARROW_VERSION >= 20000000
599
+ auto data = arrow::ArrayData::Make (
600
+ ConvertToArrowType<bool >::TypeValue (), this ->length_ ,
601
+ {this ->null_bitmap_ ->ArrowBuffer (), this ->buffer_ ->ArrowBufferOrEmpty ()},
602
+ this ->null_count_ , this ->offset_ );
603
+ this ->array_ = std::static_pointer_cast<ArrayType>(arrow::MakeArray (data));
604
+ #else
587
605
this ->array_ = std::make_shared<ArrayType>(
588
606
ConvertToArrowType<bool >::TypeValue (), this ->length_ ,
589
607
this ->buffer_ ->ArrowBufferOrEmpty (), this ->null_bitmap_ ->ArrowBuffer (),
590
608
this ->null_count_ , this ->offset_ );
609
+ #endif
591
610
}
592
611
593
612
BooleanArrayBuilder::BooleanArrayBuilder (Client& client)
@@ -642,10 +661,33 @@ Status BooleanArrayBuilder::Build(Client& client) {
642
661
643
662
template <typename ArrayType>
644
663
void BaseBinaryArray<ArrayType>::PostConstruct(const ObjectMeta& meta) {
664
+ #if defined(ARROW_VERSION) && ARROW_VERSION >= 20000000
665
+ std::shared_ptr<arrow::DataType> data_type;
666
+ if constexpr (std::is_same_v<ArrayType, arrow::StringArray>) {
667
+ data_type = arrow::utf8 ();
668
+ } else if constexpr (std::is_same_v<ArrayType, arrow::LargeStringArray>) {
669
+ data_type = arrow::large_utf8 ();
670
+ } else if constexpr (std::is_same_v<ArrayType, arrow::BinaryArray>) {
671
+ data_type = arrow::binary ();
672
+ } else if constexpr (std::is_same_v<ArrayType, arrow::LargeBinaryArray>) {
673
+ data_type = arrow::large_binary ();
674
+ } else {
675
+ VINEYARD_ASSERT (false , " Unsupported array type: " +
676
+ std::to_string (ArrayType::type_id ()));
677
+ }
678
+ auto data =
679
+ arrow::ArrayData::Make (data_type, this ->length_ ,
680
+ {this ->null_bitmap_ ->ArrowBuffer (),
681
+ this ->buffer_offsets_ ->ArrowBufferOrEmpty (),
682
+ this ->buffer_data_ ->ArrowBufferOrEmpty ()},
683
+ this ->null_count_ , this ->offset_ );
684
+ this ->array_ = std::static_pointer_cast<ArrayType>(arrow::MakeArray (data));
685
+ #else
645
686
this ->array_ = std::make_shared<ArrayType>(
646
687
this ->length_ , this ->buffer_offsets_ ->ArrowBufferOrEmpty (),
647
688
this ->buffer_data_ ->ArrowBufferOrEmpty (),
648
689
this ->null_bitmap_ ->ArrowBuffer (), this ->null_count_ , this ->offset_ );
690
+ #endif
649
691
}
650
692
651
693
template class BaseBinaryArray <arrow::BinaryArray>;
@@ -722,10 +764,19 @@ template class GenericBinaryArrayBuilder<arrow::LargeStringArray,
722
764
arrow::LargeStringBuilder>;
723
765
724
766
void FixedSizeBinaryArray::PostConstruct (const ObjectMeta& meta) {
767
+ #if defined(ARROW_VERSION) && ARROW_VERSION >= 20000000
768
+ auto data = arrow::ArrayData::Make (
769
+ arrow::fixed_size_binary (this ->byte_width_ ), this ->length_ ,
770
+ {this ->null_bitmap_ ->ArrowBuffer (), this ->buffer_ ->ArrowBufferOrEmpty ()},
771
+ this ->null_count_ , this ->offset_ );
772
+ this ->array_ = std::static_pointer_cast<arrow::FixedSizeBinaryArray>(
773
+ arrow::MakeArray (data));
774
+ #else
725
775
this ->array_ = std::make_shared<arrow::FixedSizeBinaryArray>(
726
776
arrow::fixed_size_binary (this ->byte_width_ ), this ->length_ ,
727
777
this ->buffer_ ->ArrowBufferOrEmpty (), this ->null_bitmap_ ->ArrowBuffer (),
728
778
this ->null_count_ , this ->offset_ );
779
+ #endif
729
780
}
730
781
731
782
FixedSizeBinaryArrayBuilder::FixedSizeBinaryArrayBuilder (
@@ -784,7 +835,13 @@ Status FixedSizeBinaryArrayBuilder::Build(Client& client) {
784
835
}
785
836
786
837
void NullArray::PostConstruct (const ObjectMeta& meta) {
838
+ #if defined(ARROW_VERSION) && ARROW_VERSION >= 20000000
839
+ auto data = arrow::ArrayData::Make (arrow::null (), this ->length_ , {}, 0 );
840
+ this ->array_ =
841
+ std::static_pointer_cast<arrow::NullArray>(arrow::MakeArray (data));
842
+ #else
787
843
this ->array_ = std::make_shared<arrow::NullArray>(this ->length_ );
844
+ #endif
788
845
}
789
846
790
847
NullArrayBuilder::NullArrayBuilder (Client& client)
@@ -831,10 +888,19 @@ void BaseListArray<ArrayType>::PostConstruct(const ObjectMeta& meta) {
831
888
auto array = detail::CastToArray (values_);
832
889
auto list_type =
833
890
std::make_shared<typename ArrayType::TypeClass>(array->type ());
891
+ #if defined(ARROW_VERSION) && ARROW_VERSION >= 20000000
892
+ auto data =
893
+ arrow::ArrayData::Make (list_type, this ->length_ ,
894
+ {this ->null_bitmap_ ->ArrowBuffer (),
895
+ this ->buffer_offsets_ ->ArrowBufferOrEmpty ()},
896
+ {array->data ()}, this ->null_count_ , this ->offset_ );
897
+ this ->array_ = std::static_pointer_cast<ArrayType>(arrow::MakeArray (data));
898
+ #else
834
899
this ->array_ = std::make_shared<ArrayType>(
835
900
list_type, this ->length_ , this ->buffer_offsets_ ->ArrowBufferOrEmpty (),
836
901
array, this ->null_bitmap_ ->ArrowBuffer (), this ->null_count_ ,
837
902
this ->offset_ );
903
+ #endif
838
904
}
839
905
840
906
template class BaseListArray <arrow::ListArray>;
@@ -920,9 +986,18 @@ template class BaseListArrayBuilder<arrow::LargeListArray>;
920
986
921
987
void FixedSizeListArray::PostConstruct (const ObjectMeta& meta) {
922
988
auto array = detail::CastToArray (values_);
989
+ #if defined(ARROW_VERSION) && ARROW_VERSION >= 20000000
990
+ auto list_type = arrow::fixed_size_list (array->type (), this ->list_size_ );
991
+
992
+ auto data = arrow::ArrayData::Make (list_type, this ->length_ , {nullptr },
993
+ {array->data ()}, 0 , 0 );
994
+ this ->array_ = std::static_pointer_cast<arrow::FixedSizeListArray>(
995
+ arrow::MakeArray (data));
996
+ #else
923
997
this ->array_ = std::make_shared<arrow::FixedSizeListArray>(
924
998
arrow::fixed_size_list (array->type (), this ->list_size_ ), this ->length_ ,
925
999
array);
1000
+ #endif
926
1001
}
927
1002
928
1003
FixedSizeListArrayBuilder::FixedSizeListArrayBuilder (
0 commit comments