Skip to content

feat: add feature for switching to writeColumnBatches endpoint#227

Open
alxhill wants to merge 3 commits into
mainfrom
ah/columnar-endpoint-feature
Open

feat: add feature for switching to writeColumnBatches endpoint#227
alxhill wants to merge 3 commits into
mainfrom
ah/columnar-endpoint-feature

Conversation

@alxhill
Copy link
Copy Markdown
Contributor

@alxhill alxhill commented Apr 21, 2026

building on top of #210, add the use of the new endpoint as an opt-in feature for easier testing rather than a hard switchover

alxhill and others added 3 commits April 21, 2026 12:33
Adds the `columnar` cargo feature that switches from writeNominalBatches
(row-oriented, dataSourceRid in URL path) to writeNominalColumnarBatches
(columnar, dataSourceRid in proto body).

Introduces a `StreamWriteRequest` type alias in client.rs that switches
between WriteRequestNominal and WriteBatchesRequest based on the feature;
this unifies trait signatures and consumer-wrapper types across both
feature states. Implementation details (AvroFileConsumer body,
SeriesBuffer::take, batch_processor request construction, encoding path,
and tests) are feature-gated in-line with `#[cfg(feature = "columnar")]`.

First pass — 55 cfg annotations across 5 files; follow-up will move the
divergent code into dedicated modules so each side sits behind a single
cfg boundary.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Moves all feature-specific helpers (encoding, avro serialization, request
construction, log summaries, format-specific tests) from per-callsite cfg
blocks in shared files into two dedicated sibling modules:

  src/row.rs       — compiled when `columnar` is disabled
  src/columnar.rs  — compiled when `columnar` is enabled

`lib.rs` aliases the active module as `crate::format`, so all other files
(`consumer.rs`, `stream.rs`, `listener.rs`) call `crate::format::*`
without any cfg annotations. Each format module exposes the same
internal API:

  build_write_request   — turn drained SeriesBuffer into a StreamWriteRequest
  encode_for_core       — serialize + wrap in an HTTP WriteRequest
  avro_append           — write a request to an avro file
  request_summary       — short human-readable payload summary
  test_support::*       — helpers the stream tests use to assert on payloads

Removes the duplicated assertion blocks in `lib.rs` stream tests in favor
of `format::test_support::count_points_by_channel` and
`first_request_first_double_count`; assertions now read the aggregate
count correctly (5 × 1000 points, not the accidental last-series 1000).

Result: 55 cfg annotations → 8, concentrated at the two boundary points
(module decls in lib.rs + the StreamWriteRequest alias in client.rs).
consumer.rs, stream.rs, listener.rs carry zero cfg. Shared trait signatures
and consumer-wrapper types (Fallback/Dual/Listening) remain unified via
the StreamWriteRequest alias.

Both feature states compile clean under clippy -D warnings and all 6
tests pass in each.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant