You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "vsop-479 (via GitHub)" <gi...@apache.org> on 2025/12/23 08:48:14 UTC

[PR] Use HashMap#newHashMap, HashSet#newHashSet in CollectionUtil. [lucene]

vsop-479 opened a new pull request, #15517:
URL: https://github.com/apache/lucene/pull/15517

   ### Description
   
   Discussed in https://github.com/apache/lucene/pull/14770.
   


-- 
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: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Use HashMap#newHashMap, HashSet#newHashSet instead of CollectionUtil#newHashMap, CollectionUtil#newHashSet. [lucene]

Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler commented on PR #15517:
URL: https://github.com/apache/lucene/pull/15517#issuecomment-3689268582

   For 10.x maybe keep the CollectionUtil method as deprecated.


-- 
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: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Use HashMap#newHashMap, HashSet#newHashSet in CollectionUtil. [lucene]

Posted by "thecoop (via GitHub)" <gi...@apache.org>.
thecoop commented on PR #15517:
URL: https://github.com/apache/lucene/pull/15517#issuecomment-3686001293

   Yup, these CollectionUtil methods can just be removed and the JCL methods used directly


-- 
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: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Use HashMap#newHashMap, HashSet#newHashSet instead of CollectionUtil#newHashMap, CollectionUtil#newHashSet. [lucene]

Posted by "vsop-479 (via GitHub)" <gi...@apache.org>.
vsop-479 commented on PR #15517:
URL: https://github.com/apache/lucene/pull/15517#issuecomment-3688530184

   Hi @uschindler , @thecoop 
   I removed `CollectionUtil#newHashMap, CollectionUtil#newHashSet`, and use Use `HashMap#newHashMap, HashSet#newHashSet` directly.
   
   This pr also plus 1 for `CustomAnalyzer#paramsToMap` 's map size.


-- 
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: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Use HashMap#newHashMap, HashSet#newHashSet in CollectionUtil. [lucene]

Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler commented on PR #15517:
URL: https://github.com/apache/lucene/pull/15517#issuecomment-3685969644

   Hi,
   The plan was to remove both methods in main branch and replace the whole code by the default variant I n JDK.
   
   The plus1 issue comes from a safety added, I think because @thecoop wanted to make sure that after rounding the size is correct. According to JDK docs the newHashXxx method in jdk ensures that the requested elements fit into the map without resizing. So they .ay gave changed other stuff to make the plus1 not needed.
   
   Uwe


-- 
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: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Use HashMap#newHashMap, HashSet#newHashSet in CollectionUtil. [lucene]

Posted by "vsop-479 (via GitHub)" <gi...@apache.org>.
vsop-479 commented on PR #15517:
URL: https://github.com/apache/lucene/pull/15517#issuecomment-3685821413

   Hello, @uschindler 
   There is a little difference between two versions on the calculation fo capacity: the old one divide by 0.75f, and add one. Now , we just divide 0.75f.


-- 
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: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Use HashMap#newHashMap, HashSet#newHashSet instead of CollectionUtil#newHashMap, CollectionUtil#newHashSet. [lucene]

Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler commented on code in PR #15517:
URL: https://github.com/apache/lucene/pull/15517#discussion_r2645220443


##########
lucene/analysis/common/src/java/org/apache/lucene/analysis/custom/CustomAnalyzer.java:
##########
@@ -606,7 +606,8 @@ private Map<String, String> paramsToMap(String... params) {
         throw new IllegalArgumentException(
             "Key-value pairs expected, so the number of params must be even.");
       }
-      final Map<String, String> map = CollectionUtil.newHashMap(params.length / 2);
+      // Plus 1 since applyDefaultParams will add a default param later.
+      final Map<String, String> map = HashMap.newHashMap(params.length / 2 + 1);

Review Comment:
   👍



-- 
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: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Use HashMap#newHashMap, HashSet#newHashSet instead of CollectionUtil#newHashMap, CollectionUtil#newHashSet. [lucene]

Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler commented on PR #15517:
URL: https://github.com/apache/lucene/pull/15517#issuecomment-3689211476

   Merry Xmas! 🎄


-- 
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: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Use HashMap#newHashMap, HashSet#newHashSet in CollectionUtil. [lucene]

Posted by "vsop-479 (via GitHub)" <gi...@apache.org>.
vsop-479 commented on PR #15517:
URL: https://github.com/apache/lucene/pull/15517#issuecomment-3686260259

   Thanks @uschindler, @thecoop.
   
   I considered use the JDK methods directly, but chosed this way.
   
   Anyway, I will fix it.


-- 
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: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Use HashMap#newHashMap, HashSet#newHashSet instead of CollectionUtil#newHashMap, CollectionUtil#newHashSet. [lucene]

Posted by "vsop-479 (via GitHub)" <gi...@apache.org>.
vsop-479 commented on PR #15517:
URL: https://github.com/apache/lucene/pull/15517#issuecomment-3689265339

   Merry Xmas! 🎄
   
   I will backport this to 10.x


-- 
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: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Use HashMap#newHashMap, HashSet#newHashSet instead of CollectionUtil#newHashMap, CollectionUtil#newHashSet. [lucene]

Posted by "vsop-479 (via GitHub)" <gi...@apache.org>.
vsop-479 merged PR #15517:
URL: https://github.com/apache/lucene/pull/15517


-- 
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: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org