Skip to content

(cleanup) marshal: remove proto field from NativeType struct#712

Draft
mykaul wants to merge 4 commits intoscylladb:masterfrom
mykaul:remove_proto_from_native_type
Draft

(cleanup) marshal: remove proto field from NativeType struct#712
mykaul wants to merge 4 commits intoscylladb:masterfrom
mykaul:remove_proto_from_native_type

Conversation

@mykaul
Copy link
Copy Markdown

@mykaul mykaul commented Feb 14, 2026

Remove the functionally unused proto byte field from NativeType, reducing struct size from 32 to 24 bytes (1 byte + 7 padding). Reduces memory consumption and thus GC.

Changes:

  • Remove proto byte field from NativeType struct
  • Version() now returns protoVersion4 constant, marked deprecated
  • NewNativeType/NewCustomType accept but ignore proto param, marked deprecated
  • Remove Marshal panic guard that checked proto == 0
  • Remove proto: from all struct literals across production and test files
  • Remove protoVer parameter from internal getCassandraType/getCassandraLongType
  • Remove unused v uint8 parameter from unmarshalTabletHint

All unit tests passed, ran Scylla integration tests as well.

@mykaul mykaul requested a review from Copilot February 14, 2026 09:00
@mykaul mykaul marked this pull request as draft February 14, 2026 09:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Removes the unused protocol-version field from NativeType to reduce per-type memory overhead and simplify related parsing/marshaling code paths.

Changes:

  • Drops NativeType.proto and updates type construction sites accordingly (prod + tests).
  • Makes NativeType.Version() always return protoVersion4 and removes the Marshal() panic guard tied to unset proto.
  • Simplifies internal helpers/signatures by removing now-redundant protocol-version parameters (type parsing + tablet hint unmarshalling).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
marshal.go Removes NativeType.proto, updates constructors/Version behavior, and adjusts UDT construction accordingly.
helpers.go Removes proto-version from internal Cassandra type parsing helpers and updates vector parsing to match.
frame.go Updates framer.readTypeInfo() type-info construction to no longer set proto.
conn.go Updates tablet hint unmarshalling to no longer accept/pass a proto version and removes proto from nested type literals.
marshal_test.go Updates marshaling/unmarshaling tests to remove proto: from NativeType literals.
ring_describer_test.go Updates result metadata fixtures to remove proto: from NativeType literals.
helpers_test.go Updates tests for the new getCassandraType signature.
tablet_integration_test.go Updates integration test call site for the new unmarshalTabletHint signature.
Comments suppressed due to low confidence (1)

marshal.go:1843

  • NewUDTType still accepts a proto parameter but no longer uses it after removing NativeType.proto. This is a silent behavior change for callers; please document that the proto argument is ignored (and ideally deprecate it with a leading "Deprecated:" sentence) to avoid confusion.
func NewUDTType(proto byte, name, keySpace string, elems ...UDTField) UDTTypeInfo {
	return UDTTypeInfo{
		NativeType: NativeType{typ: TypeUDT},
		Name:       name,
		KeySpace:   keySpace,
		Elements:   elems,
	}

Comment thread marshal.go Outdated
Comment on lines 1707 to 1715
// NewNativeType creates a NativeType. The proto parameter is ignored and kept for API compatibility.
func NewNativeType(proto byte, typ Type) NativeType {
return NativeType{proto: proto, typ: typ, custom: ""}
return NativeType{typ: typ}
}

// NewCustomType creates a custom NativeType. The proto parameter is ignored and kept for API compatibility.
func NewCustomType(proto byte, typ Type, custom string) NativeType {
return NativeType{proto: proto, typ: typ, custom: custom}
return NativeType{typ: typ, custom: custom}
}
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

NewNativeType/NewCustomType now ignore the proto parameter, but the doc comments don’t mark these APIs as deprecated (Go convention is a leading "Deprecated:" sentence). Either update the comments to use the standard deprecation marker or adjust the PR description/intent so users aren’t misled by godoc.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@copilot - this is slightly wrong - if I use 'Deprecated:' here, one might think that the func is deprecated, whereas just a single parameter is. Which is why I've added a comment above each of them.

@Lorak-mmk
Copy link
Copy Markdown

Version() now returns protoVersion4 constant, marked deprecated

There is the exact same problem as in Python, right? This functionality is not strictly needed now, but will be in the future when we support new protocol versions (especially if ser/deser for some types changes).

@mykaul
Copy link
Copy Markdown
Author

mykaul commented Feb 16, 2026

Version() now returns protoVersion4 constant, marked deprecated

There is the exact same problem as in Python, right? This functionality is not strictly needed now, but will be in the future when we support new protocol versions (especially if ser/deser for some types changes).

I thought about this, but:

  1. There are no changes in v5 wrt data types (https://github.com/apache/cassandra/blob/2ed4c25753f70c93e2b07b7df3a4ad3dd101aaec/doc/native_protocol_v5.spec#L1443 )
  2. Let's assume (or hope) that there will be a change - it should not be saved for every type, on every type? One would hope they'll create Decimal_protocol_v6 or whatnot.
  3. If we ever support a new(er) protocol, I hope some day it'll be ours and substantially better than CQL wire protocol, which is not amazing :-/

@mykaul mykaul force-pushed the remove_proto_from_native_type branch 2 times, most recently from f97a0bb to 53ea7d1 Compare February 16, 2026 17:03
@mykaul mykaul force-pushed the remove_proto_from_native_type branch from 53ea7d1 to 893b131 Compare February 26, 2026 21:24
mykaul added 2 commits March 16, 2026 17:48
Remove the functionally unused proto byte field from NativeType, reducing
struct size from 32 to 24 bytes (1 byte + 7 padding). Reduces memory consumption and thus GC.

Changes:
- Remove proto byte field from NativeType struct
- Version() now returns protoVersion4 constant, marked deprecated
- NewNativeType/NewCustomType accept but ignore proto param, marked deprecated
- Remove Marshal panic guard that checked proto == 0
- Remove proto: from all struct literals across production and test files
- Remove protoVer parameter from internal getCassandraType/getCassandraLongType
- Remove unused v uint8 parameter from unmarshalTabletHint

All unit tests passed, ran Scylla integration tests as well.

Signed-off-by: Yaniv Kaul <yaniv.kaul@scylladb.com>
@mykaul mykaul force-pushed the remove_proto_from_native_type branch from 893b131 to 5fc9efa Compare March 16, 2026 15:53
mykaul added 2 commits March 20, 2026 19:55
The proto field was removed from NativeType in this PR but
events_unit_test.go was not updated, causing a compilation failure.
Use the conventional '// Deprecated:' format so that Go tooling
(godoc, staticcheck, gopls) can surface the deprecation to users.
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.

3 participants