You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2020/09/02 04:56:01 UTC

[GitHub] [lucene-solr] TomMD opened a new pull request #1818: SOLR-14819 Trivial fix to inefficient iterator pattern

TomMD opened a new pull request #1818:
URL: https://github.com/apache/lucene-solr/pull/1818


   # Description
   
   Infer, via Muse, [called out](https://console.muse.dev/result/TomMD/lucene-solr/01EH5WXS6C1RH1NFYHP6ATXTZ9?search=JsonSchemaValidator&tab=results) a few inefficient patterns which this PR fixes.
   
   # Solution
   
   The patters are:
   
   ```
   for(key in hashmap) doThing(hashmap.get(key));
   ```
   
   And the fix is:
   
   ```
   for(value in hashmap) doThing(value)
   ```
   
   Pretty basic.
   
   - [X ] I have created a Jira issue and added the issue ID to my pull request title.
   - [X ] I have developed this patch against the `master` branch.


----------------------------------------------------------------
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.

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


[GitHub] [lucene-solr] bruno-roustant closed pull request #1818: SOLR-14819 Trivial fix to inefficient iterator pattern

Posted by GitBox <gi...@apache.org>.
bruno-roustant closed pull request #1818:
URL: https://github.com/apache/lucene-solr/pull/1818


   


----------------------------------------------------------------
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.

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


[GitHub] [lucene-solr] TomMD commented on a change in pull request #1818: SOLR-14819 Trivial fix to inefficient iterator pattern

Posted by GitBox <gi...@apache.org>.
TomMD commented on a change in pull request #1818:
URL: https://github.com/apache/lucene-solr/pull/1818#discussion_r482683688



##########
File path: solr/solrj/src/java/org/apache/solr/common/util/JsonSchemaValidator.java
##########
@@ -48,13 +48,15 @@ public JsonSchemaValidator(String jsonString) {
 
   public JsonSchemaValidator(Map jsonSchema) {
     this.validators = new LinkedList<>();
-    for (Object fname : jsonSchema.keySet()) {
+    for (Object entry : jsonSchema.entrySet()) {

Review comment:
       I was being foolish - Map<> is abstract not concrete and we have no problem.  Never mind, will update.




----------------------------------------------------------------
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.

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


[GitHub] [lucene-solr] TomMD commented on a change in pull request #1818: SOLR-14819 Trivial fix to inefficient iterator pattern

Posted by GitBox <gi...@apache.org>.
TomMD commented on a change in pull request #1818:
URL: https://github.com/apache/lucene-solr/pull/1818#discussion_r482245426



##########
File path: solr/solrj/src/java/org/apache/solr/common/util/JsonSchemaValidator.java
##########
@@ -48,13 +48,15 @@ public JsonSchemaValidator(String jsonString) {
 
   public JsonSchemaValidator(Map jsonSchema) {
     this.validators = new LinkedList<>();
-    for (Object fname : jsonSchema.keySet()) {
+    for (Object entry : jsonSchema.entrySet()) {

Review comment:
       I've got to admit I'm a bit confused on this since `Map.Entry<>` is not what one gets from `entrySet` of a `Map`:
   
   ```
   > Task :solr:solrj:compileJava
   /code/solr/solrj/src/java/org/apache/solr/common/util/JsonSchemaValidator.java:51: error: incompatible types: Object ca
   nnot be converted to Entry<?,?>
       for (Map.Entry<?,?> entry : jsonSchema.entrySet()) {
   ```
   
   Are you asking for us to change the function from:
   
   ```
       public JsonSchemaValidator(Map jsonSchema) {
   ```
   
   to
   
   ```
       public JsonSchemaValidator(Map<?,?> jsonSchema) {
   ```
   
   And propagate that API change to the callees, or did I miss the obvious thing?




----------------------------------------------------------------
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.

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


[GitHub] [lucene-solr] TomMD commented on a change in pull request #1818: SOLR-14819 Trivial fix to inefficient iterator pattern

Posted by GitBox <gi...@apache.org>.
TomMD commented on a change in pull request #1818:
URL: https://github.com/apache/lucene-solr/pull/1818#discussion_r482121832



##########
File path: .muse.toml
##########
@@ -0,0 +1 @@
+jdk11 = true

Review comment:
       Woops, thanks for the catch that was for my own use.




----------------------------------------------------------------
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.

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


[GitHub] [lucene-solr] juanka588 commented on a change in pull request #1818: SOLR-14819 Trivial fix to inefficient iterator pattern

Posted by GitBox <gi...@apache.org>.
juanka588 commented on a change in pull request #1818:
URL: https://github.com/apache/lucene-solr/pull/1818#discussion_r481841600



##########
File path: solr/solrj/src/java/org/apache/solr/common/util/JsonSchemaValidator.java
##########
@@ -48,13 +48,15 @@ public JsonSchemaValidator(String jsonString) {
 
   public JsonSchemaValidator(Map jsonSchema) {
     this.validators = new LinkedList<>();
-    for (Object fname : jsonSchema.keySet()) {
+    for (Object entry : jsonSchema.entrySet()) {

Review comment:
       use Map.Entry<> directly here




----------------------------------------------------------------
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.

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


[GitHub] [lucene-solr] bruno-roustant commented on a change in pull request #1818: SOLR-14819 Trivial fix to inefficient iterator pattern

Posted by GitBox <gi...@apache.org>.
bruno-roustant commented on a change in pull request #1818:
URL: https://github.com/apache/lucene-solr/pull/1818#discussion_r482036367



##########
File path: solr/solrj/src/java/org/apache/solr/common/util/JsonSchemaValidator.java
##########
@@ -48,13 +48,15 @@ public JsonSchemaValidator(String jsonString) {
 
   public JsonSchemaValidator(Map jsonSchema) {
     this.validators = new LinkedList<>();
-    for (Object fname : jsonSchema.keySet()) {
+    for (Object entry : jsonSchema.entrySet()) {

Review comment:
       +1 (same for the other loop below)

##########
File path: .muse.toml
##########
@@ -0,0 +1 @@
+jdk11 = true

Review comment:
       Please remove this from the PR




----------------------------------------------------------------
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.

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