Project
Loading...
Searching...
No Matches
FragmentToBatch.cxx
Go to the documentation of this file.
1// Copyright 2019-2025 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
12#include "Framework/Logger.h"
13#include "Framework/Endian.h"
14#include "Framework/Signpost.h"
15
16#include <arrow/dataset/file_base.h>
17#include <arrow/record_batch.h>
18#include <arrow/type.h>
19#include <arrow/util/key_value_metadata.h>
20#include <TBufferFile.h>
21
22#include <memory>
23#include <utility>
24
25O2_DECLARE_DYNAMIC_LOG(tabletree_helpers);
26
27namespace o2::framework
28{
29
30FragmentToBatch::FragmentToBatch(StreamerCreator creator, std::shared_ptr<arrow::dataset::FileFragment> fragment, arrow::MemoryPool* pool)
31 : mFragment{std::move(fragment)},
32 mArrowMemoryPool{pool},
33 mCreator{std::move(creator)}
34{
35}
36
38{
39 mTableLabel = label;
40}
41
42void FragmentToBatch::fill(std::shared_ptr<arrow::Schema> schema, std::shared_ptr<arrow::dataset::FileFormat> format)
43{
44 auto options = std::make_shared<arrow::dataset::ScanOptions>();
45 options->dataset_schema = schema;
46 auto scanner = format->ScanBatchesAsync(options, mFragment);
47 auto batch = (*scanner)();
48 mRecordBatch = *batch.result();
49 // Notice that up to here the buffer was not yet filled.
50}
51
52std::shared_ptr<arrow::RecordBatch> FragmentToBatch::finalize()
53{
54 return mRecordBatch;
55}
56
57} // namespace o2::framework
#define O2_DECLARE_DYNAMIC_LOG(name)
Definition Signpost.h:489
FragmentToBatch(StreamerCreator, std::shared_ptr< arrow::dataset::FileFragment >, arrow::MemoryPool *pool=arrow::default_memory_pool())
std::shared_ptr< arrow::RecordBatch > finalize()
std::function< std::shared_ptr< arrow::io::OutputStream >(std::shared_ptr< arrow::dataset::FileFragment >, const std::shared_ptr< arrow::ResizableBuffer > &buffer)> StreamerCreator
void setLabel(const char *label)
void fill(std::shared_ptr< arrow::Schema > dataSetSchema, std::shared_ptr< arrow::dataset::FileFormat >)
GLuint GLsizei const GLchar * label
Definition glcorearb.h:2519
GLint GLint GLsizei GLint GLenum format
Definition glcorearb.h:275
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
Defining DataPointCompositeObject explicitly as copiable.