OpenMS
Loading...
Searching...
No Matches
ParquetFile.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Justin Sing $
6// $Authors: Justin Sing $
7// --------------------------------------------------------------------------
8
9#pragma once
10
11#include <OpenMS/config.h>
14#include <OpenMS/SYSTEM/File.h>
15
16#ifdef WITH_PARQUET
17#include <arrow/api.h>
18#include <arrow/io/file.h>
19#include <parquet/arrow/writer.h>
20#include <parquet/arrow/reader.h>
21#endif
22
23#include <memory>
24#include <string>
25#include <vector>
26
27namespace OpenMS
28{
29
49 class OPENMS_DLLAPI ParquetFile
50 {
51 public:
52#ifdef WITH_PARQUET
53
57
66 static void appendOrThrow(const arrow::Status& status, const std::string& column);
67
78 template <typename BuilderT>
79 static std::shared_ptr<arrow::Array> finishArray(BuilderT& builder, const std::string& name)
80 {
81 std::shared_ptr<arrow::Array> array;
82 auto status = builder.Finish(&array);
83 if (!status.ok())
84 {
85 throw_finish_error_(name, status.ToString());
86 }
87 return array;
88 }
89
91
95
106 static void writeTable(const std::shared_ptr<arrow::Table>& table, const String& filename,
107 int64_t row_group_size = 262144);
108
120 static std::shared_ptr<arrow::Table> readTable(const String& filename);
126 static std::shared_ptr<arrow::Table> readTable(const std::shared_ptr<arrow::io::RandomAccessFile>& infile);
127
129
133
145 static std::shared_ptr<arrow::Array> getColumn(const std::shared_ptr<arrow::Table>& table,
146 const std::string& name);
147
158 static std::shared_ptr<arrow::Array> getOptionalColumn(const std::shared_ptr<arrow::Table>& table,
159 const std::string& name);
160
162
166
182 static int64_t getInt64(const std::shared_ptr<arrow::Array>& array, int64_t row,
183 int64_t default_value, bool allow_null);
184
200 static double getDouble(const std::shared_ptr<arrow::Array>& array, int64_t row,
201 double default_value, bool allow_null);
202
218 static bool getBool(const std::shared_ptr<arrow::Array>& array, int64_t row,
219 bool default_value, bool allow_null);
220
233 static std::string getString(const std::shared_ptr<arrow::Array>& array, int64_t row);
234
247 static std::vector<std::string> getStringList(const std::shared_ptr<arrow::Array>& array, int64_t row);
248
250
254
262 static std::string jsonEscape(const String& input);
263
268 static int64_t rowCount(const String& filename);
269
271
272#endif // WITH_PARQUET
273
274 private:
275#ifdef WITH_PARQUET
277 static void throw_finish_error_(const std::string& name, const std::string& error);
278#endif
279 };
280
281} // namespace OpenMS
A more convenient string class.
Definition String.h:34
Shared utilities for reading, writing, and packaging Parquet-based file formats.
Definition ParquetFile.h:50
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19