(improvement) cqltypes: fast-path lookup_casstype() for simple type n…#729
Open
mykaul wants to merge 1 commit intoscylladb:masterfrom
Open
(improvement) cqltypes: fast-path lookup_casstype() for simple type n…#729mykaul wants to merge 1 commit intoscylladb:masterfrom
mykaul wants to merge 1 commit intoscylladb:masterfrom
Conversation
…ames Skip the regex scanner and stack-based parser in parse_casstype_args() when the type string has no parentheses. For simple types like 'AsciiType' or 'org.apache.cassandra.db.marshal.FloatType', go directly to lookup_casstype_simple() which is just a prefix strip + dict lookup. This avoids re.Scanner, re.split on ':' / '=>', int() try/except, and list-of-lists stack manipulation for the common case of non-parameterized types. Signed-off-by: Yaniv Kaul <yaniv.kaul@scylladb.com>
There was a problem hiding this comment.
Pull request overview
Optimizes Cassandra type-class lookup by short-circuiting lookup_casstype() for non-parameterized (no-parentheses) type strings, avoiding the heavier regex scanner + stack parser for the common case.
Changes:
- Add a fast-path in
lookup_casstype()to directly calllookup_casstype_simple()when the input has no parentheses. - Update unit test expectations for malformed simple type names (
AsciiType~) to produce an unrecognized type instead of raisingValueError.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| cassandra/cqltypes.py | Adds a no-parentheses fast-path in lookup_casstype() to bypass parse_casstype_args() for simple types. |
| tests/unit/test_types.py | Updates lookup_casstype() unit test to reflect the new behavior for malformed simple type names. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Author
|
This is a very small change, which I've split from much larger patchset I'm playing with. I think it's reasonable to get it in by itself. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…ames
Skip the regex scanner and stack-based parser in parse_casstype_args() when the type string has no parentheses. For simple types like 'AsciiType' or 'org.apache.cassandra.db.marshal.FloatType', go directly to lookup_casstype_simple() which is just a prefix strip + dict lookup.
This avoids re.Scanner, re.split on ':' / '=>', int() try/except, and list-of-lists stack manipulation for the common case of non-parameterized types.
Pre-review checklist
./docs/source/.Fixes:annotations to PR description.