OpenMS
Loading...
Searching...
No Matches
ParquetTableComparator Class Reference

Primary-key-aware, order-insensitive, tolerant comparison of Parquet tables. More...

#include <OpenMS/FORMAT/ParquetTableComparator.h>

Static Public Member Functions

static ParquetDiffResult compare (const std::string &file_1, const std::string &file_2, const ParquetDiffSettings &settings)
 Compare two Parquet files.
 
static ParquetDiffResult validate (const std::string &file, const std::string &view, const ParquetDiffSettings &settings)
 Check one Parquet file against a built-in QPX schema.
 
static std::vector< std::string > qpxPrimaryKey (const std::string &view)
 The primary key of a QPX view.
 
static std::string viewFromFileType (const std::string &file_type)
 Map a QPX file_type metadata value to a view name.
 

Detailed Description

Primary-key-aware, order-insensitive, tolerant comparison of Parquet tables.

Two Parquet files holding the same logical table may legitimately differ in row order and in the low-order bits of floating-point columns, so neither a byte comparison nor a text diff of a serialised form answers "are these the same result?". This class matches rows by a primary key, compares the matched rows cell-by-cell with a numeric tolerance, and reports schema drift separately from value drift.

It is the table-shaped counterpart of FuzzyDiff, and is exposed as ParquetDiff.

Note
All Arrow/Parquet API use is confined to the implementation, so binaries linking libOpenMS do not need to import Arrow symbols (see ArrowIOHelpers.h).

Member Function Documentation

◆ compare()

static ParquetDiffResult compare ( const std::string &  file_1,
const std::string &  file_2,
const ParquetDiffSettings &  settings 
)
static

Compare two Parquet files.

Rows are matched on ParquetDiffSettings::primary_key. List-valued key columns are canonicalised by sorting their elements before the key is formed, matching how QPX treats set-valued key columns such as grouped_runs.

Parameters
[in]file_1first Parquet file
[in]file_2second Parquet file
[in]settingstolerance, key and reporting options
Returns
the differences found; ParquetDiffResult::equal is true when there are none

◆ qpxPrimaryKey()

static std::vector< std::string > qpxPrimaryKey ( const std::string &  view)
static

The primary key of a QPX view.

Parameters
[in]viewone of psm, feature, pg
Returns
the key columns, in order
Exceptions
Exception::IllegalArgumentif view is not a known view name

◆ validate()

static ParquetDiffResult validate ( const std::string &  file,
const std::string &  view,
const ParquetDiffSettings &  settings 
)
static

Check one Parquet file against a built-in QPX schema.

Reports columns the view requires but the file lacks, columns whose Arrow type differs from the schema, and columns the file carries that the view does not define. Duplicate primary keys are reported as well, since a QPX primary key must be unique.

Parameters
[in]filethe Parquet file to check
[in]viewone of psm, feature, pg
[in]settingsreporting options (tolerances are unused)
Returns
the violations found; ParquetDiffResult::equal is true when there are none
Exceptions
Exception::IllegalArgumentif view is not a known view name

◆ viewFromFileType()

static std::string viewFromFileType ( const std::string &  file_type)
static

Map a QPX file_type metadata value to a view name.

Parameters
[in]file_typee.g. psm_file, feature_file, pg_file
Returns
the view name, or an empty string when file_type is not recognised