Skip to content

feat(spark): count bytes for files opened with buildColumnarReader(file) - #114

Merged
ChristopherWirt merged 3 commits into
developfrom
cwirt/public-read-metrics
Nov 11, 2026
Merged

ChristopherWirt merged 3 commits into
developfrom
cwirt/public-read-metrics

Conversation

@ChristopherWirt

@ChristopherWirt ChristopherWirt commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

#108 reports native read bytes only through the connector's own createColumnarReader.

The public buildColumnarReader(file) still passes a no-op byte counter. So a source that opens files one by one reports 0 input bytes. The event store's history read does this, with a new factory for each file.

On a full-scale history read with 0.93.0-qc51, a task reported 9.5 KB of input (its anchors), while S3A counted 37 MB per Vortex file.

Change

buildColumnarReader(file) on both reader factories now returns a reader that reports its own bytes:

  • It publishes worker-thread bytes on next() and close(), the same way the scan reader does.
  • Its currentMetricsValues() returns vortexBytesRead. This is one cumulative total for every file opened this way in the task, so it stays correct when each file has its own factory.

So callers get input bytes without code changes. To show vortexBytesRead, a scan declares VortexBytesReadMetric and forwards the reader's metric values.

Known limitation: if several such scans run in one task, each one's vortexBytesRead shows their combined total. Task input bytes are still correct. This is documented on the method.

VortexReadMetrics stays package-private. The scan path and the single-file path share one wrapper.

Tests

  • New filesOpenedOneAtATimeReportInputBytes: a test V2 source (OneFileAtATimeSource) reads every file in one task, with a new factory for each file. It runs through DataSourceRDD, which overwrites input bytes from thread statistics. It checks that task input bytes and vortexBytesRead both equal the bytes the file system served. It fails without the change.
  • Spark 4.0 / 2.13 and 3.5 / 2.12 suites pass, except two failures that also happen on develop:
    • VortexListElementPruningIoTest (4.0) fails with SparkContext was shut down and passes on its own.
    • VortexV1FallbackTest.readsMissingColumnsWithCodegen (3.5) sometimes misses the appended column. Schema inference reads one footer (fix(spark): infer schemas from one footer by default #105).
  • spotlessCheck fails on develop because of NestedSchemaPruning.java, which this PR doesn't touch.

🤖 Generated with Claude Code

ChristopherWirt and others added 2 commits November 10, 2026 15:35
#108 reports native read bytes to Spark, but only through the connector's own
scan: VortexReadMetrics is package-private, and the factory's reader that takes
a byte counter is private. A data source that builds VortexPartitionReaderFactory
itself and reads files one by one, as the event store's history read does,
reports 0 input bytes.

- VortexReadMetrics is public, with forTask(scan) for a task's cumulative
  counter, publish() to move worker-thread bytes into the task's input
  metrics, and currentMetricsValues().
- VortexPartitionReaderFactory.buildColumnarReader(file, metrics) is public.
- The connector's own scan gets its counter from forTask, so both paths share
  one implementation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replaces the public VortexReadMetrics API with self-reporting readers.
The public buildColumnarReader(file) now counts its bytes, publishes them
on next() and close(), and exposes a cumulative vortexBytesRead shared by
every such file in the task. Callers that open files one by one need no
changes to report input bytes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ChristopherWirt ChristopherWirt changed the title feat(spark): let readers that open their own files report bytes read feat(spark): count bytes for files opened with buildColumnarReader(file) Nov 11, 2026
States the task-thread requirement and that the custom metric is one
cumulative total per task. Looks up TaskContext once per reader.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ChristopherWirt
ChristopherWirt merged commit bea9db1 into develop Nov 11, 2026
1 check passed
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.

2 participants