[Refactor] StreamingProducer: use VecDeque for O(1) buffer advance

Open
#1,436 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@andrewmusselman is already working on this.

Since Oct 20, 2026.

  • #1462 by @0lai0 — closed without merging
  • #1559 by @andrewmusselman — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
70/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Quiet
Tech stack
rust

Research direction

Start in qdp-core/src/pipeline_runner.rs:368 and inspect the StreamingProducer buffer initialization and advance path, including whether StreamingAdapter has landed. Run the streaming coverage in tests/parquet_f32.rs and tests/reader.rs before changes. Done means the buffer uses VecDeque, capacity stays bounded across 100 batches, output remains identical, and advancement avoids per-batch O(n) memmoves.

Written by the indexing model from the issue text.

Description

good-first-issue qdp
What

Change the streaming producer's internal buffer from a Vec advanced with Vec::drain(..cursor) to a VecDeque, so advancing past consumed samples is O(1) instead of O(n).

Why

StreamingProducer currently advances its buffer with self.buffer.drain(..self.buffer_cursor) (qdp-core/src/pipeline_runner.rs:368), which memmoves the remaining elements down on every batch — O(n) per advance, paid on the streaming hot path. A VecDeque makes front-popping O(1) and avoids the repeated memmove, with no change to the data produced.

How
  • Replace the backing Vec buffer in the streaming producer (or StreamingAdapter, if E2 has landed) with a VecDeque<T>.
  • Swap the Vec::drain(..cursor) front-removal for VecDeque front operations (drain(..cursor) / pop_front) so the advance is O(1) amortized.
  • Ensure capacity stays bounded across many batches (no unbounded growth or reallocation churn).
  • Keep output identical to the current streaming path.

Out of scope: Producer unification (E2) if taken separately, any change to streaming correctness or output.

Acceptance criteria:

  • Test: VecDeque capacity stays constant over 100 consecutive batches (no reallocation growth)
  • No correctness change on the streaming coverage in tests/parquet_f32.rs and tests/reader.rs
  • Streaming hot-path advance is O(1) (no per-batch O(n) memmove)
Dominant language
Rust
Stars
2.3k
Forks
1k
Avg merge
2d 20h
Merged PRs (30d)
7

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/mahout

All issues in apache/mahout

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.