Skip to content

Commit e1f9cdc

Browse files
authored
DPL: adapt to arrow 20.0.0 (#14332)
1 parent 49882f7 commit e1f9cdc

File tree

4 files changed

+28
-14
lines changed

4 files changed

+28
-14
lines changed

Framework/AnalysisSupport/src/RNTuplePlugin.cxx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include <arrow/array/array_primitive.h>
3131
#include <arrow/array/builder_nested.h>
3232
#include <arrow/array/builder_primitive.h>
33+
#include <arrow/array/util.h>
34+
#include <arrow/record_batch.h>
3335
#include <arrow/dataset/file_base.h>
3436

3537
#if __has_include(<ROOT/RFieldBase.hxx>)
@@ -859,18 +861,19 @@ arrow::Result<arrow::RecordBatchGenerator> RNTupleFileFormat::ScanBatchesAsync(
859861
}
860862
switch (listSize) {
861863
case -1: {
862-
auto varray = std::make_shared<arrow::PrimitiveArray>(physicalField->type()->field(0)->type(), totalSize, arrowValuesBuffer);
863-
array = std::make_shared<arrow::ListArray>(physicalField->type(), readEntries, arrowOffsetBuffer, varray);
864+
auto vdata = std::make_shared<arrow::ArrayData>(physicalField->type()->field(0)->type(), totalSize, std::vector<std::shared_ptr<arrow::Buffer>>{nullptr, arrowValuesBuffer});
865+
array = std::make_shared<arrow::ListArray>(physicalField->type(), readEntries, arrowOffsetBuffer, arrow::MakeArray(vdata));
864866
} break;
865867
case 1: {
866868
totalSize = readEntries * listSize;
867-
array = std::make_shared<arrow::PrimitiveArray>(physicalField->type(), readEntries, arrowValuesBuffer);
869+
auto data = std::make_shared<arrow::ArrayData>(physicalField->type(), readEntries, std::vector<std::shared_ptr<arrow::Buffer>>{nullptr, arrowValuesBuffer});
870+
array = arrow::MakeArray(data);
868871

869872
} break;
870873
default: {
871874
totalSize = readEntries * listSize;
872-
auto varray = std::make_shared<arrow::PrimitiveArray>(physicalField->type()->field(0)->type(), totalSize, arrowValuesBuffer);
873-
array = std::make_shared<arrow::FixedSizeListArray>(physicalField->type(), readEntries, varray);
875+
auto vdata = std::make_shared<arrow::ArrayData>(physicalField->type()->field(0)->type(), totalSize, std::vector<std::shared_ptr<arrow::Buffer>>{nullptr, arrowValuesBuffer});
876+
array = std::make_shared<arrow::FixedSizeListArray>(physicalField->type(), readEntries, arrow::MakeArray(vdata));
874877
}
875878
}
876879
}

Framework/AnalysisSupport/src/TTreePlugin.cxx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <arrow/array/array_primitive.h>
2828
#include <arrow/array/builder_nested.h>
2929
#include <arrow/array/builder_primitive.h>
30+
#include <arrow/array/util.h>
31+
#include <arrow/record_batch.h>
3032
#include <TTree.h>
3133
#include <TBranch.h>
3234
#include <TFile.h>
@@ -35,7 +37,6 @@
3537
#include <cstdint>
3638
#include <memory>
3739
#include <stdexcept>
38-
#include <iostream>
3940

4041
O2_DECLARE_DYNAMIC_LOG(root_arrow_fs);
4142

