lesnik2u opened a new pull request, #4463: URL: https://github.com/apache/cassandra/pull/4463
Summary This PR optimizes the Component.Type.fromRepresentation() method by pre-compiling regex patterns in the enum constructor instead of compiling them on every match operation. This improves performance for component type matching, which can occur frequently during SSTable operations. Changes Added pre-compiled Pattern field to Component.Type enum Patterns are now compiled once during enum initialization CUSTOM type correctly handles null pattern Updated matching logic in fromRepresentation() Changed from Pattern.matches() to reusing pre-compiled patterns Added null check with IllegalArgumentException for invalid input Made method package-private (was incorrectly public despite @VisibleForTesting) Added comprehensive unit tests Test null input validation Test empty string handling (returns CUSTOM as expected) Existing test coverage maintained <img width="2560" height="626" alt="after" src="https://github.com/user-attachments/assets/76979486-f2ce-461d-9646-da5b00e1626d" /> <img width="2267" height="1232" alt="before" src="https://github.com/user-attachments/assets/6289bc27-957e-4a11-85fc-68dc97faf1cc" /> Performance Impact Eliminates repeated regex compilation overhead Particularly beneficial for workloads with frequent component type lookups Testing All existing unit tests pass Added testFromRepresentationNullInput() to verify precondition Added testFromRepresentationEmptyString() to verify empty string behavior -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

