Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return correct type indices for primitive types referred to by their CLR type names #12956

Merged
merged 3 commits into from
Jun 6, 2022

Conversation

aparajit-pratap
Copy link
Contributor

@aparajit-pratap aparajit-pratap commented Jun 2, 2022

Purpose

Return correct type indices for primitive types referred to by their CLR type names - this permits a node like List.RemoveIfNot to work with not just the DS types passed as input, but also the C# type. For e.g. it now works for both the DS type int but also the equivalent C# type, System.Int64 type.

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated

Release Notes

List.RemoveIfNot now supports C# type such as that returned from Object.Type.

FYIs

(FILL ME IN, Optional) Names of anyone else you wish to be notified of

if (index != Constants.kInvalidIndex) return index;

if(clrToDSTypeMap.TryGetValue(ident, out string dsType))
return classTable.IndexOf(dsType);
Copy link
Member

@mjkkirschner mjkkirschner Jun 3, 2022

Choose a reason for hiding this comment

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

while I think this PR looks good - I am curious if you think there could be performance implications here, this IndexOf call doesn't seem to be straight forward, it seems to do partial matching? So in the worst case we'll now do 2x the lookups in some pathologically bad cases, do you think those will come up rarely, and if so is this method classTable.IndexOf linear in complexity or something worse?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think right now, it's only going to take place for a node like RemoveIfNot where there is the possibility of checking for a C# type.

@mjkkirschner
Copy link
Member

LGTM

@aparajit-pratap aparajit-pratap merged commit 3561ce9 into DynamoDS:master Jun 6, 2022
@aparajit-pratap aparajit-pratap deleted the dyn-4648 branch June 6, 2022 11:55
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