Skip to content

feat: parse vector<T, N> from Custom type class name (Cassandra 5.0)#222

Draft
bkearns wants to merge 1 commit intokrojew:masterfrom
bkearns:feature/vector-type
Draft

feat: parse vector<T, N> from Custom type class name (Cassandra 5.0)#222
bkearns wants to merge 1 commit intokrojew:masterfrom
bkearns:feature/vector-type

Conversation

@bkearns
Copy link

@bkearns bkearns commented Mar 22, 2026

Summary

Parse vector<T, N> column types from the Custom type class name string, matching how Cassandra 5.0 encodes vectors on the wire. Supersedes #221 which incorrectly used a non-standard type ID.

Cassandra has no dedicated type ID for vectors in the native protocol. Vector columns are sent as Custom (0x0000) with class name:
org.apache.cassandra.db.marshal.VectorType(org.apache.cassandra.db.marshal.FloatType , 768)

This is the same approach used by the DataStax Java driver, ScyllaDB Rust driver, and Python driver.

Changes

  • ColTypeOptionValue::CVector(element_type_name, dimensions) new variant
  • parse_vector_class_name() extracts element type + dimension count
  • Custom type handler detects VectorType before falling back to CString
  • Serialize CVector back to Cassandra-compatible class name format

No new ColType variant — vectors stay as ColType::Custom on the wire.

Tests

7 new tests (182 total, all passing): float4, float768, double, compact format, non-vector passthrough, wire roundtrips.

@bkearns bkearns force-pushed the feature/vector-type branch from 4754ef5 to 647c5e5 Compare March 22, 2026 07:16
Cassandra 5.0 sends vector columns as Custom (0x0000) with class name:
  org.apache.cassandra.db.marshal.VectorType(
    org.apache.cassandra.db.marshal.FloatType , 768)

This patch detects VectorType in Custom class name strings and parses
the element type and dimension count into a structured CVector variant.

Changes in cassandra-protocol/src/frame/message_result.rs:
- ColTypeOptionValue::CVector(element_type_name, dimensions)
- parse_vector_class_name() extracts type + dims from class name
- Custom type handler checks for VectorType before falling back to CString
- Serialize CVector back to the Cassandra class name format
- 7 new tests: parsing, compact format, non-vector passthrough,
  wire roundtrip for both vector and non-vector Custom types

No new ColType variant needed — vectors stay as ColType::Custom on the
wire, matching the Cassandra native protocol spec (which has no dedicated
vector type ID).
@bkearns bkearns force-pushed the feature/vector-type branch from 647c5e5 to 502498c Compare March 22, 2026 07:20
@krojew
Copy link
Owner

krojew commented Mar 24, 2026

Thanks for submitting. Is it ready for review?

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