Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions Framework/AnalysisSupport/src/RNTuplePlugin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <arrow/array/array_primitive.h>
#include <arrow/array/builder_nested.h>
#include <arrow/array/builder_primitive.h>
#include <arrow/array/util.h>
#include <arrow/record_batch.h>
#include <arrow/dataset/file_base.h>

#if __has_include(<ROOT/RFieldBase.hxx>)
Expand Down Expand Up @@ -859,18 +861,19 @@ arrow::Result<arrow::RecordBatchGenerator> RNTupleFileFormat::ScanBatchesAsync(
}
switch (listSize) {
case -1: {
auto varray = std::make_shared<arrow::PrimitiveArray>(physicalField->type()->field(0)->type(), totalSize, arrowValuesBuffer);
array = std::make_shared<arrow::ListArray>(physicalField->type(), readEntries, arrowOffsetBuffer, varray);
auto vdata = std::make_shared<arrow::ArrayData>(physicalField->type()->field(0)->type(), totalSize, std::vector<std::shared_ptr<arrow::Buffer>>{nullptr, arrowValuesBuffer});
array = std::make_shared<arrow::ListArray>(physicalField->type(), readEntries, arrowOffsetBuffer, arrow::MakeArray(vdata));
} break;
case 1: {
totalSize = readEntries * listSize;
array = std::make_shared<arrow::PrimitiveArray>(physicalField->type(), readEntries, arrowValuesBuffer);
auto data = std::make_shared<arrow::ArrayData>(physicalField->type(), readEntries, std::vector<std::shared_ptr<arrow::Buffer>>{nullptr, arrowValuesBuffer});
array = arrow::MakeArray(data);

} break;
default: {
totalSize = readEntries * listSize;
auto varray = std::make_shared<arrow::PrimitiveArray>(physicalField->type()->field(0)->type(), totalSize, arrowValuesBuffer);
array = std::make_shared<arrow::FixedSizeListArray>(physicalField->type(), readEntries, varray);
auto vdata = std::make_shared<arrow::ArrayData>(physicalField->type()->field(0)->type(), totalSize, std::vector<std::shared_ptr<arrow::Buffer>>{nullptr, arrowValuesBuffer});
array = std::make_shared<arrow::FixedSizeListArray>(physicalField->type(), readEntries, arrow::MakeArray(vdata));
}
}
}
Expand Down
17 changes: 11 additions & 6 deletions Framework/AnalysisSupport/src/TTreePlugin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include <arrow/array/array_primitive.h>
#include <arrow/array/builder_nested.h>
#include <arrow/array/builder_primitive.h>
#include <arrow/array/util.h>
#include <arrow/record_batch.h>
#include <TTree.h>
#include <TBranch.h>
#include <TFile.h>
Expand All @@ -35,7 +37,6 @@
#include <cstdint>
#include <memory>
#include <stdexcept>
#include <iostream>

O2_DECLARE_DYNAMIC_LOG(root_arrow_fs);

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

