CORSIKA  @c8_version@
The framework to simulate particle cascades for astroparticle physics
ParquetStreamer.hpp
1 
2 /*
3  * (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu
4  *
5  * This software is distributed under the terms of the GNU General Public
6  * Licence version 3 (GPL Version 3). See file LICENSE for a full version of
7  * the license.
8  */
9 
10 #pragma once
11 
12 #include <string>
13 
14 // clang-format-off, NOTE: the order of these includes is *important*
15 // you will get unhelpful compiler errors about unknown
16 // operator definitions if these are reordered
17 #include <parquet/stream_writer.h>
18 #include <parquet/arrow/schema.h>
19 #include <arrow/io/file.h>
20 // clang-format-on
21 
22 namespace corsika {
23 
29 
30  public:
35 
39  void initStreamer(std::string const& filepath);
40 
44  template <typename... TArgs>
45  void addField(TArgs&&... args);
46 
50  void enableCompression(int const level = 3);
51 
55  void buildStreamer();
56 
60  void closeStreamer();
61 
65  std::shared_ptr<parquet::StreamWriter> getWriter();
66 
70  bool isInit() const { return isInit_; }
71 
72  private:
73  bool isInit_ = false;
74  parquet::WriterProperties::Builder builder_;
75  parquet::schema::NodeVector fields_;
76  std::shared_ptr<parquet::schema::GroupNode> schema_;
77  std::shared_ptr<arrow::io::FileOutputStream> outfile_;
78  std::shared_ptr<parquet::StreamWriter> writer_;
79 
80  }; // class ParquetStreamer
81 } // namespace corsika
82 
83 #include <corsika/detail/output/ParquetStreamer.inl>
void closeStreamer()
Finish writing this stream.
void initStreamer(std::string const &filepath)
Initialize the streamer to write to a given file.
void enableCompression(int const level=3)
Enable compression for this streamer.
void buildStreamer()
Finalize the streamer construction.
This class automates the construction of simple tabular Parquet files using the parquet::StreamWriter...
std::shared_ptr< parquet::StreamWriter > getWriter()
Return a reference to the underlying writer.
`, since they are used everywhere as integral part of the framework.
ParquetStreamer()
ParquetStreamer&#39;s take no constructor arguments.
void addField(TArgs &&... args)
Add a field to this streamer.