@@ -729,26 +730,30 @@ arrow::Result<arrow::RecordBatchGenerator> TTreeFileFormat::ScanBatchesAsync(
729730
std::shared_ptr<arrow::Array> array;
730731

731732
if (listType) {
732-
auto varray = std::make_shared<arrow::PrimitiveArray>(datasetField->type()->field(0)->type(), valueOp.rootBranchEntries * valueOp.listSize, valueOp.targetBuffer);
733-
array = std::make_shared<arrow::FixedSizeListArray>(datasetField->type(), valueOp.rootBranchEntries, varray);
733+
auto vdata = std::make_shared<arrow::ArrayData>(datasetField->type()->field(0)->type(), valueOp.rootBranchEntries * valueOp.listSize,
734+
std::vector<std::shared_ptr<arrow::Buffer>>{nullptr, valueOp.targetBuffer});
735+
array = std::make_shared<arrow::FixedSizeListArray>(datasetField->type(), valueOp.rootBranchEntries, arrow::MakeArray(vdata));
734736
// This is a vla, there is also an offset op
735737
O2_SIGNPOST_EVENT_EMIT(root_arrow_fs, tid, "Op", "Created op for branch %{public}s with %lli entries, size of the buffer %lli.",
736738
valueOp.branch->GetName(),
737739
valueOp.rootBranchEntries,
738740
valueOp.targetBuffer->size());
739741
} else if (mapping.vlaIdx != -1) {
740742
auto& offsetOp = ops[ops.size() - 2];
741-
auto varray = std::make_shared<arrow::PrimitiveArray>(datasetField->type()->field(0)->type(), offsetOp.offsetCount, valueOp.targetBuffer);
743+
auto vdata = std::make_shared<arrow::ArrayData>(datasetField->type()->field(0)->type(), offsetOp.offsetCount,
744+
std::vector<std::shared_ptr<arrow::Buffer>>{nullptr, valueOp.targetBuffer});
742745
// We have pushed an offset op if this was the case.
743-
array = std::make_shared<arrow::ListArray>(datasetField->type(), offsetOp.rootBranchEntries, offsetOp.targetBuffer, varray);
746+
array = std::make_shared<arrow::ListArray>(datasetField->type(), offsetOp.rootBranchEntries, offsetOp.targetBuffer, arrow::MakeArray(vdata));
744747
O2_SIGNPOST_EVENT_EMIT(root_arrow_fs, tid, "Op", "Created op for branch %{public}s with %lli entries, size of the buffer %lli.",
745748
offsetOp.branch->GetName(), offsetOp.rootBranchEntries, offsetOp.targetBuffer->size());
746749
O2_SIGNPOST_EVENT_EMIT(root_arrow_fs, tid, "Op", "Created op for branch %{public}s with %lli entries, size of the buffer %lli.",
747750
valueOp.branch->GetName(),
748751
offsetOp.offsetCount,
749752
valueOp.targetBuffer->size());
750753
} else {
751-
array = std::make_shared<arrow::PrimitiveArray>(datasetField->type(), valueOp.rootBranchEntries, valueOp.targetBuffer);
754+
auto data = std::make_shared<arrow::ArrayData>(datasetField->type(), valueOp.rootBranchEntries,
755+
std::vector<std::shared_ptr<arrow::Buffer>>{nullptr, valueOp.targetBuffer});
756+
array = arrow::MakeArray(data);
752757
O2_SIGNPOST_EVENT_EMIT(root_arrow_fs, tid, "Op", "Created op for branch %{public}s with %lli entries, size of the buffer %lli.",
753758
valueOp.branch->GetName(),
754759
valueOp.rootBranchEntries,

Framework/Core/src/EmptyFragment.cxx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111
#include "Framework/EmptyFragment.h"
12+
#include <arrow/array/data.h>
1213
#include <arrow/type_fwd.h>
1314
#include <arrow/array/array_primitive.h>
1415
#include <arrow/array/array_nested.h>
16+
#include <arrow/record_batch.h>
17+
#include <arrow/type.h>
18+
#include <arrow/array/util.h>
1519
#include <memory>
1620

1721
static constexpr int64_t kBufferMinimumSize = 256;
@@ -35,16 +39,17 @@ arrow::Result<arrow::RecordBatchGenerator> EmptyFragment::ScanBatchesAsync(
3539
} else {
3640
size *= field->type()->field(0)->type()->byte_width();
3741
}
38-
auto varray = std::make_shared<arrow::PrimitiveArray>(field->type()->field(0)->type(), mRows * listType->list_size(), GetPlaceholderForOp(size));
39-
columns.push_back(std::make_shared<arrow::FixedSizeListArray>(field->type(), (int32_t)mRows, varray));
42+
auto vdata = std::make_shared<arrow::ArrayData>(field->type()->field(0)->type(), mRows * listType->list_size(), std::vector<std::shared_ptr<arrow::Buffer>>{nullptr, GetPlaceholderForOp(size)});
43+
columns.push_back(std::make_shared<arrow::FixedSizeListArray>(field->type(), (int32_t)mRows, arrow::MakeArray(vdata)));
4044
} else {
4145
size_t size = mRows;
4246
if (field->type()->byte_width() == 0) {
4347
size /= 8;
4448
} else {
4549
size *= field->type()->byte_width();
4650
}
47-
columns.push_back(std::make_shared<arrow::PrimitiveArray>(field->type(), mRows, GetPlaceholderForOp(size)));
51+
auto data = std::make_shared<arrow::ArrayData>(field->type(), mRows, std::vector<std::shared_ptr<arrow::Buffer>>{nullptr, GetPlaceholderForOp(size)});
52+
columns.push_back(arrow::MakeArray(data));
4853
}
4954
}
5055
return arrow::RecordBatch::Make(physical_schema_, mRows, columns);

Framework/Core/test/o2AO2DToAO3D.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <TMap.h>
1919
#include <TTree.h>
2020
#include <fmt/format.h>
21+
#include <arrow/record_batch.h>
2122

2223
int main(int argc, char** argv)
2324
{

0 commit comments

Comments
 (0)