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

[Core] Add support for taking init capacity in the HttpHeaders #22960

Merged
merged 1 commit into from
Jul 19, 2021

Conversation

mssfang
Copy link
Member

@mssfang mssfang commented Jul 14, 2021

Use existing Java Map's Load Factor of HashMap: 0.75f to compute the threshold of the Map.

Fixes: #11472

@mssfang mssfang added the Azure.Core azure-core label Jul 14, 2021
@mssfang mssfang added this to the [2021] August milestone Jul 14, 2021
@mssfang mssfang self-assigned this Jul 14, 2021
Copy link
Member

@lmolkova lmolkova left a comment

Choose a reason for hiding this comment

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

LGTM!

nitpicking: it may be good to call one constructor from others to set headers instance field in case we'll ever add more constructors or other instance fields, but it sounds hard to come up with default capacity (instead of HashMap(), so it seems as good as we can get already

* @param initialCapacity the initial capacity of headers map.
*/
public HttpHeaders(int initialCapacity) {
this.headers = new HashMap<>(initialCapacity);
Copy link
Member

Choose a reason for hiding this comment

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

Should this validate initialCapacity?

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean we should validate the initialCapacity to be less than 2^30, which is the max capacity of Java hashmap.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, let's ignore this and let HashMap handle throwing the error if the initialCapicity is invalid

@mssfang mssfang merged commit 6cc9aff into Azure:main Jul 19, 2021
@mssfang mssfang deleted the TA-HttpHeader-Constructor branch July 19, 2021 23:24
azure-sdk pushed a commit to azure-sdk/azure-sdk-for-java that referenced this pull request May 19, 2023
Release sql microsoft.sql 2022 11 01 preview (Azure#23802)

* Adds base for updating Microsoft.Sql from version preview/2022-08-01-preview to version 2022-11-01-preview

* Updates readme

* Updates API version in new specs and examples

* Add Swagger API changes required for progress-reporting related changes in DatabaseOperations (Azure#22669)

* Update swagger (Azure#22715)

* Follow-up Swagger API changes required for progress-reporting related changes in DatabaseOperations  (Azure#22775)

* Add Swagger API changes required for progress-reporting related changes in DatabaseOperations

* Follow up changes required for progress-reporting related changes in DatabaseOperations

* updated example file

* Added Failed case in list-operations examples

* Update Microsoft.Sql ManagedInstance 2022-11-01-preview Swagger Docs (Azure#22899)

* Update Microsoft.sql ManagedInstance 2022-11-01-preview Swagger Docs

* Address Swagger Validation Errors

* Modify custom-words.txt

* Manually updating arm-id format to match stable 2021-11-01 version

* Adding provisioning state changes

* fixing validation

* adding missing space

* Remove HTTP 200 from Start/Stop Actions as we only return HTTP 202

---------

Co-authored-by: Jovana Toroman <jtoroman@microsoft.com>

* Update DateTime to ISO-8601 format in example file (Azure#22986)

* Add Swagger API changes required for progress-reporting related changes in DatabaseOperations

* Follow up changes required for progress-reporting related changes in DatabaseOperations

* updated example file

* Added Failed case in list-operations examples

* Update DateTime to ISo-8601 format in example file

* Enable TryPlannedBeforeForcedFailover for SQL DB Failover Group (Azure#22673)

* Enable TryPlannedBeforeForcedFailover for SQL DB Failover Group

* Modify example file

* Add example

* Fix ModelValidation issues

* Fix ModelValidation issues

* Add new controller

* Modify example

* Modify example

* Update server name

* Fix LintDiff

* Fix model validation errors

* Fix PostOperationAsyncResponseValidation, Unfix LroLocationHeader,ResourceNameRestriction

* Fix PostOperationAsyncResponseValidation

* Fix pending items

* Update doc

* Remove empty/unschematized object

---------

Co-authored-by: subhrob <subhrob@microsoft.com>

* [DO NOT MERGE] Add Archive option to LTR Policy for SQL DB (Azure#22697)

* add archival changes to LTRPolicy

* fix LongTermRetentionPolicies swagger file

* fix check failures

* redo swagger

* Update swagger documentation for Managed Instance start-stop actions (Azure#22992)

* Add NetworkSecurityPerimeterConfigurations Swagger (Azure#22960)

* Add NetworkSecurityPerimeterConfigurations Swagger

* Fixes round 1

* Fixes round 2

* Fixes Round 3

* Fixes Round 4

* Fix Round 5

* fixing enum (Azure#22995)

Co-authored-by: Jovana Toroman <jtoroman@microsoft.com>

* add changes (Azure#23120)

* Carry all minor changes to dev sql microsoft.sql 2022 11 01 preview (Azure#23337)

* Revert "add changes (Azure#23120)"

This reverts commit 5c348d22f8fb6c29b7322e28ea78d665586f4135.

Revert "[DO NOT MERGE] Add Archive option to LTR Policy for SQL DB (Azure#22697)"

This reverts commit 559f7f474d944a92f6cb108eb433a05f3c53cd8e.

* Carrying minor changes to release branch for Microsoft.Sql 2022-11-01-preview

* Reverting DatabaseAdvisors

* Further reverting problematic files

* Reverting a few example files

* Adding back arm-id to a few files

* Reverting error message change in ManagedDatabaseRestoreDetails.json, Jobs.json,ServerDevOpsAudit.json, and TransparentDataEncryptions.json

* Minor fixes for Turkey name change and missing x-ms-identifier (Azure#23637)

* Fixing issues with a few breaking changes (Azure#23943)

* Minor fixes for Turkey name change and missing x-ms-identifier

* Adding back missing arm-id and other missing property issues causing breaking changes incorrectly.

* Fixing prettier issue with ManagedDatabases.json

* Fixing arm-id format in 4 examples

* Adding missing location for 202 responses on sync examples

---------

Co-authored-by: Ji Wang <wangjiprc@gmail.com>
Co-authored-by: Mohit Agarwal <mohitagarwal@microsoft.com>
Co-authored-by: GalGoldi72 <124780962+GalGoldi72@users.noreply.github.com>
Co-authored-by: ilijadivljan-ms <122982104+ilijadivljan-ms@users.noreply.github.com>
Co-authored-by: Jovana Toroman <jtoroman@microsoft.com>
Co-authored-by: subhrob <subhro.bhattacharya@gmail.com>
Co-authored-by: subhrob <subhrob@microsoft.com>
Co-authored-by: CelinaJiangJXY <124339390+CelinaJiangJXY@users.noreply.github.com>
Co-authored-by: beoberha <51964155+beoberha@users.noreply.github.com>
Co-authored-by: toki95 <35834415+toki95@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Core azure-core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Proposal] Add HttpHeaders Constructor with Initial Size
3 participants