Skip to content

HDDS-14740. Implement ScmListCodec without reflection#9919

Open
Russole wants to merge 6 commits intoapache:masterfrom
Russole:HDDS-14740
Open

HDDS-14740. Implement ScmListCodec without reflection#9919
Russole wants to merge 6 commits intoapache:masterfrom
Russole:HDDS-14740

Conversation

@Russole
Copy link
Contributor

@Russole Russole commented Mar 14, 2026

What changes were proposed in this pull request?

Record generic type information when constructing SCMRatisRequest; otherwise getCodec() and decode() cannot determine the element type of List.

  • Add genericType field to MethodArgument in SCMRatisProtocol.proto to store the element type T of List<T>.
  • Add genericType field to SCMRatisResponseProto to preserve generic type information in responses.
  • Update SCMRatisRequest and SCMRatisResponse encode() to include genericType when the parameter is List<T>.
  • Update SCMRatisRequest and SCMRatisResponse decode() to reconstruct the corresponding generic Type.
  • Add genericParameterTypes parameter to SCMRatisRequest and SCMRatisResponse constructors to preserve generic type information.
  • Add getCodec(Type type) and getOrCreateListCodec() in ScmCodecFactory to support resolving codecs for List<T>.
  • Update ScmListCodec to support generic element types instead of inferring the type from runtime values.
  • Dynamically create and cache ScmListCodec instances for List<T> based on the element type.
  • Fix tests to align with the changes.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-14740

How was this patch tested?

@Russole
Copy link
Contributor Author

Russole commented Mar 14, 2026

Hi @szetszwo, could you please help review this PR when you have time? Thanks!

message MethodArgument {
optional string type = 1;
optional bytes value = 2;
optional string genericType = 3;
Copy link
Contributor

Choose a reason for hiding this comment

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

@Russole , since the existing code can serialize/deserialize, the protos should have enough information, i.e. we probably don't need to add new fields to the protos. Let me see about how to do it.

@szetszwo
Copy link
Contributor

@Russole , Please see if this idea would work.

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