if (listType) {
auto varray = std::make_shared<arrow::PrimitiveArray>(datasetField->type()->field(0)->type(), valueOp.rootBranchEntries * valueOp.listSize, valueOp.targetBuffer);
array = std::make_shared<arrow::FixedSizeListArray>(datasetField->type(), valueOp.rootBranchEntries, varray);
auto vdata = std::make_shared<arrow::ArrayData>(datasetField->type()->field(0)->type(), valueOp.rootBranchEntries * valueOp.listSize,
std::vector<std::shared_ptr<arrow::Buffer>>{nullptr, valueOp.targetBuffer});
array = std::make_shared<arrow::FixedSizeListArray>(datasetField->type(), valueOp.rootBranchEntries, arrow::MakeArray(vdata));
// This is a vla, there is also an offset op
O2_SIGNPOST_EVENT_EMIT(root_arrow_fs, tid, "Op", "Created op for branch %{public}s with %lli entries, size of the buffer %lli.",
valueOp.branch->GetName(),
valueOp.rootBranchEntries,
valueOp.targetBuffer->size());
} else if (mapping.vlaIdx != -1) {
auto& offsetOp = ops[ops.size() - 2];
auto varray = std::make_shared<arrow::PrimitiveArray>(datasetField->type()->field(0)->type(), offsetOp.offsetCount, valueOp.targetBuffer);
auto vdata = std::make_shared<arrow::ArrayData>(datasetField->type()->field(0)->type(), offsetOp.offsetCount,
std::vector<std::shared_ptr<arrow::Buffer>>{nullptr, valueOp.targetBuffer});
// We have pushed an offset op if this was the case.
array = std::make_shared<arrow::ListArray>(datasetField->type(), offsetOp.rootBranchEntries, offsetOp.targetBuffer, varray);
array = std::make_shared<arrow::ListArray>(datasetField->type(), offsetOp.rootBranchEntries, offsetOp.targetBuffer, arrow::MakeArray(vdata));
O2_SIGNPOST_EVENT_EMIT(root_arrow_fs, tid, "Op", "Created op for branch %{public}s with %lli entries, size of the buffer %lli.",
offsetOp.branch->GetName(), offsetOp.rootBranchEntries, offsetOp.targetBuffer->size());
O2_SIGNPOST_EVENT_EMIT(root_arrow_fs, tid, "Op", "Created op for branch %{public}s with %lli entries, size of the buffer %lli.",
valueOp.branch->GetName(),
offsetOp.offsetCount,
valueOp.targetBuffer->size());
} else {
array = std::make_shared<arrow::PrimitiveArray>(datasetField->type(), valueOp.rootBranchEntries, valueOp.targetBuffer);
auto data = std::make_shared<arrow::ArrayData>(datasetField->type(), valueOp.rootBranchEntries,
std::vector<std::shared_ptr<arrow::Buffer>>{nullptr, valueOp.targetBuffer});
array = arrow::MakeArray(data);
O2_SIGNPOST_EVENT_EMIT(root_arrow_fs, tid, "Op", "Created op for branch %{public}s with %lli entries, size of the buffer %lli.",
valueOp.branch->GetName(),
valueOp.rootBranchEntries,
Expand Down
11 changes: 8 additions & 3 deletions Framework/Core/src/EmptyFragment.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include "Framework/EmptyFragment.h"
#include <arrow/array/data.h>
#include <arrow/type_fwd.h>
#include <arrow/array/array_primitive.h>
#include <arrow/array/array_nested.h>
#include <arrow/record_batch.h>
#include <arrow/type.h>
#include <arrow/array/util.h>
#include <memory>

static constexpr int64_t kBufferMinimumSize = 256;
Expand All @@ -35,16 +39,17 @@ arrow::Result<arrow::RecordBatchGenerator> EmptyFragment::ScanBatchesAsync(
} else {
size *= field->type()->field(0)->type()->byte_width();
}
auto varray = std::make_shared<arrow::PrimitiveArray>(field->type()->field(0)->type(), mRows * listType->list_size(), GetPlaceholderForOp(size));
columns.push_back(std::make_shared<arrow::FixedSizeListArray>(field->type(), (int32_t)mRows, varray));
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)});
columns.push_back(std::make_shared<arrow::FixedSizeListArray>(field->type(), (int32_t)mRows, arrow::MakeArray(vdata)));
} else {
size_t size = mRows;
if (field->type()->byte_width() == 0) {
size /= 8;
} else {
size *= field->type()->byte_width();
}
columns.push_back(std::make_shared<arrow::PrimitiveArray>(field->type(), mRows, GetPlaceholderForOp(size)));
auto data = std::make_shared<arrow::ArrayData>(field->type(), mRows, std::vector<std::shared_ptr<arrow::Buffer>>{nullptr, GetPlaceholderForOp(size)});
columns.push_back(arrow::MakeArray(data));
}
}
return arrow::RecordBatch::Make(physical_schema_, mRows, columns);
Expand Down
1 change: 1 addition & 0 deletions Framework/Core/test/o2AO2DToAO3D.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <TMap.h>
#include <TTree.h>
#include <fmt/format.h>
#include <arrow/record_batch.h>

int main(int argc, char** argv)
{
Expand Down