11#include <OpenMS/config.h>
23#include <unordered_set>
30 class KeyValueMetadata;
38class MetaInfoInterface;
39namespace MS1LabelState {
struct Keys; }
50namespace ArrowIOHelpers
84 const std::shared_ptr<arrow::Table>& table,
85 const std::string& filename,
104 enum class Type { INT16, INT64, UTF8, FLOAT_LIST, UTF8_LIST, SCORE_LIST, INT32, BOOL,
DOUBLE, STRUCT_LIST, FLOAT, INT32_LIST };
110 StructField(std::string field_name,
Type field_type,
bool field_nullable =
true, std::vector<StructField> struct_fields = {}) :
111 name(
std::move(field_name)), type(field_type), nullable(field_nullable), fields(
std::move(struct_fields)) {}
114 bool nullable =
true;
124 std::variant<std::monostate, std::string, Int32, bool, double, std::vector<StructEntry>>
value;
137 bool nullable =
true;
163 const std::shared_ptr<arrow::Table>& table,
164 const std::vector<ParquetColumn>& columns);
176 const std::vector<ParquetColumn>& columns,
195 const std::vector<std::shared_ptr<arrow::Table>>& tables,
196 const std::string& filename,
198 const std::shared_ptr<const arrow::KeyValueMetadata>& metadata =
nullptr);
227 const std::string& file_type,
229 const std::map<std::string, std::string>& extra = {});
249 OPENMS_DLLAPI std::string
qpxScanFormat(
const std::vector<std::string>& native_ids);
320 const std::string& resolved_run_file,
337 const std::string& context,
338 const std::vector<std::string>& ms_run_paths);
364 const std::string& column_label,
365 const std::string& channel_name);
427 const std::shared_ptr<arrow::Table>& table,
428 const std::string& name,
429 bool required =
true);
433 const std::shared_ptr<arrow::Array>& array,
438 const std::shared_ptr<arrow::Array>& array,
440 double default_val = 0.0);
444 const std::shared_ptr<arrow::Array>& array,
446 float default_val = 0.0f);
450 const std::shared_ptr<arrow::Array>& array,
452 int32_t default_val = 0);
456 const std::shared_ptr<arrow::Array>& array,
458 int64_t default_val = 0);
462 const std::shared_ptr<arrow::Array>& array,
464 bool default_val =
false);
468 const std::shared_ptr<arrow::Array>& array,
487 const std::shared_ptr<arrow::Array>& array,
490 const std::unordered_set<std::string>& excluded_keys = {});
A container for consensus elements.
Definition ConsensusMap.h:67
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition DataValue.h:33
int32_t Int32
Signed integer type (32bit)
Definition Types.h:26
unsigned int UInt
Unsigned integer type.
Definition Types.h:64
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
std::string qpxPsmRunFileName(const MetaInfoInterface &hit, const MetaInfoInterface &identification, const std::string &resolved_run_file, const QPXRunFileNameKeys &keys)
The QPX run_file_name the psm view writes for one identification and hit.
int32_t getInt32Value(const std::shared_ptr< arrow::Array > &array, int64_t row, int32_t default_val=0)
Read an int32 at row, or default_val if null.
bool writeTableToParquet(const std::shared_ptr< arrow::Table > &table, const std::string &filename, const ParquetWriteConfig &config=ParquetWriteConfig{})
Write an Arrow table to a Parquet file.
int64_t getInt64Value(const std::shared_ptr< arrow::Array > &array, int64_t row, int64_t default_val=0)
Read an int64 at row, or default_val if null.
bool getBoolValue(const std::shared_ptr< arrow::Array > &array, int64_t row, bool default_val=false)
Read a bool at row, or default_val if null.
std::vector< Int32 > qpxScanComponents(const std::string &spectrum_reference)
The QPX scan column value for one spectrum reference.
float getFloatValue(const std::shared_ptr< arrow::Array > &array, int64_t row, float default_val=0.0f)
Read a float at row, or default_val if null.
std::vector< std::pair< std::string, std::string > > qpxCvParams(const MetaInfoInterface &hit)
The meta values of an identification that QPX carries as cv_params.
double getDoubleValue(const std::shared_ptr< arrow::Array > &array, int64_t row, double default_val=0.0)
Read a double at row, or default_val if null.
std::string generateUuidV4()
Generate a lowercase hyphenated RFC 4122 version-4 UUID string.
void readMetaValues(const std::shared_ptr< arrow::Array > &array, int64_t row, MetaInfoInterface &target, const std::unordered_set< std::string > &excluded_keys={})
Read metavalues from a list<struct{name,value,value_type}> column.
std::shared_ptr< arrow::Array > getColumn(const std::shared_ptr< arrow::Table > &table, const std::string &name, bool required=true)
Fetch a named column from a table, combining chunks if needed.
std::string qpxIntensityLabel(const std::string &column_label, const std::string &channel_name)
QPX intensities[].label for a ConsensusMap column header.
std::string qpxRunFileName(const std::string &ms_run_path)
Reduce an MS run path to the QPX run_file_name form.
std::string getStringValue(const std::shared_ptr< arrow::Array > &array, int64_t row)
Read a string at row, or "" if null/out-of-bounds.
bool qpxIsCanonicalIntensityLabel(const std::string &label)
Test whether a string is in the canonical SDRF/QPX intensity-label vocabulary.
std::shared_ptr< arrow::Table > tableOfColumns(const std::vector< ParquetColumn > &columns, Size rows)
A table of columns (in their order, without schema metadata), for callers outside libOpenMS that cann...
std::string qpxScanFormat(const std::string &native_id)
Classify a spectrum native ID into a QPX scan_format token.
std::shared_ptr< arrow::Table > withColumns(const std::shared_ptr< arrow::Table > &table, const std::vector< ParquetColumn > &columns)
The table with columns added: a column of the name of an existing one replaces it (in its place),...
bool concatenateAndWriteToParquet(const std::vector< std::shared_ptr< arrow::Table > > &tables, const std::string &filename, const ParquetWriteConfig &config=ParquetWriteConfig{}, const std::shared_ptr< const arrow::KeyValueMetadata > &metadata=nullptr)
Concatenate a vector of Arrow tables and write the result to a Parquet file.
std::shared_ptr< const arrow::KeyValueMetadata > qpxFileMetadata(const std::string &file_type, const ParquetWriteConfig &config=ParquetWriteConfig{}, const std::map< std::string, std::string > &extra={})
Build the canonical QPX file-level key-value metadata.
bool qpxWarnOnRunNameCollisions(const std::string &context, const std::vector< std::string > &ms_run_paths)
Warn once per export about source files that collapse onto one run_file_name.
bool isNull(const std::shared_ptr< arrow::Array > &array, int64_t row)
Whether array is null at row (or unset)
Size tableRowCount(const std::shared_ptr< arrow::Table > &table)
Number of rows in an Arrow table, or 0 when it is null.
std::map< std::uint64_t, std::string > qpxIntensityLabels(const ConsensusMap &cmap)
Derive canonical QPX intensity labels for every ConsensusMap column.
std::string metaValueString(const DataValue &value)
The text a metavalue is written as in a list<struct{name,value,value_type}> column.
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Definition ArrowIOHelpers.h:28
Definition ArrowIOHelpers.h:108
std::vector< StructField > fields
STRUCT_LIST: the fields of its struct.
Definition ArrowIOHelpers.h:115
StructField(std::string field_name, Type field_type, bool field_nullable=true, std::vector< StructField > struct_fields={})
Definition ArrowIOHelpers.h:110
std::string name
Definition ArrowIOHelpers.h:112
Definition ArrowIOHelpers.h:123
std::variant< std::monostate, std::string, Int32, bool, double, std::vector< StructEntry > > value
Definition ArrowIOHelpers.h:124
StructValue(Int32 v)
Definition ArrowIOHelpers.h:128
StructValue(const char *v)
(not a bool)
Definition ArrowIOHelpers.h:127
StructValue(const std::optional< T > &v)
Definition ArrowIOHelpers.h:132
StructValue(bool v)
Definition ArrowIOHelpers.h:129
StructValue()=default
null
StructValue(std::string v)
Definition ArrowIOHelpers.h:126
StructValue(double v)
Definition ArrowIOHelpers.h:130
StructValue(std::vector< StructEntry > v)
Definition ArrowIOHelpers.h:131
One column for withColumns(), built without Arrow types.
Definition ArrowIOHelpers.h:94
std::vector< std::vector< StructEntry > > struct_lists
STRUCT_LIST: per row its entries.
Definition ArrowIOHelpers.h:146
std::vector< std::vector< std::string > > utf8_lists
UTF8_LIST.
Definition ArrowIOHelpers.h:143
Type
Definition ArrowIOHelpers.h:104
std::vector< Int64 > int64_values
INT16 and INT32 (narrowed, range-checked), INT64, BOOL (0: false)
Definition ArrowIOHelpers.h:138
std::vector< bool > null_rows
true marks a null row (empty: no null row)
Definition ArrowIOHelpers.h:147
std::vector< StructValue > StructEntry
An entry of a STRUCT_LIST: one value per field.
Definition ArrowIOHelpers.h:119
std::optional< bool > higher_better
none: unknown (null)
Definition ArrowIOHelpers.h:100
std::vector< double > double_values
DOUBLE, FLOAT (narrowed)
Definition ArrowIOHelpers.h:139
std::string name
Definition ArrowIOHelpers.h:98
std::vector< std::vector< Score > > score_lists
SCORE_LIST.
Definition ArrowIOHelpers.h:144
std::vector< std::string > utf8_values
UTF8.
Definition ArrowIOHelpers.h:140
std::vector< std::vector< Int32 > > int32_lists
INT32_LIST.
Definition ArrowIOHelpers.h:142
std::vector< std::vector< float > > float_lists
FLOAT_LIST.
Definition ArrowIOHelpers.h:141
std::vector< StructField > struct_fields
STRUCT_LIST: the fields of its struct.
Definition ArrowIOHelpers.h:145
An entry of a SCORE_LIST row: the struct of the QPX additional_scores (QPXPSMSchema::additionalScores...
Definition ArrowIOHelpers.h:97
MetaInfo indices qpxPsmRunFileName() consults, resolved once.
Definition ArrowIOHelpers.h:289
QPXRunFileNameKeys()
Resolve the keys against the current registry.
UInt run_file_name
Index of run_file_name, or UInt(-1) when it is not registered.
Definition ArrowIOHelpers.h:295
UInt reference_file_name
Index of reference_file_name, or UInt(-1) when it is not registered.
Definition ArrowIOHelpers.h:293
The registry indices of the three keys, resolved once for a loop over many hits.
Definition MS1LabelState.h:65
Configuration for Parquet file writing.
Definition MSExperimentArrowExport.h:136