Skip to content

[INTERNAL,TEST] deduplicate XIC/XIM parquet reader helpers - #9691

Merged
timosachsenberg merged 5 commits into
OpenMS:developfrom
singjc:refactor/xic_xim_helpers
Jun 30, 2026
Merged

timosachsenberg merged 5 commits into
OpenMS:developfrom
singjc:refactor/xic_xim_helpers

Conversation

@singjc

@singjc singjc commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

Address #9688, extract shared Arrow/Parquet reader plumbing into an internal helper used by XICParquetFile and XIMParquetFile.

Keep the public reader and row-struct APIs unchanged, and add regression coverage for LARGE_STRING plus FLOAT/DOUBLE parquet column handling.

Checklist

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

How can I get additional information on failed tests during CI

Click to expand If your PR is failing you can check out

Advanced commands (admins / reviewer only)

Click to expand
  • /reformat (experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.
  • setting the label "NoJenkins" will skip tests for this PR on jenkins (saves resources e.g., on edits that do not affect tests)
  • commenting with rebuild jenkins will retrigger Jenkins-based CI builds

⚠️ Note: Once you opened a PR try to minimize the number of pushes to it as every push will trigger CI (automated builds and test) and is rather heavy on our infrastructure (e.g., if several pushes per day are performed).

Summary by CodeRabbit

  • New Features
    • Improved Parquet-based loading with stronger filter support for chromatogram and mobilogram retrieval, including better handling of large string columns.
  • Bug Fixes
    • More reliable schema/column selection across multiple Parquet files.
    • Clearer behavior for invalid/unknown filters and stricter checks for out-of-range run identifiers (e.g., uint64 overflow).
    • More consistent type-safe decoding for numeric features (including FEATURE_RT as float vs double).
  • Tests
    • Added write-then-read Arrow/Parquet coverage for large-string columns and FEATURE_RT float/double scenarios.
    • Added tests for invalid filters and uint64 overflow handling.

Extract shared Arrow/Parquet reader plumbing into an internal helper used by XICParquetFile and XIMParquetFile.

Keep the public reader and row-struct APIs unchanged, and add regression coverage for LARGE_STRING plus FLOAT/DOUBLE parquet column handling.
@github-actions

Copy link
Copy Markdown
Contributor

@singjc The following names might be missing from the AUTHORS file:

  • singjc

Please consider applying the following patch:

--- AUTHORS	2026-06-30 15:06:49.202193458 +0000
+++ AUTHORS.new	2026-06-30 15:06:54.662685687 +0000
@@ -113,6 +113,7 @@
  - Sandro Andreotti
  - Santhil
  - Simon Gene Gottlieb
+ - singjc
  - Steffen Sass
  - Stephan Aiche
  - Sven Nahnsen

@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 51d018c1-1d51-4183-a89b-390e011d159c

📥 Commits

Reviewing files that changed from the base of the PR and between d45a111 and 706c2a7.

📒 Files selected for processing (1)
  • src/tests/class_tests/openms/CMakeLists.txt

📝 Walkthrough

Walkthrough

A shared ParquetReaderHelpers module now centralizes Parquet/Arrow reading, filter parsing, pruning, and filtering. XICParquetFile and XIMParquetFile now call it for their Parquet paths, and tests add Arrow-written Parquet cases for large strings, float/double values, invalid filters, and overflow handling.

Changes

Shared Parquet helper extraction

Layer / File(s) Summary
Helper API and build wiring
src/openms/source/FORMAT/DATAACCESS/ParquetReaderHelpers.h, src/openms/source/FORMAT/DATAACCESS/sources.cmake
Declares the shared Parquet helper API, pruning options, and adds the new source file to the DATAACCESS CMake source list.
Helper IO, parsing, and pruning
src/openms/source/FORMAT/DATAACCESS/ParquetReaderHelpers.cpp
Implements Parquet reader opening, table/schema handling, selected-column reads, chunk combination, filter tokenization, filter normalization, schema-aware pruning, typed getters, and binary extraction.
Helper filter execution
src/openms/source/FORMAT/DATAACCESS/ParquetReaderHelpers.cpp
Implements dataset-scanner filtering, manual row-by-row filtering, and Arrow compute filtering with fallback behavior for parsed filter expressions.
XIC reader migration
src/openms/source/FORMAT/XICParquetFile.cpp
XICParquetFile now uses shared helper calls for filter parsing, dataset reads, in-memory filtering, column access, optional value extraction, schema reads, and pruning options; upper_ also casts through unsigned char before std::toupper.
XIM reader migration
src/openms/source/FORMAT/XIMParquetFile.cpp
XIMParquetFile removes its local Parquet and filter helpers and switches mobilogram, run, analyte, and column paths to the shared helper API, while keeping local binary decoding and pruning options.
Arrow-backed reader tests and changelog
src/tests/class_tests/openms/source/XICParquetFile_test.cpp, src/tests/class_tests/openms/source/XIMParquetFile_test.cpp, CHANGELOG
Test helpers write Parquet files through Arrow, and new cases cover large UTF-8 columns, float/double feature RT handling, invalid filters, and uint64 overflow; the changelog records the reader refactor.

🐇 I hopped through Parquet rows,
Shared helpers bloomed in neat repose.
Strings grew large, floats found their place,
Filters now run with steadier pace.
Hooray for code that friends can share! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.66% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: deduplicating shared XIC/XIM Parquet reader helpers.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (6)
src/tests/class_tests/openms/source/XICParquetFile_test.cpp (2)

29-29: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use TEST_TRUE for boolean assertions.

These assertions use TEST_EQUAL(..., true), but this test tree prefers TEST_TRUE(...) for clearer and more idiomatic failures. As per coding guidelines, "Prefer TEST_TRUE(expr) and TEST_FALSE(expr) over TEST_EQUAL(expr, true) and TEST_EQUAL(expr, false)."

Also applies to: 36-36, 48-48, 188-188

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tests/class_tests/openms/source/XICParquetFile_test.cpp` at line 29,
Replace the boolean assertions in XICParquetFile_test so they use TEST_TRUE
instead of TEST_EQUAL(..., true). Update the checks around
builder.Append(value).ok() and the other matching assertions in the same test
file to follow the preferred boolean assertion style, using the existing test
helper names and keeping the test logic unchanged.

Source: Coding guidelines


24-68: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a couple of // comments in the new helper/test blocks.

The added code is currently all uncommented, which misses the repository’s C++ comment-coverage rule. A short // Build a one-row parquet table... / // Validate decoded chromatogram fields... style note before each phase would satisfy it without adding noise. As per coding guidelines, "Add comments covering at least ~5% of code using // style, describing the next few lines in plain English."

Also applies to: 145-201

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tests/class_tests/openms/source/XICParquetFile_test.cpp` around lines 24
- 68, The new helper block in XICParquetFile_test.cpp lacks the required `//`
comment coverage, so add a couple of short plain-English `//` comments around
the helper/test phases in the anonymous-namespace utilities and the related test
sections. Place them near the symbols like `appendOk_`, `finishArray_`,
`writeParquetTable_`, and the chromatogram validation steps so the added helpers
and test flow are clearly documented without changing behavior.

Source: Coding guidelines

src/tests/class_tests/openms/source/XIMParquetFile_test.cpp (2)

29-29: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use TEST_TRUE for boolean assertions.

The new checks still use TEST_EQUAL(..., true). Please switch them to TEST_TRUE(...) to match the class-test convention. As per coding guidelines, "Prefer TEST_TRUE(expr) and TEST_FALSE(expr) over TEST_EQUAL(expr, true) and TEST_EQUAL(expr, false)."

Also applies to: 36-36, 48-48, 202-202, 258-258, 265-265

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tests/class_tests/openms/source/XIMParquetFile_test.cpp` at line 29, The
boolean assertions in the XIMParquetFile class tests still use TEST_EQUAL(...,
true); update the affected checks in the test cases around
builder.Append(value).ok() and the other listed assertions to use TEST_TRUE(...)
instead, following the existing class-test convention and keeping the
surrounding test logic unchanged.

Source: Coding guidelines


24-68: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add brief // comments to the new setup/assertion phases.

These added helper and test blocks do not include any // comments, so they currently miss the repository’s C++ comment-coverage requirement. A few short phase comments would be enough. As per coding guidelines, "Add comments covering at least ~5% of code using // style, describing the next few lines in plain English."

Also applies to: 145-214, 217-267

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tests/class_tests/openms/source/XIMParquetFile_test.cpp` around lines 24
- 68, The new helper/setup and assertion sections in the XIMParquetFile tests
lack the required brief // coverage comments. Add short plain-English //
comments in the relevant helper functions and test-phase blocks, using the
nearby symbols like appendOk_, finishArray_, appendBinaryOk_, encodeDoubles_,
writeParquetTable_, and the affected test cases to guide placement. Keep the
comments focused on the next few lines and ensure the added test code meets the
repository’s C++ comment-coverage guideline.

Source: Coding guidelines

src/openms/source/FORMAT/DATAACCESS/ParquetReaderHelpers.cpp (1)

1097-1103: 🚀 Performance & Scalability | 🔵 Trivial | 🏗️ Heavy lift

Avoid creating one RecordBatch per matching row.

The manual fallback pushes batch->Slice(row, 1) for every hit, which can create millions of tiny batches. Build a per-batch boolean mask or index vector and filter/slice once per input batch instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openms/source/FORMAT/DATAACCESS/ParquetReaderHelpers.cpp` around lines
1097 - 1103, The manual fallback in ParquetReaderHelpers::evaluate should not
push batch->Slice(row, 1) for every matching row, since that creates one tiny
RecordBatch per hit. Update the per-batch filtering logic to collect matches
into a boolean mask or row-index vector while iterating the batch, then apply a
single filter/slice operation once per input batch and push only the resulting
batch.
src/openms/source/FORMAT/DATAACCESS/ParquetReaderHelpers.h (1)

14-15: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Forward-declare Arrow types in this header.

These declarations only use std::shared_ptr<arrow::Table>, arrow::Schema, and arrow::Array, so the heavyweight Arrow includes can move to the .cpp.

Proposed cleanup
-#include <arrow/api.h>
-#include <arrow/compute/api.h>
+namespace arrow
+{
+  class Array;
+  class Schema;
+  class Table;
+}

As per coding guidelines, “Use forward declarations in headers where possible and include only base class headers, non-pointer members, and templates.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openms/source/FORMAT/DATAACCESS/ParquetReaderHelpers.h` around lines 14 -
15, The header is pulling in heavy Arrow dependencies unnecessarily; move the
Arrow includes out of ParquetReaderHelpers.h and replace them with forward
declarations for the Arrow types used there, since this header only needs
std::shared_ptr<arrow::Table>, arrow::Schema, and arrow::Array. Update any
declarations in ParquetReaderHelpers.h to rely on those forward-declared
symbols, and keep the full Arrow includes in the corresponding .cpp or other
implementation file where the types are actually used.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/openms/source/FORMAT/DATAACCESS/ParquetReaderHelpers.cpp`:
- Around line 277-282: The filter handling in
ParquetReaderHelpers::applyArrowFilter is dropping both unsupported columns and
schema-missing columns, which can silently turn a bad predicate into no filter
at all. Update the column-pruning logic so only explicitly unsupported columns
are removed, and if a referenced column is not found in the schema, reject the
filter as invalid instead of continuing. Use the existing identifiers
unsupported_columns, name_map, and dropped_columns in the applyArrowFilter path
to keep the behavior localized and make unknown filter columns fail fast.
- Around line 489-491: Guard the `arrow::Type::UINT64` path in
`ParquetReaderHelpers::getValue`/the surrounding `switch` so it does not blindly
assign into `Int64`; check the `arrow::UInt64Array::Value(row)` against
`std::numeric_limits<Int64>::max()` before conversion, and return failure or
handle overflow explicitly when the value cannot fit. Use the existing `value`
assignment in the `UINT64` case as the place to add the range check, and keep
the behavior consistent with the other type-conversion branches.

In `@src/openms/source/FORMAT/DATAACCESS/ParquetReaderHelpers.h`:
- Around line 29-69: The helper API in ParquetReaderHelpers is missing the
required Doxygen documentation, including `@brief` tags, grouping, and parameter
notes. Add Doxygen blocks for the public declarations such as
FilterPruningOptions,
readParquetTable/readParquetSchema/readParquetTableColumns/getColumn/getOptionalInt/getOptionalDouble/getOptionalString/getBinaryView/parseFilter/applyArrowFilter/readParquetTableDataset,
and include `@param` descriptions with any relevant ranges or units; keep the docs
aligned with the existing helper names so they remain easy to locate.

---

Nitpick comments:
In `@src/openms/source/FORMAT/DATAACCESS/ParquetReaderHelpers.cpp`:
- Around line 1097-1103: The manual fallback in ParquetReaderHelpers::evaluate
should not push batch->Slice(row, 1) for every matching row, since that creates
one tiny RecordBatch per hit. Update the per-batch filtering logic to collect
matches into a boolean mask or row-index vector while iterating the batch, then
apply a single filter/slice operation once per input batch and push only the
resulting batch.

In `@src/openms/source/FORMAT/DATAACCESS/ParquetReaderHelpers.h`:
- Around line 14-15: The header is pulling in heavy Arrow dependencies
unnecessarily; move the Arrow includes out of ParquetReaderHelpers.h and replace
them with forward declarations for the Arrow types used there, since this header
only needs std::shared_ptr<arrow::Table>, arrow::Schema, and arrow::Array.
Update any declarations in ParquetReaderHelpers.h to rely on those
forward-declared symbols, and keep the full Arrow includes in the corresponding
.cpp or other implementation file where the types are actually used.

In `@src/tests/class_tests/openms/source/XICParquetFile_test.cpp`:
- Line 29: Replace the boolean assertions in XICParquetFile_test so they use
TEST_TRUE instead of TEST_EQUAL(..., true). Update the checks around
builder.Append(value).ok() and the other matching assertions in the same test
file to follow the preferred boolean assertion style, using the existing test
helper names and keeping the test logic unchanged.
- Around line 24-68: The new helper block in XICParquetFile_test.cpp lacks the
required `//` comment coverage, so add a couple of short plain-English `//`
comments around the helper/test phases in the anonymous-namespace utilities and
the related test sections. Place them near the symbols like `appendOk_`,
`finishArray_`, `writeParquetTable_`, and the chromatogram validation steps so
the added helpers and test flow are clearly documented without changing
behavior.

In `@src/tests/class_tests/openms/source/XIMParquetFile_test.cpp`:
- Line 29: The boolean assertions in the XIMParquetFile class tests still use
TEST_EQUAL(..., true); update the affected checks in the test cases around
builder.Append(value).ok() and the other listed assertions to use TEST_TRUE(...)
instead, following the existing class-test convention and keeping the
surrounding test logic unchanged.
- Around line 24-68: The new helper/setup and assertion sections in the
XIMParquetFile tests lack the required brief // coverage comments. Add short
plain-English // comments in the relevant helper functions and test-phase
blocks, using the nearby symbols like appendOk_, finishArray_, appendBinaryOk_,
encodeDoubles_, writeParquetTable_, and the affected test cases to guide
placement. Keep the comments focused on the next few lines and ensure the added
test code meets the repository’s C++ comment-coverage guideline.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 63857e3b-fd80-4aef-ac92-f49ea5e3be6c

📥 Commits

Reviewing files that changed from the base of the PR and between 7de1a8d and 58d247b.

📒 Files selected for processing (7)
  • src/openms/source/FORMAT/DATAACCESS/ParquetReaderHelpers.cpp
  • src/openms/source/FORMAT/DATAACCESS/ParquetReaderHelpers.h
  • src/openms/source/FORMAT/DATAACCESS/sources.cmake
  • src/openms/source/FORMAT/XICParquetFile.cpp
  • src/openms/source/FORMAT/XIMParquetFile.cpp
  • src/tests/class_tests/openms/source/XICParquetFile_test.cpp
  • src/tests/class_tests/openms/source/XIMParquetFile_test.cpp

@timosachsenberg

Copy link
Copy Markdown
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deduplicate XICParquetFile / XIMParquetFile (extract shared Arrow/Parquet reader helpers)

2 participants