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/Signpost.h"
14
15#include <arrow/dataset/file_base.h>
16#include <arrow/record_batch.h>
17#include <arrow/type.h>
18#include <arrow/util/key_value_metadata.h>
19#include <TBufferFile.h>
20
21#include <memory>
22#include <utility>
23
24O2_DECLARE_DYNAMIC_LOG(tabletree_helpers);
25
26namespace o2::framework
27{
28
29FragmentToBatch::FragmentToBatch(StreamerCreator creator, std::shared_ptr<arrow::dataset::FileFragment> fragment, arrow::MemoryPool* pool)
30 : mFragment{std::move(fragment)},
31 mArrowMemoryPool{pool},
32 mCreator{std::move(creator)}
33{
34}
35
37{
38 mTableLabel = label;
39}
40
41void FragmentToBatch::fill(std::shared_ptr<arrow::Schema> schema, std::shared_ptr<arrow::dataset::FileFormat> format)
42{
43 auto options = std::make_shared<arrow::dataset::ScanOptions>();
44 options->dataset_schema = schema;
45 auto scanner = format->ScanBatchesAsync(options, mFragment);
46 auto batch = (*scanner)();
47 mRecordBatch = *batch.result();
48 // Notice that up to here the buffer was not yet filled.
49}
50
51std::shared_ptr<arrow::RecordBatch> FragmentToBatch::finalize()
52{
53 return mRecordBatch;
54}
55
56} // namespace o2::framework
std::shared_ptr< arrow::Schema > schema
#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 ITS Vertex explicitly as messageable.
Definition Cartesian.h:288